
599 Menlo Drive • # 100 • Rocklin, CA 95765
Sales / Technical Support - Tel: (916) 624-8333 Fax: (916) 624-8003
Web: http://www.parallaxinc.com or http://www.stampsinclass.com • Email: [email protected]
1-27-2000, V1.0 • Mfg. by www.
RFDigital.com
Page
12
RF MODULES
n+3 doesn’t exist). The second method is based on a Cyclic-Redundancy-Check algorithm. The CRC16, as it is
called, uses a sophisticated equation to calculate a checksum that catches 99% of transmission errors and is
unaffected by symmetrical data. (If this method is used, Byte n+3 is the last byte of the packet).
The Master and Slave use an acknowledge-based protocol to communicate with each other. The process works
in the following fashion:
a) The Master decides to send some data.
i)
It creates a new packet number (previous packet 1).
ii) It builds a packet, one byte at a time, calculating the checksum (using the XOR or the CRC method)
for each byte. It finishes the packet by appending the checksum (1 or 2 bytes) to the end.
iii) It transmits the entire packet.
b) The Slave periodically checks for incoming data.
i)
If a packet arrives, it calculates a checksum (using the same method as the Master).
ii) If the calculated checksum matches the received checksum, the Slave transmits a positive
acknowledgement to the Master (by simply transmitting the checksum).
iii) If the calculated checksum does not match the received checksum, the Slave transmits a negative
acknowledgement to the Master (by simply transmitting the one’s-compliment form of the checksum).
iv) If the packet is good (as determined by step ii above) the Slave verifies that that packet number is not
the same as the previous packet’s (indicating that a duplicate was received) and processes the data
of the packet. In this example, the process is simply to pass the data on to the Serial LCD Display. If
the packet number is the same, the packet is just ignored.
v) If the packet is bad (as determined by step iii above), the Slave starts over, looking for a packet
again.
c) The Master, immediately after sending the packet, looks for an acknowledgement from the Slave.
i)
If a negative acknowledgement or no acknowledgement was received, the Master delays a random
amount of time (0 to 255 ms) and then retransmits the entire packet.
ii) If a positive acknowledgement was received, the Master continues with its other tasks.
Using the above methods of transmission, data can be sent reliably for more than 250 feet. Our tests reached
more than 400 feet, with trees and buildings in between. Many packets became lost or damaged in transmission
but the two devices were able to adjust for this and communicate slowly. Your environment may cause different
results.
The source code provide is named “Txcvr_Master_…” and “Txcvr_Slave_…”. Each piece of code has a
corresponding companion program. For example, the Txcvr_Master_XOR.BS2 source code uses the XOR
method and is meant to be programmed into the “Master” device (a BASIC Stamp 2). The Slave device should
be programmed with the corresponding “Slave” code, namely Txcvr_Slave_XOR.BS2.
Be very careful to match up the correct code for the device and application. Do not try to program a BASIC
Stamp 2sx with code that ends in a .BS2 extension. Do not try to use the XOR code for the Master and the CRC
code for the Slave
.