Xbee remote control

Hi all
I am a noob trying to learn how to make these robots work. I have tried the PS2 controller and was not satified with the range and it seemed to keep losing the connection with the control. I then looked at the DIY XBEE control program as a noob it is greek to me. At this point I decided that the best way to learn was to jump in with both feet and try to do it myself. I started of small and hacked the PS2 control and have my T-Hex running from a terminal program using the keyboard to control it with a bluesmirf and to my suprise it worked. I have then changed over to XBEE’s and again the program still worked. I was not suprised as it was the same program but the XBEE’s worked. I have now purchased a joystick and build a button panel using a array of resistors and reading the buttons with a single pin and the adin command. Again it all worked but I am seeing some uncontrolled movements from the legs. I have tried several ways to send the data to the bot and all seem to have the same results. If I move my joystick forward or any other direction the bot will walk forward or responde as commanded but 1 or 2 legs might jump first. I have tracked this down to the point that this happens when my bot recieves the commands from my remote but I need some help finding out what is causing this unwanted movements. I have attached the code (or at least I think I have this furum stuff is new to me too) so if anyone can help you can see what I have done. Just don’t laugh to loud, as I said this is my first attempt at trying this and I think I have gotten pretty far before having to ask for help. Anyway thanks for any help in advance.
adin tx.bas (6.17 KB)
phoenix_control_serial.bas (19.8 KB)

My guess is that you are running into the issue that the interrupts caused by the HSERIAL system (hserin/hserout), is causing the data stream to the SSC-32 to be corrupted. Been there. What I did to resolve this with the DIY XBee work, was to introduce a function:

[code];==============================================================================
; [ControlAllowInput] - Are we allowing input?
;==============================================================================
_fCAI var byte
ControlAllowInput[_fCAI]:
#ifdef cXBEE_RTS
if _fCAI then
low cXBEE_RTS
else
high cXBEE_RTS
endif
#endif

g_fAllowInput = _fCAI
return
[/code]

I then soldered on a wire to the RTS line of the xbee adapter and then connected it to an IO pin on the BB2. I use one of the IO pins that output 3.3V to be safe (I believe that is pins 7 or 8) The XBee needs to be configured to watch this signal: Command “ATD6 1”. Code in DIY…

There is code in the main part that calls off to this function to disable the XBEE while we are outputting stuff to the SSC-32. Depending on what version of code you are using, it may be there or not, also the function name may have changed…

Good Luck
Kurt

Thank you for the reply. This is where my skills with basic are for a better term “basic”. I understand the problem you are discribing but I don’t understand the coding. I believe what I understand is that you are using pin 7 on the XBEE to start and stop the communication to prevent interference with the comms to the ssc-32. The high and low in your example would be tied to pin 7 and tell the xbee when it can talk. The part I don’t understand is how the #ifdef command works. Could you comment the example a little to explain what is going on in the code. As for my setup, my Xbees are on a sparkfun regulated explorer board and I am using phoenix_V20.bas with the thex_3dof_cfg.bas files. Thanks again for the help. I will print out the DIY Xbee code and see if I can understand what is going on in the mean time.

I made the code conditional on doing the turning the XBEE on or off as for example if you are on an Arc32 and the Arc32 is controlling the servos, then you don’t need to do this.
so what the #ifdef cXBEE_RTS says only include this code if the variable/value CXBEE_RTS is defined. If it is not defined, then everything in between the #ifdef and the #endif are more or less thrown away.

Yes you are understanding about what I was doing is turning on and off pin 7, which when the XBee is properly configured, tells the XBee to stop sending data. Note: it may still send up to 2 characters before it completes. The nice thing is that the XBee has it’s own buffers so it will continue to properly receive data even when you tell it not to send it to you. Obviously if you hold it off too long it has the possibility of overflowing its buffer, but…

Let me know if after looking it over you have any questions.

Kurt

OK I have added a wire to the RTS on my xbee regulator board and have it connected to P7 on the BB2.
I have found the following parts of code in the DIY and added it to the begining of the Phoenix_Control_Serial.bas file.
then added the WaitSeroutComplete to the end of the program.

_XBEE_PPP_STR bytetable “+++” ; 3 bytes long
_XBEE_ATCN_STR bytetable “ATCN”,13 ; 5 byte

ENABLEHSERIAL
SetHSerial1 H9600,H8DATABITS,HNOPARITY,H1STOPBITS

hserout [str _XBEE_PPP_STR\3]
gosub WaitHSeroutComplete
pause 20 ; have to wait a bit again
hserout “ATD6 1”,13,| ; turn on flow control
str _XBEE_ATCN_STR\5] ; exit command mode
low P7 ; make sure RTS is output and input starts off enabled…

I have then located the servo driver in the phoenix_v20.bas and added “high p7” and a “pause 20” before the servo driver starts and then “low P7” after it completes talking to the SSC-32. When testing I still have the twitch when I send commands to the robot. I tried reversing the high/low commands and have the same results. Is there a way to make sure the xbee is using the RTS? or do I have something not right in the programming?

The next thing is how is your xbee configured… That is mine are configured to have a very short timeout speed in command mode. That is I configure the guard time to 3… I do this external to this program… Command I use is “ATGT 3”. The default is 2000 (or 2 seconds), which in hex comes out as: “ATGT 3E8”. Why is this important? for the +++ command to work with an xbee, the XBee can not receive anything for the Guard time before the +++ and after the +++. So if you have the default you will need to change the pauses around this command (ATD6 1). My guess is the ATD6 was ignored as it did not properly enter into command mode.

Kurt

Its Alive and walking without kicking itself in the butt anymore. Thank You Kurte.
I know as a noob that I will never be able to return the favor as a programmer. but if you ever need the assistance of a laser ingraver / cutter please look me up. I will try to attach some photos of the clear apod I am working on and some wire guides that I added to the legs of my T-Hex. I know a lot of people say acrlic in a no no. But if you have a laser to cut it you can do some amazing things with it. The last photo is a clock showing gears that were cut from acrylic.





Sorry for the quality of the pics my camera batteries were dead and the only thing available was my Ipod.
OK, Don’t tell my wife but the camera batteries are in my bot

You give laser cutting a whole new meaning! When I saw the Apod, I was like :slight_smile: then when I saw the clock :open_mouth: :smiley:
Looks uhh-mazing!

Cool! How about in metal?

Alan KM6VV

It will engrave metal but it won’t cut it. That would have been nice but when my wife found out that I could have bought a car for what this machine cost :frowning: , it nearly cost me my marrage. The only thing that saved me was when I showed her how to run it and she found out she could engrave wine bottles and glasses and it would do things for her hobbies and even make a few bucks too. That was a close one, but both me and the laser stayed :smiley: . It will cut wood and plastics up to about 3/8" thick in a single pass. I cut out the APods body in about 5 minutes. seems quick but you also need to add the time at the computer drawing it all. If you wan’t to check it out on the net it is a epilog 30 watt mini 24. Anyway thanks for the comments and now back to my bot.

I didn’t see the price right off, so I probably can’t afford it. ;>|

Alan KM6VV

I think I saw a used one, for about $12.5K :open_mouth: : community.benchmarkemail.com/use … -Available

Yeah… that probably won’t help!

But thanks for the URL