Go Down

Topic: Programming an Xbee Please Help!! (Read 3668 times) previous topic - next topic

Railfan1588

Oct 24, 2011, 03:06 am Last Edit: Nov 16, 2011, 06:31 am by Railfan1588 Reason: 1
I'm am working on a project to wiressly control an HO scale locomotive.

To obtain my goal, I am starting out using two series one Xbee chips along with a serial controlled motor driver.  http://www.sparkfun.com/products/9571

One Xbee chip will be connected to an Arduino uno that will receive commmands from a computer.  The other chip will be placed on a flatcar.  Can I directly hook up the TX and RX ports on my Xbee to the motor driver chip?

The commands or the motor driver are fairly strait forward.  A '1' or '2' indicates motor , 'f' or 'r' indicateds direction, '0' - '9' is speed, and '/r', end of command.



If I initiated my first Xbee to receive data from the computer, how would i relay this data to the second chip.  I imagine I would want to use the "char getData command to read this data from my computer?

PaulS

Quote
Can I directly hook up the TX and RX ports on my Xbee to the motor driver chip?

Yes.

Quote
If I initiated my first Xbee to receive data from the computer

How would you do this? The XBee is a radio. Does your PC have a transmitter that the XBee is compatible with?

Most likely, what you mean is that you are sending data to the Arduino, via the serial port. Whatever arrives on the Arduino's serial port is also transmitted by the XBee.

Quote
I imagine I would want to use the "char getData command to read this data from my computer?

What getData command?

No, you don't have to do anything. Anything that arrives on the serial port will be seen by, and transmitted by, the XBee, without you having to do anything. You don't even need an Arduino on the PC end. Use one of these, instead: http://www.sparkfun.com/products/8687

The art of getting good answers lies in asking good questions.

Railfan1588

To add to this previous discussion, I have a serial motor driver board on a flatcar with the TX and RX pins of that board connected to the Din and Dout pins on the Arduino.  The TX pin is going to the Din pin on the Arduino.  The serial motor driver is running off of 12 volts DC.

The serial motor driver I am using is made by Sparkfun.  I have provided a link below.

http://www.sparkfun.com/products/9571

I am using the 5 v output port on the board to power my X bee.  I included two diodes in series to knock down the voltage to 3.3 volts  to power Xbee.

The Xbee version I am using is a Series 1 1MW chip.

My other Xbee is connected to an X-CTU program on my computer via an Xbee Explorer USB chip.  I am trying to send commands from X-CTU to control the serial motor driver.

Because the baud rate used to control the serial motor driver is set at 115200, I made sure to change the baud rate on each Xbee to 115200.  I also checked that they both had the same version of software uploaded.

Commands to Control a Motor:

'1'-Selects Motor 1
'f' or 'r'- selects forward or reverse direction
'1'-'9'-selects speed
'/r'-end of command

When I type these into the XCTU terminal window, I am not getting anything out of the motor driver.

I am obviously doing something wrong, please help.

PaulS

Quote
To add to this previous discussion, I have a serial motor driver board on a flatcar with the TX and RX pins of that board connected to the Din and Dout pins on the Arduino.

The UNO doesn't have any pin labeled Din or Dout. So, try again.

Quote
Because the baud rate used to control the serial motor driver is set at 115200, I made sure to change the baud rate on each Xbee to 115200.  I also checked that they both had the same version of software uploaded.

What else did you set? To what values? PAN ID? MY? DL?

Quote
I am using the 5 v output port on the board to power my X bee.  I included two diodes in series to knock down the voltage to 3.3 volts  to power Xbee.

You need more than one wire going to the XBee. What else is connected to it, and where?
The art of getting good answers lies in asking good questions.

PeterH

Is the Xbee on your railcar receiving the serial input correctly? How does that input get from the Xbee to the motor driver? I guess that there is a sketch on the Arduino reading from the Xbee and writing to the motor driver, but it isn't clear.

ryanlipski

#5
Nov 16, 2011, 03:30 pm Last Edit: Nov 16, 2011, 03:38 pm by ryanlipski Reason: 1
I believe that your setting for your Pan ID, etc... are not correct.  Here is a good tutorial to get them on the same settings:
More applicable:
http://www.faludi.com/classes/xbee1workshop/Horsie_Race-Series_1_XBee.pdf
Same concept:
http://www.ladyada.net/make/xbee/arduino.html .


Railfan1588


