Receiving multiple bytes?
Hello,
I'm working on a Remote Unit to report temperature using a DS1620 and door position using a proximity switch. The DS1620 requires a WORD variable and the door requires a BIT. Eventually this will include 5 Remote Transmitters but I'm working with only one now to get it functional.
I need to send the WORD and BIT from one Series 1 XBee to another. I've only seen references in the XBee Turorial to sending BYTES so I'm sending one WORD and one BYTE. See relevent code below
Transmitter code:
The code displays the correct information if only one of the SERIN statements is included (with the other SERIN statement commented out). But Switch just displays 0 with both statements in the code. I added separate Timeout statements but that didn't help.
I was hoping to receive both variables with one statement as follows, but that did not work either
Is it possible to send a WORD variable and decimal data using one SERIN statement?
falcon
I'm working on a Remote Unit to report temperature using a DS1620 and door position using a proximity switch. The DS1620 requires a WORD variable and the door requires a BIT. Eventually this will include 5 Remote Transmitters but I'm working with only one now to get it functional.
I need to send the WORD and BIT from one Series 1 XBee to another. I've only seen references in the XBee Turorial to sending BYTES so I'm sending one WORD and one BYTE. See relevent code below
Transmitter code:
tempIn VAR Word Switch VAR Byte SEROUT Tx, Baud, [DEC Switch, CR] SEROUT Tx, Baud, [TempIn]Receiver code:
main:
Switch VAR Byte
tempIn VAR Word
PAUSE 500
DEBUG "Configuring XBee...",CR
PAUSE 2000 ' Guard Time
SEROUT Tx,Baud,["+++"] ' Command mode sequence
PAUSE 2000 ' Guard Time
SEROUT Tx,Baud,["ATD6 1,CN",CR] ' RTS enable (D6 1)
' Exit Command Mode (CN)
' ************** Main LOOP ******************************
PAUSE 500 ' 1/2 second pause to stabilize comms
DEBUG "Awaiting Byte Data...",CR
DO
SERIN Rx\RTS,Baud,1000,TimeOut1,[tempIn] ' Use Timeout to wait for byte
Timeout1:
SERIN Rx\RTS,Baud,1000,TimeOut2,[DEC Switch] ' Use Timeout to wait for byte
'GOTO Done ' Jump to done
Timeout2: ' If no data, display
Done:
DEBUG CRSRXY, 0, 2, TempIn, CR
DEBUG CRSRXY, 0, 5, DEC Switch, CR
goto main
The code displays the correct information if only one of the SERIN statements is included (with the other SERIN statement commented out). But Switch just displays 0 with both statements in the code. I added separate Timeout statements but that didn't help.
I was hoping to receive both variables with one statement as follows, but that did not work either
SERIN Rx\RTS,Baud,1000,TimeOut,[TempIn, DEC Switch]
Is it possible to send a WORD variable and decimal data using one SERIN statement?
falcon

Comments
shouldn't that be reversed?
That was the problem. Both code lines are not always sent at the same time, but I was able to modify the sequence so that when both are sent the TempIn is always sent first.
falcon