DIY Remote Control XBee controller for Robotics

Quick Update: I changed my Axon2 program to show me the current version of the XBEE and it shows 10E6. My other ones are 1084 I think. So that may be my problem. Sparkfun may have changed the default version they send…

Kurt

:laughing: I’m not back yet though, I’ve just brought my laptop with me…

Its a good thing that it work for you then!

I didn’t get any contact setting the DL manually. No robot show up in the the list.
I am using another Pan ID than the default one though.

I’ll have to take a closer look to all this when I’m home again.

Thanks for your help!

Meanwhile, I’ve been thinking of adding two more potentiometers. Would that be very hard to add into your code?
Have tried to understand your code (not finished studying it completely). An example: the fPacketChanged variable, I guess that need to be changed to a word since I need 10 bPackets?
Code from main loop:

; finally increment the index and limit its range to 0 to 7. index = (index + 1) & 7
I assume the index still has the same range (0-7)?

Does the additional packets make trouble for timing etc?

We will have to debug more when you get back. Did you bring a robot with you as well? :slight_smile: Sounds like my kind of vacation.

For the ATND command to work, it will only find those XBEES that are on the same channel and PAN ID. I also read somewhere that all of the XBEES on a specific pan ID should have the same version. So I will probably change all of mine. I have not decided yet if to revert the one back to 1084 or to upgrade all of mine to 10E6. For the heck of it I will also probably change all of mine from the default channel and pan id as well.

If you set it up manually, then it still won’t show up in the other list. So far I have not found a transparent way to say for an DL: give me back their serial number and Node Identifier. Of course I can add that to my own code, which I may do, especially if ATND continues to be flaky. Would not be much code. Add A request packet id and a Response packet id, with maybe 22 extra bytes returned (I limit my NI information to 14 characters as display is only 16…

Should not be hard to add extra stuff to the packet. Simply redefine the code that sends it as well as the code that receives it to know about the extra length. There are probably several places where the size is hard coded. Maybe while doing some more cleanup I will parameterize it better.

The code you mentioned about index limited to 0-7 is not related. It is used to average the values returned by the AtoD conversions. We average the last 8 readings are the current value for the joysticks as well as the sliders.

My guess is if you add 2 more bytes to the packet there will be almost zero differences in speed.

Kurt

EDIT: Update - I did change my one to version 1084 to match the others and it is acting much better now. My Configure program now does print out the current xbee version (if it can get the right baud rate)… I will silently update the previous post with the zip file with this. You may want to check yours to see if they are all running the same version or not…

I am also in the process of when you add an item by number, it will ask the robot at the other side for its serial number and node identifier. Regardless if it gets the new data, it hopefully will add it to the list of robots with probably some identifier like: _unknown_XXXX where XXX is the hex my value, so you can later just scroll through them and select them in the other screen. Will post more later when I have completed it and it looks like it is at least starting to work :slight_smile: so I can avoid the :blush:

:laughing: No I didn’t have one of my robots with me. I believe my wife would go pretty crazy if I did so. She already complains that I’ve spent to much time with my laptop… :unamused:

Sounds great Kurt! I hope to start with this as soon as I have a DIY remote working fine with your latest code. I’m planning to add one potmeter on top of each joystick, I need to make some custom parts at work first. I’m also thinking of replacing or modify the left joystick to be a spring-centered joystick in the up/down direction too like the right joystick are.

Ok, I thought it was something like that.

Sounds very promising! Looking forward to measure the difference.

I have a little hope that this is the cause for why I have some trouble. When I ordered my XBee’s I noticed that two of them was set to default baud speed = 115200 not 9600 as the other was. Probably was these two a part of the Arbotix kit. Maybe these two XBee’s had a different version than the other ones?

Looking forward to check this out.

Thanks!

Sounds like a reasonable compromise. :laughing:

Yep, I am playing with adding in the extra messages to query the robot for the information. May be overkill. I ran into a couple of problems along the way. First a compiler issue.
return -1
Does not compile at least with 1.0.0.15, but I found that
return (-1)
Does…

Then I actually ran out of program space on the BAP. Now I did have a lot of debug stuff in, but I started to clean things up. One thing that may surprise people is that if I change the code:

From:
    serout Display, i19200, [254, 0, "Calibrating..."] 
To:
    _CB_PROMPT_STRING	bytetable 254, 0, "Calibrating..."	; 16
    gosub TASerout[Display, i19200, @_CB_PROMPT_STRING, 16]

Or:
    serout Display, i19200, [str CB_PROMPT_STRING\16] 

Actually shrinks the code by something like 44 bytes. Why? Because in basic passing a string like “ABCD” actually passes each character as a long (4) byte value to the function. So I am walking through the code making those types of changes. Also will try to do some standard string (bytetable) sharing. Like certain strings like: “+++”, “ATCN” are shared in a few places.

Well now back to cleanup. So far I am back to 1670 bytes free with debug still turned on…

Yeah, that was a little suprise! Very useful information Kurt.

I’ve been studying your code a bit more. One little Q: @bPacket does that mean all 8 bytes in the bPacket? I searched for the @ in the basic atom pro syntax manual but couldn’t find anything. What does the @ mean? A pointer to a data table? Sorry for the stupid question. :blush:

Hi again,

The @ has to meanings as sort-of described in the post: viewtopic.php?f=4&t=4664

Nathan defined a new data type of Pointer, Below is some sample like code that shows how these can be used. If the @ is in front of a variable or the like that is not a pointer, the result will be the address of the thing. If the @ is in front of a pointer variable it says use the value of what is in the pointer variable as the address of what you wish to use.

myP    var    pointer    ; This stores the address of something.
MyD    var    byte        ; some data variable 
MyT    bytetable   "CAT",0  ; some other data.

MyD = 4                     ; Assign some value to your data
MyP = @MyD              ; Assigns the addres of MyD into MyP

serout s_out, i9600, [dec @MyP]    ; will print out 4 as @MyP gets what is at the address.
...
MyP = @MyT              ; points MyP to the start of the table of bytes.

while @MyP               ; Loop while the characer pointed to by MYP <> 0
    ...
    MyP = MyP + 1       ; Point to the next byte.
wend

Some side note:

In MyP = MyP + 1, I think it literally adds 1, so for example if you are using a wordtable instead of a bytetable, it will probably not go the next element of the wordtable, but instead will be to the second byte of the first element.

I believe you can use the pointer with arrays:
So with: MyP = @MyT
I think you can do something like: @MyP[1] and it will return the “A”
Edit: Note - I think that if in the example @MyP1} that MyP was pointing to a WORDTABLE, then maybe the array reference will point to the 2nd element of the word table (ie it knows about the size of element)

