Programming XBee

mildenhall

New Member
I have built and successfully tested my XBee link. I want a PC->XBee link to eventually control a robot to demo to some of my pupils. As my own personal test I have written a program to read the input using serin and just output the same data using serout so that I know the 18X has received the data correctly.

This is the program I have written...

init:
high 7
pause 100

main:
serin 7, T2400, b2
pause 500
serout 7,T2400, ("xx=", b2, CR,LF)
pause 500
goto main

To send data to it I use the Serial Terminal (F8 key), with 2400, n, 8, 1.
This sometimes works, but very rarely. Does anyone know what I am doing wrong please?

Jerry
 

hippy

Ex-Staff (retired)
It should work, I have a loop-back test which sends a byte from the PC, the PICAXE increments the value and sends it back, the PC increments that and round it goes, and that is reliable and error free.

Is it simply the case that your two PAUSE's are causing the PICAXE to miss data sent ? When using the Prog Edit Terminal, you can only send one character at a time using the code you have. Because SERIN reads only a single byte, any byte in the next second or so will be lost while the PICAXE is pausing and sending a reply back.

The XBee module doesn't buffer up data until the PICAXE is ready for it and is executing a SERIN. As with normal serial, the PICAXE has to be executing a SERIN when data is sent to it or data will be lost.
 
Top