300 likes | 408 Views
Studienarbeit. Vortrag Wireless Communication Von Spisa Yang Liu(215622) 30.11.2005. Einleitung. Digital Signal Controller(dspic30F3013) I/O Ports UART SPI Radio Frequenz Funkmodule nRF905 Transceiver Steuerungsregister Transmit and Receive Komplete Module Interface
E N D
Studienarbeit Vortrag Wireless Communication Von Spisa Yang Liu(215622) 30.11.2005
Einleitung • Digital Signal Controller(dspic30F3013) • I/O Ports • UART • SPI • Radio Frequenz Funkmodule • nRF905 Transceiver • Steuerungsregister • Transmit and Receive • Komplete Module • Interface • Anwendungsbeispiel
dspic30F3013 I/O Ports • TRISx: Data Direction Register • 1:Input, 0:Output • PORTx: I/O Port Register • Read: Value of the I/O Pin • Write: To Port Data Latch • LATx: I/O Latch Register • Read: Value in Port Data Latch • Write: To Port Data Latch • ADPCFGx: ADC Port Configuration Register (Port B) • 1: Digital I/O, 0: Analog I/O
Universal Asynchronous Receiver Transmitter(UART) • Full-Duplex 8- or 9 Bit Data Transmission • Even, Odd or No Parity • One or Two Stop Bits • Fully Integrated Baud Rate Generator 16 Bit Prescaler • Baud Rate 29bps to 1.875Mbps • 4 Deep FIFO Transmit Data Buffer • 4 Deep FIFO Receive Data Buffer • Error Detection • 9 Bit Mode with Address Detection • Transmit Receive Interrupt
UART Register • Control Register: UxMode • Enable, Alterative IO Pins, Parity Data Selection… • Status and Control Register: UxSTA • Transmit Enable, Address Detect Mode, Error Detection, Buffer Overflow, Transmit Buffer Full… • Receive Register: UxRXREG • Example: unsigned char c = U1RXREG; • Transmit Register: UxTXREG • Example: U1TXREG = ‘c’; • Baud Rate Generator: UxBRG
UART Register Example: Quarze: 20MHz BaudRate: 57.6Kbps UxREG = 4.42=4 Real BaudRate: 62.5Kbps Error: 8.5%>3% Quarze: 22.1184MHz BaudRate: 57.6Kbps UxREG = 5 Error: 0%
Serial Peripheral Interface(SPI) • Synchronous Serial Interface communicate with other Peripheral or Microcontroller • Serial EEPROMs, Shift Register, Display Drivers, ADCs, nRF905 • SPI Interface consist of 4 Pins • SDIx: Serial Data Input • SDOx: Serial Data Output • SCKx: Shift Clock Input or Output • SSx: Active low Slave Select or Frame Synchronization I/O Pulse
SPI Register • SPI Status and Control Register: SPIxSTAT • SPI Enable, SPI Transmit Buffer Full Status, SPI Receive Buffer Full Status • SPI Control Register: SPIxCON • Framed SPI Support, 8-Bit or 16-Bit Select, Master or Slave Select • Secondary and Primary Prescale BitsBit Rate from Fcy to Fcy/512
Radio Frequenz Funkmodule • Single Chip Transceiver nRF905 • 433MHz, 868MHz, 915MHz ISM Band • GFSK Transceiver • Betriebspannung 1.9v-3.6v • Bis 50Kbps • Multikanäle • Senderleistung –10dBm--10dBm • Carrier Detection • Adress Match von Packet • 8-Bit, 16-Bit CRC Codierung • Manchester Codierung • 5x5mm 32Pin QFN Package
nRF905 Configuration Register • CH_NO, 9 Bits: Frequenz EinstellenFreq = (422.4+CH_NO/10)*(1+HFREQ_PLL)MHzBeispiel: Freq = 433MHz CH_NO=0x04c=0b001001100 • HFREQ_PLL, 1 Bit: Frequenz Einstellen0: 433MHz Band, 1: 868MHz oder 915Mhz Band • PA_PWR, 2 Bits: Sendleistung Einstellen-10dBm, -2dBm, 6dBm, 10dBm • RX_AWF, TX_AWF, 3 Bits: Adressenbereit001: 1 Byte …… 100: 4 Byte
nRF905 Configuration Register • RX_PW, TX_PW, 6 Bits: Payload Bereit000001: 1 Byte……100000: 32 Byte • RX_ADDRESS, 4 Byte: Receiver Adresse • XOF, 3 Bits: Oszillator Frequenz4MHz, 8MHz, 12MHz, 20MHz011: 16MHz • CRC_EN 1 Bit: CRC Codierung Enable0: Disable, 1: Enable • CRC_MODE 1 Bit: CRC Codierung Mode0: 8 Bit Mode, 1: 16 Bit Mode
nRF905 Register and Control • TX_ADDRESS, 4 Byte: Send Address • TX_PAYLOAD, 32 Byte: Send Data • RX_PAYLOAD, 32 Byte: Receive Data • STATUS_REGISTER, 1 Byte: • AM, DR
nRF905 Receive Standby Mode PWR_UP = HI TX_EN = LO TRX_CE = HI Carrier Detect Set CD High Correct Address? Correct CRC? yes no no yes Set AM LO Read Data in RX_PAYLOAD Via SPI Set DR and AM LO Set DR HI
nRF905 Transmit Standby Mode PWR_UP = HI TX_EN = HI TRX_CE = LO SPI Programming Load TX_ADDRESS and TX_PAYLOAD TRX_EN = HI? Transmitter is Powered up yes no yes TRX_EN = HI? Generate Preamble and CRC, Send Package Set DR Hi when Finish Maximal 1ms no Preamble 10 Bits Address To 4 Bytes Data To 32 Bytes CRC 0, 1 or 2 Byte
Wireless Communication Interface unsigned char NRFConfig[10]; // Configuration Bytes unsigned char RX_ADDRESS[4]; // Speicherplatz RX Address unsigned char TX_ADDRESS[4]; // Speicherplatz TX Address unsigned char SpiRxBuf[32]; // Speicherplatz Receive Data unsigned char SpiTxBuf[32]; // Speicherplatz Send Data void SetNRFRegister(unsigned char CBit, unsigned char Register[], unsigned char Counter); // nRF905 Konfigurieren void SetTxMode(void); // Set TX Mode void SetRxMode(void); // Set RX Mode void TXPackage(void); // Send Data Package void RXPackage(void); // Receive Data Package
Anwendungsbeispiel • Aufgabe: Ein String(bis 512 Byte) von einem PC nach ander PC Schicken. PC1 Max232 dspic Funk Module PC2 Max232 dspic Funk Module
Protokoll • Kommunikation zwischen PC und dspic durch UART byte0 byte8 byte9 byte521 CMD TA1 TA2 TA3 TA4 DT MP1 MP2 LL Data …… Data • CMD: Command Byte, 0x00 für String Schicken • TA1-TA4: TX Address • DT: Datatyp (Char, Int, Float, Double...) • MP1,MP2: Maxmale Package Numberint MaxPackNr = (MP1<<8)+MP2; • LL: Last Package Lengthint Datalength = (MaxPackNr-1)*29 + LL
Protokoll • Wireless Kommunikation Protokoll • Sender: First Package byte0 byte8 ROC TA1 TA2 TA3 TA4 DT MP1 MP2 LL …… • ROC: 0x01, Request of Connection • TA1…TA4: TX Address • DT: Datatyp(Char, Int, Float, Double) • MP1,MP2: Maxmale Package Numberint MaxPackNr = (MP1<<8)+MP2; • LL: Last Package Lengthint Datalength = (MaxPackNr-1)*29 + LL
Protokoll • Sender: • Empfanger: byte3 byte31 byte0 byte0 DAT PN1 PN2 Data …… Data CMD …… • CMD: Command Byte 0x03: Accept of Connection 0x04: Accept of Data 0x05: Error Package Number • DAT: 0x02, Data • PN1,PN2: Package Numberint PackNr = (PN1<<8)+PN2; • Data: Byte3…Byte31
Protokoll B B A A B A Pack.1 Pack.1 Header ROC DAT1 DAT1 Timeout Timeout Pack.1 AOC Pack.1 Pack.1 Pack. 1 DAT1 DAT1 DAT1 Pack.1 Pack.1 AOD AOD EPN Pack. 2 DAT2 Pack.2
Literatur • [1] dsPIC30F Family Reference Manual www.microchip.com • [2] dsPIC30F3013 Data Sheet www.microchip.com • [3] MPLAB C30C COMPILER USER'S GUIDE www.microchip.com • [4] NORDIC SEMICONDUCTOR, Single Chip 433/868/915MHz Transceiver nRF905 www.nordicsemi.no • [5] William Stallings, Data & Computer Communications Sixth Edition, Publishing House of Electronics Industry Beijing, 2001 • [6] Karl-Dirk Kammeyer, Nachrichtenübertragung 3. Auflage, Teubner Verlag, 2004 • [7] Gordon L. Stueber, Principles of Mobile Communication Second Edition, Kluwer Academic Publishers, 2001