
Parallax, Inc. • IR Buddy Demo Kit (#28016) • 11/2002
Page 15
IR Buddy Application: Master Controller
This application demonstrates the use of data communications between BASIC Stamps using the IR
Buddy's 8-byte data packet mode. This program, the master controller, sends an 8-byte packet to a
slave controller. The slave will validate the packet and if the transmission was successful will act on it
and respond accordingly. If the packet was not received properly, the slave will respond with an error
message and the master will retransmit the the packet.
In this application the 8-byte packet is structured accordingly:
0 Header
1 Command
(i.e., Light LEDs on slave)
2 Data byte 1
(i.e., LED pattern for slave LEDs)
3 Data byte 2
4 Data byte 3
5 Data byte 4
6 Data byte 5
7 Checksum
The use of a pre-defined header byte and a simple checksum algorithm allows the slave to validate the
packet before acting on the command. The software validation, combined with the IR Buddy's robust
modulation scheme ensures reliable transfers under the worst of conditions.
' -----[ Title ]----------------------------------------------------------------
'
' IRB Master.BS2
' {$STAMP BS2}
' -----[ I/O Definitions ]------------------------------------------------------
IRbSIO CON 15 ' IR Buddy serial I/O
TxLED CON 0 ' transmitter on indicator
' -----[ Constants ]------------------------------------------------------------
IRbDataTx CON $44 ' 8-byte data transmit
IRbDataRx CON $64 ' 8-byte data receive
IRbMod CON 38 ' modulation freq: 30, 38 or 56