Quote
To add to this previous discussion, I have a serial motor driver board on a flatcar with the TX and RX pins of that board connected to the Din and Dout pins on the Arduino.

The UNO doesn't have any pin labeled Din or Dout. So, try again.

Sorry, I meant to say my serial motor driver is connected to the Dout and Din Pins of my Xbee.

Quote
Because the baud rate used to control the serial motor driver is set at 115200, I made sure to change the baud rate on each Xbee to 115200.  I also checked that they both had the same version of software uploaded.

What else did you set? To what values? PAN ID? MY? DL?

Xbee on Flat Car
Pan ID -3332
Channel - C
Baud Rate - 115200
Destination Address (High)- 0
Destinatin Address (Low) - 0
My Address- 0 (Only Receives Data)

Xbee on USB Chip
Pan ID-3332
Channel- C
Baud rate- 115200
Destination Address (High)-0
Destination Address (Low)-0
My Address-1

Quote
I am using the 5 v output port on the board to power my X bee.  I included two diodes in series to knock down the voltage to 3.3 volts  to power Xbee.

You need more than one wire going to the XBee. What else is connected to it, and where?


Have two wires connected to the Dout and Din pins.


Is the Xbee on your railcar receiving the serial input correctly? How does that input get from the Xbee to the motor driver? I guess that there is a sketch on the Arduino reading from the Xbee and writing to the motor driver, but it isn't clear.


As of right now, my two Xbees aren't communicating which I realized today,  Whenever I try the range test in XCTU, I cannot receive any data back from the other Xbee.  The Xbee Dout and DIN pins are directly connected to the RX and TX pins of the motor driver respectively.  There is no Arduino connected right now.  As of right now, Im trying to test this my sending data from the Terminal Screen of X-CTU.

I believe that your setting for your Pan ID, etc... are not correct.  Here is a good tutorial to get them on the same settings:
More applicable:
http://www.faludi.com/classes/xbee1workshop/Horsie_Race-Series_1_XBee.pdf
Same concept:
http://www.ladyada.net/make/xbee/arduino.html .




I agree, I believe my program may have something to deal with either my Pan ID or my serial addresses.

PaulS

Quote
Destinatin Address (Low) - 0
My Address- 0 (Only Receives Data)

The DL value 0 denotes the broadcast-to-all address. It is not a valid MY address.

Quote
Destination Address (Low)-0
My Address-1

So, this XBee is broadcast to all other XBees on the channel. If you want just two XBees to talk to each other, which is a requirement for the loopback test in X-CTU, MY on one XBee has to match DL on the other, and neither can be 0.
The art of getting good answers lies in asking good questions.

Railfan1588

#8
Nov 16, 2011, 11:43 pm Last Edit: Nov 17, 2011, 01:31 am by Railfan1588 Reason: 1
I am still having trouble.

The Xbee that is connected the USB chip and transmitting, I have my DH set to zero and my DL set to 1.

For the Xbee that is receiving, the MY address is set to 1
The DH is set zero, and DL is set to 1.
What am I missing?

I start the range test, and i keep getting the messag timeout waiting for data.

PaulS

It appears that you have DL set to 1 on both XBees.

MY is the ID for an XBee and DL is the ID of that XBee that it can talk to.

For one XBee, set My to 42 and DL to 14.
For the other XBee, set MY to 14 and DL to 42.

Only when DL on one XBee matches MY on the other can they talk.
The art of getting good answers lies in asking good questions.

Railfan1588

#10
Nov 17, 2011, 02:08 am Last Edit: Nov 17, 2011, 02:20 am by Railfan1588 Reason: 1
I followed your advice and set my Dl's and My's accordingly.  Im still having no success. 

Is it ok to set each DH to 0?

Railfan1588





[imghttp://i1215.photobucket.com/albums/cc505/Railfan4ever/IMG_0062.jpg]http://[/img]

[imghttp://i1215.photobucket.com/albums/cc505/Railfan4ever/IMG_0063.jpg][/img]

Here are some pictures on my project.

My one X-bee is connected to a break-out board, which is connected to the serial motor driver.

The other X-bee is connected to the USB board.

PaulS

You really need to get another USB Explorer. That way, you can test the communication between the XBees. As it is now, there is nothing on the receiver end that causes the received data to be echoed back, so you have no way of knowing whether they are even talking to each other.

Yes, both DH values can (and should) be 0.
The art of getting good answers lies in asking good questions.

Go Up