I hope that helps

Thanks Kurt, it helped alot!

I had to read it (and the other thread) several times before I understood why @MyP returned 4 in your example.

Hi Kurt,

I’m back home again. And I’ve done some testing but I’ve still problem with your latest DIY remote code. Both XBee’s have the 1084 version. When I try to do a node detection on the DIY remote (push the A-button) the LCD display only show “-- Scan XBees --” in a very short fraction of a second (I can barely see the text). Then the display show "*** None *** " again.

I did also do a node detection using a third XBEE on the USB board and X-CTU.
The node detection (atnd) gave this result:

[code]10
13A200
4033328E
24
DIY

12
13A200
403333B8
2A
phoenix
[/code]

I’m puzzled because everything seem to be ok but I just can’t get any connection. The old “diy transmitter xbee.bas” program works fine though.

If you have any hint about how I can debug this I would be pleased.
Thanks.

Well I hopefully will finish the manual input in the next day or so. Again Not sure why it would not see it, since the other XBEE sees them.

Kurt

P.S. - I am glad that the you can still use the older version to continue your stuff.

Ok, manual input would be a good option. Are you thinking of having the option to make a list manualy?

One thing I forgot to mention is that when I did the ATND from the third XBee the DIY XBee didn’t respond when the BAP was powered and running the DIY code.

Yeah, me too. :wink:

OK that is a good hint. One thing that is not obvious is that when you set the “MY” of the XBEE in the DIY remote, it is more or less ignored, At program startup it reads the desired value from the EEPROM of the BAP and stores it in the XBEE but does not do a write to permanently store it in the XBees permanent storage. So if you page through the pages of data on the remote and get to the my page, what does it say? Probably the current my is: 0.
Then my guess is that your third one plugged into your PC is also zero, so they don’t like each other.

So things to try:

  1. Unplug the one from the PC. and/or change the one on the PC to a different MY value.

  2. Try using the MY input on the remote to change the value to your value, like: 24

Yes, I am putting code in that when you do the manual input, it will add it to the list. It will try to do a query to the other side to see if it can get the serial number and the NI information, if it can not get the information it will add the item to the list with some name like: _unknown_2A assuming the number you entered was 2A. Note, without this code you should still be able to enter the 2A and hit the enter key to save it. It won’t add it to some list you can scroll, but it should still set up communications to talk to the appropriate DL…

Kurt

Hi Kurt,

The third XBee (USB-PC-> X-CTU) did have the same MY=10 as the DIY XBee, changed the MY on the third XBee. So now the ATND command worked fine (from X-CTU terminal) when the DIY was powered completely. Thanks for your hint about that.

But still I have the same problem when doing the A-cmd (ATND from the DIY). I can clearly see that the green led on all XBee modules go green when sending out the (A) ATND command from the DIY but no units are found on the list though. So the bug must be somewhere after the ATND has been sent.

Not sure:

