2 Problems with my xbee / servo project

Denzel

Senior Member
first of all before I say anything is do you connect a 12v sla battery in series (+ to -) or parallel (- to -) with the charger? :p

Right, my project.
I have an Xbee and picaxe 18 connect kit connected to my computer and another xbee/connect kit on my robotic project which receives signals and tells various picaxe chips to control...
4 servos (axe 031 servo driver) for robotic arm >>> 18x
2 motors for the wheels(tracks) >>> 08M
1 motor for the claw of robotic arm >>> 14M
a temp, gas and light sensor (light turns on/off 12v light) >>> same 14M as above.

My first problem is that the communication doesnt seem to get all the way from the computer to the "end of the line" picaxes 100% of the time.

I created a visual basic program that allows you to control everything on the project (forward, reverse, the claw etc etc) by talking to the xbee/connect kit.

I know the computer is sending to the xbee connected to it and I know the xbee on the robot is receiving information but something seems to be going wrong at around this stage when the xbee/picaxe connect tells the "end of the line" picaxes what to do.

When I tell it to go forward for example, about %40 of the time it will go forward and everythings smooth but the rest of the time nothing happens.
Could this be a timing issue?

Code:
'The xbee connected to the computer transmits the numbers 2 and 1 to tell the robot to go forward

forward:
b0 = 2
b1 = 1
pause 50
Serout 7, T2400, (b0,b1)
goto compc


'this is the xbee on the robot that recieves wirelessly and sorts out what needs to be controlled
SerIn 7, T2400,b0,b1
if b0 = 1 then arm
if b0 = 2 then wheels
if b0 = 3 then sensors
goto main

arm:
if b1 = 1 then acw1
if b1 = 2 then cw1
if b1 = 3 then acw2
if b1 = 4 then cw2
if b1 = 5 then acw3
if b1 = 6 then cw3
if b1 = 7 then acw4
if b1 = 8 then cw4
goto main

wheels:
if b1 = 1 then forward
if b1 = 2 then back
if b1 = 3 then left
if b1 = 4 then right
goto main

sensors:
if b1 = 1 then temp
if b1 = 2 then gas
if b1 = 3 then light
goto main


'in this case the xbee tells the "end of the line" 08m that it needs to move forward
forward:
b4 = 1
serout 2,n2400,("ABC",b4)
goto main


'this is the recieving snippet for the "end of the line" picaxe 08m that runs the wheels
serin 3, N2400,("ABC"),b0
if b0 = 1 then forward1
if b0 = 2 then backward1
if b0 = 3 then left1
if b0 = 4 then right1

-----------------------------------------------

My second problem is running all 4 servos off 4 aa batteries giving 6v and they seem to run dry in less than an hour??? the axe031 is designed to run 21 servos from a single 6v supply? any help on this?

Cheers
I know its a bit long winded bit its a big project for me and I just need to wrap it up.
 

Grogster

Senior Member
What is the distance between the transmitting and receiving Xbee's?
Are you using the standard Series 1 Xbee(3mW) or the Pro(100mW)

I don't use anything other then the pro, as 3mW is such a small power, it's range is severely limited...

Even the 100mW one can only give you around 20-30 meters through-walls. Performance is excellent if you roof-mount the modules so that they are essentially line-of-sight: 500 meters no problem.

Anyway, I would want to be hooking a laptop computer up to the receiving end of the Xbee link, to confirm that you are actually receiving the wanted data - this has to be confirmed, before anything else, as if the data received is not exactly what the Picaxe is expecting, then the Picaxe will simply ignore the data, and nothing will happen.

I would recommend you put a debug command into your code:

SerIn 7, T2400,b0,b1
debug b0
debug b1

if b0 = 1 then arm
if b0 = 2 then wheels
if b0 = 3 then sensors
goto main

This will allow you to see on the Picaxe terminal screen, what values are actually being received by the Picaxe - perhaps there are garbled characters...

To see exactly what the Xbee is receiving, you will need some sort of Xbee-PC interface and terminal software.

Also, I would be interested to see what happens, if you lower the Xbee baud rate to 1200.

I trust that you have actually programed the Xbee's for 2400 baud, as by default they are 9600, and if you send them 2400-baud data, it would come out garbled.

As to your servo problem, I would imagine that you would never be able to run 21 servo's on 6v battery power - they most likely are saying that to run 21 servo's, you need to provide 6v plug-pack power.
 
Last edited:

muckypups

