Boe Bot wireless control using XBee radios
Hi
Let me first explain what my current setup is and what I've got working so far.
I have the Boe Bot with the basic stamp 2 module. I've mounted a XBee radio on the breadboard. On my laptop I've connected an addional XBee to function as a coordinator. By sending simple ASCII characters to the Boe Bot using a JAVA GUI on my laptop, I am able to control my Boe Bot wireless.
When I hit the 'forward' button on my GUI it sends the 'F' character to my Boe Bot and it starts moving for as long as the loop around the servo pin sends pulses. After that the bot stops and comes back to the SERIN command to wait for the next command to arrive.
This is not what I want to achieve. The bot should keep moving forward until a 'stop' command is received. I've tried to workaround this problem by using the timeout function for the SERIN command but this creates a new issue. There is no buffering and the Basic stamp 2 isn't capable of using threads, therefore it is sometimes unable to receive incoming commands because the BS2 is busy powering the servo's.
Is there a workaround without using a multicore module?
Let me first explain what my current setup is and what I've got working so far.
I have the Boe Bot with the basic stamp 2 module. I've mounted a XBee radio on the breadboard. On my laptop I've connected an addional XBee to function as a coordinator. By sending simple ASCII characters to the Boe Bot using a JAVA GUI on my laptop, I am able to control my Boe Bot wireless.
When I hit the 'forward' button on my GUI it sends the 'F' character to my Boe Bot and it starts moving for as long as the loop around the servo pin sends pulses. After that the bot stops and comes back to the SERIN command to wait for the next command to arrive.
This is not what I want to achieve. The bot should keep moving forward until a 'stop' command is received. I've tried to workaround this problem by using the timeout function for the SERIN command but this creates a new issue. There is no buffering and the Basic stamp 2 isn't capable of using threads, therefore it is sometimes unable to receive incoming commands because the BS2 is busy powering the servo's.
Is there a workaround without using a multicore module?

Comments
I attached the PDF for the ServoPal so you can see it will help you out and hope it take care of you problem
Thanks for the info William, I appreciate it! Unfortunately this would require additional hardware. Is this issue really impossible to resolve just by using a Boe and BS2?
No, but it will take care of the big problem that you have. Using the ServoPal frees up the Basic Stamp to handle the XBee radio code. But, thing you can do is post your code so I and others can see were you need to improve it. There maybe a way, to code it without the ServoPal.
' ========================================================================= ' ' {$STAMP BS2} ' {$PBASIC 2.5} ' ' ========================================================================= ' -----[ Program Description ]--------------------------------------------- ' ' This program is meant to drive a BOE-Bot by receiving commands from an ' XBee wireless radio. The commands are simple ascii characters, ' the charachters on the keyboard are used to control ' how the BOE-Bot drives. ' -----[ Revision History ]------------------------------------------------ ' -----[ I/O Definitions ]------------------------------------------------- XBEE_TX PIN 4 'connect to DIN pin on XBee module XBEE_RX PIN 3 'connect to DOUT pin on XBee module L_MOTOR PIN 13 R_MOTOR PIN 12 servoPin PIN 14 ' -----[ Constants ]------------------------------------------------------- L_FWD CON 1000 L_REV CON 500 L_STOP CON 750 R_FWD CON 500 R_REV CON 1000 R_STOP CON 750 BAUD_MODE CON 6 '38400 Baud, 8n1 true CmConstant CON 2260 InConstant CON 890 ' -----[ Variables ]------------------------------------------------------- i VAR Byte rx_data VAR Byte cmDistance VAR Word counter VAR Byte time VAR Word pingRatio VAR Word ' -----[ Initialization ]-------------------------------------------------- Initialization: LOW L_MOTOR LOW R_MOTOR ' -----[ Program Code ]---------------------------------------------------- Main: pingRatio=750 GOSUB CenterPing DO SERIN XBEE_RX, BAUD_MODE, [STR rx_data\1] 'get data from the XBee DEBUG "Received data: ", rx_data SELECT rx_data CASE $6C ' ascii for 'l' GOSUB Turn_left CASE $62 ' ascii for 'b' GOSUB Backup CASE $72 ' ascii for 'r' GOSUB Turn_right CASE $66 ' ascii for 'f' GOSUB Forward CASE $6D ' ascii for 'm' GOSUB Measure CASE $7A ' ascii for 'z' GOSUB TurnPingLeft CASE $78 ' ascii for 'x' GOSUB TurnPingRight ENDSELECT LOOP END CenterPing: FOR counter = 1 TO 20 PULSOUT servoPin, 750 PAUSE 20 NEXT RETURN TurnPingLeft: pingRatio=pingRatio+50 FOR counter = 1 TO 20 PULSOUT servoPin, pingRatio PAUSE 20 NEXT RETURN TurnPingRight: pingRatio=pingRatio-50 FOR counter = 1 TO 20 PULSOUT servoPin, pingRatio PAUSE 20 NEXT RETURN Measure: PULSOUT 2, 5 PULSIN 2, 1, time cmDistance = cmConstant ** time DEBUG DEC3 cmDistance, " cm", CR SEROUT XBEE_TX, BAUD_MODE, [DEC3 cmDistance] RETURN Forward: 'drive the BOE-Bot forward DEBUG "Forward", CR FOR i = 0 TO 15 PULSOUT L_MOTOR, L_FWD PULSOUT R_MOTOR, R_FWD PAUSE 20 NEXT RETURN Backup: 'drive the BOE-Bot backwards FOR i = 0 TO 15 PULSOUT L_MOTOR, L_REV PULSOUT R_MOTOR, R_REV PAUSE 20 NEXT RETURN Turn_left: 'turn the BOE-Bot left FOR i = 0 TO 10 PULSOUT L_MOTOR, L_STOP PULSOUT R_MOTOR, R_FWD PAUSE 20 NEXT RETURN Turn_right: 'turn the BOE-Bot right FOR i = 0 TO 10 PULSOUT L_MOTOR, L_FWD PULSOUT R_MOTOR, R_STOP PAUSE 20 NEXT RETURNPE -- If you were using a motor, instead, then you could turn the motor onto Forward and then go and wait indefinitely for that next SERIN.