I believe I have the adding items by entering their number in the one screen be able to add items to the list that is saved. There is a new set of messages that were defined. One from the transmitter to the robot you type the number in for, that assuming it has been rebuilt with the new support file, will do queries of their SN (SH, SL) and their node identifier and then package these up and send a packet back to the remote. If the remote does not receive the response it will put in a dummy title _unknown_XX

Still testing put so far I was able to enter my test board. Note at times I have to hit the “A” button a couple of times as it may time out. If you are still having problems we should check if I am timing out or if I am getting the ending saying the command has completed.

Thanks for the update Kurt.

With the new code I did get some unknown_xx. I was able to set the DL, so know I’ve a list of two unknown (unknown_22 and unknown_12). I’m also able to select one of them (*). This part seem to work ok.

But I still can’t get any connection to the robot when I’ve selected the correct DL. At the beginning the robot beeps when using the up and down cmd buttons and the green light on the robot-XBee are on until after a while (a timeout?) it goes off and no beeping are heard when using the up/down keys. So there seem to be some sort of connection at the beginning. But I can’t start the hex by hitting the “0” button.

I don’t know whats wrong, but I feel there is something different in the communication part between the old “diy transmitter xbee.bas” and the new diy project since the old version work very fine.

Me neither. Have you rebuilt your HEX program with the latest support files? If not try that and see if that helps.

If not maybe you should send me your copy of the file and I can try to see what is happening. Probably some timeout and not resending the NEW only mode or the like.

Kurt

Yes, I’ve rebuilt the hex program with the latest support file every time.

Just to be sure, I’m attaching the files I’m using.
To Kurt.zip (234 KB)

Well I only rebuilt your phoenix and reloaded it on my CHR-3 and so far it appears to be working??? It probably does not walk overly good as my legs and stuff are not the same, but it walks/body moves/translates.etc.

I have not rebuilt your transmitter program yet as my file compare program says they are the same. Strange :confused:

So lets back up double check things. If you go to your DIY remote and hit the page up/down buttons and you get to the page that says:
Current My:

What is yours set to. Currenly mine is set to 0099. Make sure this does not conflict with something else. (My guess of the most likely culprit…)

In the page that says current DL: It should alternate with showing you the current DL and what it thinks is the name for it. For my hex it shows: 31 and then Kurts CHR hex. What is your set to ? My guess from your earlier list it should be showing 12

What is your test USB one set to ? Have you tried it with it turned off? You might try running the test program on the CHR-3 to see what packets and other information it is receiving:

Also after you set the Destination, I assume you paged back to one of the two main pages (the one that shows all 6 values, or the one that may start off blank, but only shows the values that change and the messages that come from the robot…)

For example on my test board it starts off with:

[code]Init Timer

******** XBee Test Program ********
MY: 30
SH/L: 13A200 402C4240
Dest: 0 99
NI: Test Board
Ver: 1084
Ready: 99
Send DP:81FFFF00:[/code]
It then continues with packet information going back and forth. Most of the information is probably obvious. The Ready: 99 says that the transmitter is ready and using 99 as its my, which will then be set in DL. The next thing it sends is the DP: 81FFFFF00, which is the packet that tells the transmitter that we only want to know about new data.

Will keep trying to figure out what is happening.

Kurt

Mine MY is set to 0010. I don’t think its in any conflict.

Mine DL show 0012.

My test USB is set to MY=22. The test USB XBee was turned off when testing.

I got this result from the test program:

******** XBee Test Program ******** MY: 12 SH/L: 13A200 403333B8 Dest: 0 10 NI: phoenix Ver: 1084 Ready: 10 Send DP:81FFFF00: Send DP:80010100: Send DP:80020200:

The Send DP values keep going until the DP are:

Send DP:80292900: Ready: 10 Send DP:81FFFF00:
After a while it seem to stop.

Does this help? I’m back later today…

I started to play around with this a little more this morning and I have good news/bad news.

First the maybe good or maybe bad, is that I stil can not reproduce the problem you are having even though I am using your phoenix code and I my source compare program does not see any differences in the transmitter code. :confused:

I tried running the VB code that I put in the zip file with Beta2 of VB 2010 express and it is working. I may do a few mods to make it a little more robust. With the current phoenix code and this VB I was able to put the phoenix into SSC-32 emulator mode. It is clunky, but you can click on the button, then you can bring up LynxTerm and connect and type for example VER and it is returned, you can click on All=1500 button and all of the servos should move… Then to exit this mode you can type $$ which exits this mode. You can then disconnect the comm port and go back to VB… Clunky but it shows potential. May now hack up excel to see if I can integrate it into here…

Now the not so good news. While I was playing around I started to smell THAT smell. I think I have 1 maybe 2 servos that fried. I think I have one spare so I will need to work on that. :angry: Maybe the CHR-3 does not like walking with phoenix configuration…

Kurt

Update: Your results look as I would have expected, so now I need to figure out why you are probably timing out…