Member
Denzel, how many batteries are you using on the robot itself ? By which I mean, are you powering the picaxe(s) from one supply and the servos from a separate supply ?
The xbee will pull 50mA doing nothing at all, and maybe 55mA when receiving, which can drain a battery quite quickly.
I'm just thinking that you may be seeing "brown-outs" as your demands on the battery increase.
Also, you seem to be using 2 project boards on the robot, are they separately powered ? How are you powering the 14m and 8m picaxes ? How much current do the motors need and can the 8m supply that ?
One thing I have found is that serin will hang the program if you are not receiving a signal, so that could be a problem between the receiving 18x and the 8m.
Got any photos ?
Also I see that the 8m and 14m need a diode between input3 and V+ for serin to work (page 142 manual 2).
A good test of whether the signal is reaching the robot is to program the onboard 18x to re-transmit whatever signal it receives back to the base station before it executes any other commands. That way you can see what it sees and go from there.

Alan
 
Last edited:

ciseco

Senior Member
4 aa's will give an axe and xbee (on their own) a (non sleeping) running time between 1/2 to a day, not mathmatical just experience. If you are running the whole thing off 4aa's I'm not surprised they dont last very long :)

Muckypups point of brownouts is probably your answer if they are off the same pack. Separate them if thats the case, then at least you'll know which bit it failing.

Try flipping it on it's back first so no real load on it, fully charged batteries and see if all is well. Then see if the problem gets worse after time, if so mucky is spot on.

If not I'd stick an led on each receiver to indicate "i've got a message" and watch your commands arrive (or not), then work backwards.

Miles
________
Sunbeam
 
Last edited:

Denzel

Senior Member
...

Thanks for all the info.

i am not using the xbee pro, just the normal one and for what I am doing at the moment the range is about 1 meter but have had it at 20m through about 5 walls working fine.

I considered the "browning out" theory as it seems to be the most likely cause but the communication breakdown is so random that its not just when the power is in high demand.
all three motors and the 12v led cluster bulb are run off a small 12v sla battery which has no problems with the demand and has lasted a week so far. the servos are run on their own 4*aa battery pack. I have two more 4.5v battery packs (3*aa) 1 running the servo driver logic and the xbee and the other running the 14m and the 08m.

As for making sure the correct data is getting to the receiving xbee, Its really annoying at the moment havinbg only one computer with a serial port. but I have tried the debugging and this is what I have received:

To control the wheels the xbee should receive in b0 = 2 to indicate its the wheels needing control and b1 = 1 or 2 or 3 or 4 depending on the direction (left, forward etc)

Every time the motors worked I was getting the correct data b0 = 2 b1 = 4 for example but everytime the motors didnt work the xbee would be receiving
b0 = 2 and b1 = 129 or 130 or 131 or 132.
So this seems to be the problem as the xbee is just ignoring it, im just not sure whats causing it.

And regarding the baudrates there at 2400 because the computer uses this baudrate in my program. which could be changed but i don't think its where the problem lies.
---------------------

As for the servos I think think if I stick to some rechargeable aa's for digital cameras i should be able to work with it. besides the axe031 can read the servo supply battery level so I could at least creat a fail safe.
 

ciseco

Senior Member
This'll help with a lack of serial ports

http://www.sparkfun.com/commerce/product_info.php?products_id=8687

http://www.dontronics-shop.com/990004-xbee-usb-to-serial-micro-converter.html

http://www.ciseco.co.uk/CI001.html

From experience 2400 usually works fine, sometimes higher rates need a tweak with calibfreq, but this would produce exactly what you are seeing. The newer 28x1's are fine, I had a batch of ones before and they needed tweaking to -4 to -5 for them to work reliably at 9600. Could also be noise introduced somewhere thats causing it.

You might have found the problem there already, I'd spend some time making sure what you send is actually what get's recieved. You could sertxd the bytes back to debug before any action is taken, I dont tend to use the debug command as it seems to have some strange side effects (I'm sure someone will be able to describe why)

Miles
________
Merkur Scorpio
 
Last edited:

Denzel

Senior Member
ah.

yes i dislike using debug for the same reason and always discard it out of a working program. some of these links are interesting especially the latter. I have on its way a usb to serial port convertor which I will use on the laptop with another cable and then ill be able to get a good insight to whats happening at both ends.
 

Denzel

Senior Member
...

I seem to have come to a conclusion.
I picture of my robot may have brought this to your attention quicker but anyhow.

it seems to me that the data recieved by the xbee goes 'loopy' when the motors are running. I thought this could be a result of "browning out" but there are 3 relays that control the motors via an L293D because it couldn't cope with the current.... and there are sitting directly on top of the xbee and I thought this might cause some electromagnetic interference??
so when I moved the relays it all started working fine.

Im very excited :)

Thanks for all the input and i'll keep you up to date with the progress im making :)
 

Attachments

Top