IR buddy
yzche
Posts: 35
I am using IR buddy from http://www.parallax.com/detail.asp?product_id=28016
I use following command to send info 12345678
SEROUT·· IRbSIO,·· IRb96, [noparse][[/noparse]$44, 38,1,2,3,4,5,6,7,8, STR buffer\8]
following is the command to receive the info
SEROUT IRbSIO, IRb96,[noparse][[/noparse]$64]
SERIN·· IRbSIO, IRb96,[noparse][[/noparse] STR buffer\8]
for counter =·0 to 7
debug dec buffer(counter), cr
next
However, when it is receive by another IR buddy
the result is 11345678
any idea why?
I use following command to send info 12345678
SEROUT·· IRbSIO,·· IRb96, [noparse][[/noparse]$44, 38,1,2,3,4,5,6,7,8, STR buffer\8]
following is the command to receive the info
SEROUT IRbSIO, IRb96,[noparse][[/noparse]$64]
SERIN·· IRbSIO, IRb96,[noparse][[/noparse] STR buffer\8]
for counter =·0 to 7
debug dec buffer(counter), cr
next
However, when it is receive by another IR buddy
the result is 11345678
any idea why?
Comments
and give it another try.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
It did not work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
following are code for my program
' {$STAMP BS2}
' {$PBASIC 2.5}
'sent.BS2
buffer VAR Byte
IRbSIO········· PIN···· 14····················· ' IR Buddy serial I/O
IRb96 CON 84+$8000
main :
GOSUB ir_buddy_reset
SEROUT·· IRbSIO,·· IRb96, [noparse][[/noparse]$44, 38, 1, 2, 3, 4, 5, 6, 7, 8]
DEBUG "data sent", CR
PAUSE 500
GOTO main
IR_Buddy_Reset:
· LOW IRbSIO··································· ' signal reset
· PAUSE 5
· INPUT IRbSIO································· ' release reset signal
· PAUSE 50····································· ' allow time for reset actions
· RETURN
' {$STAMP BS2}' {$PBASIC 2.5}'receive.bs2buffer VAR ByteIRbSIO PIN 15 ' IR Buddy serial I/OIRb96 CON 84+$8000c VAR Bytemain :GOSUB IR_Buddy_ResetSEROUT IRbSIO, IRb96,[noparse][[/noparse]$64]buffer(0)=0SERIN IRbSIO, IRb96, [noparse][[/noparse] STR buffer\8]DEBUG "data receive", CRFOR c = 0 TO 7 DEBUG DEC buffer(c)NEXTDEBUG CRtx_wait: IF(INS.LOWBIT(IRbSIO)=0) THEN tx_wait GOTO main IR_Buddy_Reset: LOW IRbSIO ' signal reset PAUSE 5 INPUT IRbSIO ' release reset signal PAUSE 50 ' allow time for reset actions RETURN
The variable named "buffer" needs to be 8 BYTES long, as indicated in the demo programs supplied by Parallax. Therein is the first problem.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
buffer········· VAR···· Byte··················· ' tx-rx buffer (8 bytes)·
cmd············ VAR···· Byte
data1·········· VAR···· Byte
data2·········· VAR···· Byte
data3·········· VAR···· Byte
data4·········· VAR···· Byte
data5·········· VAR···· Byte
chkSum········· VAR···· Byte
I don't see any array from the code.
As to the demo code above, since the BASIC Stamp treats RAM as an array you can get do this:
and you'll get $FF.·· Just to be explicit, here is how the [noparse][[/noparse]implicit] array is organized:
buffer(0) = buffer
buffer(1) = cmd
buffer(2) = data1
buffer(3) = data2
buffer(4) = data3
buffer(5) = data4
buffer(6) = data5
buffer(7) = chkSum
When using the implicit array nature of the BASIC Stamp, you must be very careful of the order of assignments, and make sure that you keep like-sized variables grouped to gether so that you're mindful of the assignment order. The compiler places words first, then bytes, then nibs, finally bits.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Post Edited (Jon Williams) : 8/24/2004 6:38:13 AM GMT