Studienarbeit
VortragWireless 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
4Quarze
CY
FF
)1(16
UxREG
FBaudRate CY
116
BaudRate
FUxREG CY
Example: Quarze: 20MHzBaudRate: 57.6KbpsUxREG = 4.42=4Real BaudRate: 62.5KbpsError: 8.5%>3%
Quarze: 22.1184MHzBaudRate: 57.6KbpsUxREG = 5Error: 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 Bits
Bit Rate from Fcy to Fcy/512
SPI Master Mode Operation
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 Blockschaltbild
nRF905 Register
nRF905 Instruction
nRF905 Configuration Register
nRF905 Configuration Register CH_NO, 9 Bits: Frequenz Einstellen
Freq = (422.4+CH_NO/10)*(1+HFREQ_PLL)MHzBeispiel: Freq = 433MHz
CH_NO=0x04c=0b001001100 HFREQ_PLL, 1 Bit: Frequenz Einstellen
0: 433MHz Band, 1: 868MHz oder 915Mhz Band PA_PWR, 2 Bits: Sendleistung Einstellen
-10dBm, -2dBm, 6dBm, 10dBm RX_AWF, TX_AWF, 3 Bits: Adressenbereit
001: 1 Byte …… 100: 4 Byte
nRF905 Configuration Register RX_PW, TX_PW, 6 Bits: Payload Bereit
000001: 1 Byte……100000: 32 Byte RX_ADDRESS, 4 Byte: Receiver Adresse XOF, 3 Bits: Oszillator Frequenz
4MHz, 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 ModePWR_UP = HITX_EN = LOTRX_CE = HI
Carrier DetectSet CD High
CorrectAddress?
no
CorrectCRC?
yes
Set AM LO
no
Set DR HI
yes
Read Data inRX_PAYLOAD
Via SPISet DR and AM LO
nRF905 Transmit
Standby ModePWR_UP = HITX_EN = HI
TRX_CE = LO
SPI ProgrammingLoad TX_ADDRESSand TX_PAYLOAD
TRX_EN = HI?
no
Transmitter isPowered up
Generate Preamble andCRC, Send Package
Set DR Hi when FinishMaximal 1ms
TRX_EN = HI?no
yes
yes
Preamble10 Bits
AddressTo 4 Bytes
DataTo 32 Bytes
CRC0, 1 or 2 Byte
Wireless Communication Interfaceunsigned char NRFConfig[10]; // Configuration Bytesunsigned char RX_ADDRESS[4]; // Speicherplatz RX Addressunsigned char TX_ADDRESS[4]; // Speicherplatz TX Addressunsigned char SpiRxBuf[32]; // Speicherplatz Receive Dataunsigned char SpiTxBuf[32]; // Speicherplatz Send Data
void SetNRFRegister(unsigned char CBit, unsigned char Register[],unsigned char Counter); // nRF905 Konfigurieren
void SetTxMode(void); // Set TX Modevoid SetRxMode(void); // Set RX Modevoid TXPackage(void); // Send Data Packagevoid RXPackage(void); // Receive Data Package
Komplete Schaltung 433MHz
Funkmodule PCB 433MHz
Anwendungsbeispiel Aufgabe: Ein String(bis 512 Byte) von einem
PC nach ander PC Schicken.
PC1 Max232 dspicFunk
Module
PC2 Max232 dspicFunk
Module
Schaltplan
Protokoll Kommunikation zwischen PC und dspic durch UART
CMD TA1 TA2 TA3 TA4 DT MP1 MP2 LL Data …… Data
byte0 byte8 byte9 byte521
•CMD: Command Byte, 0x00 für String Schicken•TA1-TA4: TX Address•DT: Datatyp (Char, Int, Float, Double...)•MP1,MP2: Maxmale Package Number
int MaxPackNr = (MP1<<8)+MP2;•LL: Last Package Length
int Datalength = (MaxPackNr-1)*29 + LL
Protokoll Wireless Kommunikation Protokoll
ROC TA1 TA2 TA3 TA4 DT MP1 MP2 LL ……byte8
•Sender: First Package
byte0
•ROC: 0x01, Request of Connection•TA1…TA4: TX Address•DT: Datatyp(Char, Int, Float, Double)•MP1,MP2: Maxmale Package Number
int MaxPackNr = (MP1<<8)+MP2;•LL: Last Package Length
int Datalength = (MaxPackNr-1)*29 + LL
Protokoll
DAT PN1 PN2 Data …… Data
byte0 byte3 byte31
•Sender:
CMD
•Empfanger:byte0
……
•DAT: 0x02, Data•PN1,PN2: Package Number int PackNr = (PN1<<8)+PN2;•Data: Byte3…Byte31
•CMD: Command Byte 0x03: Accept of Connection 0x04: Accept of Data 0x05: Error Package Number
Protokoll
ROC
AOC
DAT1
AOD
A B
Header
Pack. 1
DAT2Pack. 2
A B
DAT1Pack.1
DAT1
AOD
Pack.1
Tim
eo
ut
A B
DAT1Pack.1
DAT1
EPN
Pack.1
Tim
eo
ut
Pack.1
Pack.1Pack.1
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