Tx Rx with IR buddy Pair
vincent
Posts: 11
' {$STAMP BS2p} ' {$PBASIC 2.5} TX CON 14 RX CON 15 Irbpin PIN 0 system VAR Byte command VAR Byte buffer VAR Byte(8) GOSUB IR_Buddy_Reset TX_Code: SEROUT 14, 9600, [noparse][[/noparse]$74, 0, 38, system, command] PAUSE 5 TX_Wait: IF (INS.LOWBIT(Irbpin) = 0) THEN TX_Wait SEROUT 15, 9600, [noparse][[/noparse]$72, 10] ' <---- SERIN 15, 9600, [noparse][[/noparse]STR buffer\8\255] DEBUG "buffer = ", STR buffer,CR END ' Reset the IR Buddy. This code is useful for clearing data from the RX ' buffer and prepping to switch modes. Timing specific; do not change. IR_Buddy_Reset: LOW RX ' signal reset LOW TX PAUSE 5 INPUT RX ' release reset signal INPUT TX PAUSE 50 ' allow time for reset actions RETURN
Hi guys,
I jus try out the IR buddy pair that i have to do some simple transmit and recieve but it didn't ouput anything at the debug screen. I did some simple debugging and found out that it stops at
SEROUT 15, 9600, [noparse][[/noparse]$72, 10]··· *where the arrow is pointing.
Any reason why it didn't continue on to the rest of the codes???
Regards,
Vincent
Comments
My guess is that it's never leaving the tight loop just above the place you have indicated:
TX_Wait:
IF (INS.LOWBIT(Irbpin) = 0) THEN TX_Wait
I'm not quite sure what that rather esoteric bit of code is supposed to accomplish, but I think it boils down to looking at pin port zero (one bit) and checking it for a 0 (low). If it's a 0, it loops back and checks it again. If it never changes from zero, the program never continues.
What's on pin port 0 (aka Irbpin)? Will it ever change? If so, under what conditions?
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 10/10/2005 8:15:38 AM GMT
This program is actually taken from the IR BUDDY demo kit documentation which is available here:
http://www.parallax.com/dl/docs/prod/comm/irbuddymanual.PDF
I took the example codes from page 3 and page 4 of the documentation and sort of compiled them into a program as shown above, just to test out if my IR Buddy actually works.
There isn't any particular hardware connected on pin port 0, so i can't really answer your question.
Regards,
Vincent
If indeed, as you say, "there isn't any particular hardware connected on pin port 0", then everything I said holds true, and the program will enter an infinite loop exactly where I mentioned. You might do well to try and find out what was supposed to be hooked up to that pin before you continue much further.
I downloaded the sample programs for the Ir Buddy, and didn't see any indication therein as to what the purpose of pin port zero was, that's why I answered your quandry the way I did. I'll shoot over and grab the manual now, and see what I can find out as well.
Regards,
Bruce Bates
Based on what I see quickly, I suspect this may get you around your present problem. Add this statement to the end of your pin definitions:
Irbpin con Tx
Regards,
Bruce Bates
·· Your code shows the RX pin being 15, and the TX pin being 14, but you're trying to SEROUT and SERIN on the same pin at the point where your code stops.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
The codes folowing after Tx wait section is to receive the codes. I read according to the notes(pg 3), the first line is to send the command protocol and the second line is to recieve the data. Or am i doing it wrongly still?
I also jus realis something , my IR have this blue LED but on power up , it didn't lights-up. Is it suppose to be that way or the other way round?
Regards,
Vincent