XBEE Communication Help
BKane
Posts: 9
I am doing a project with XBEE to XBEE communication. I am going from a BS2 to BS2p module, communicating only one way. I have been trying to do communication with basic code to start and I am receiving a repeating pattern of numbers at the output end. Can someone please help me out because I think this code should be right. Here is my code:
Tx:
HIGH TX
DO
X = 25
SEROUT TX,84, [noparse][[/noparse]X]
PAUSE 2500
LOOP
END
Rx:
HIGH RX
DO
SERIN RX,240, [noparse][[/noparse]X]
DEBUG DEC X
PAUSE 1000
LOOP
END
Tx:
HIGH TX
DO
X = 25
SEROUT TX,84, [noparse][[/noparse]X]
PAUSE 2500
LOOP
END
Rx:
HIGH RX
DO
SERIN RX,240, [noparse][[/noparse]X]
DEBUG DEC X
PAUSE 1000
LOOP
END
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Tx:
' {$STAMP BS2}
' {$PBASIC 2.5}
'***********************
' Simple_tx.bs2
' ***********************
RX PIN 2
TX PIN 1
X VAR Byte
HIGH TX
DO
X = 25
SEROUT TX,84, [noparse][[/noparse]X]
PAUSE 2500
LOOP
END
Rx:
' {$STAMP BS2p}
' {$PBASIC 2.5}
' ***************************
' simple_rx.bs2
' ***************************
RX PIN 2
TX PIN 1
X VAR Byte
HIGH RX
DO
SERIN RX,240, [noparse][[/noparse]X]
DEBUG DEC X
PAUSE 1000
LOOP
END
I am not using flow control. I just have the transmitting and receiving pins hooked up.
At the output I am receiving 02552550255255. It is not an exact repeating pattern but it consists of 0s and 255. And something weird about it is that when I put my hand near the transceiver the numbers seem to pop out in the debug window, and when I take my hand away it stops giving numbers. I know 25 is being sent out on the transmitting end, but I just don't know what's going on after that.
Also on the receiving end I'd add a space character to your DEBUG statement. You're looking for 25, and you're getting 255. It'll be a lot easier to see 25 in that field of 255s if there are spaces.
I don't see anything wrong with the code. Can you briefly describe the hardware setup/power supplies?
Did you configure the xbee and set the baudrate?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
On the Tx end: I just have DIN hooked up to pin 2 and DOUT hooked up to pin 1.
On the Rx end: I have DIN hooked up to pin 1 and DOUT hooked up to pin 2.
I did not do anything to configure the xbee. I didn't think there needed to be any configuring as I thought it is supposed to work right out of the box for my setup. And I have the baudrate inside of my SERIN and SEROUT so I don't think that is a problem.
I'm still not really getting anything. I don't know what the problem is.
Can you try another power source besides the 9V battery? The XBEE module is a power hog, and a 9V is not the best supply·for those types of applications.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
- First of all, for powering the XBee, you need a 3.3V source, meaning the regulator and the appropriate capacitors, per the datasheet for the regulator you're using. You also need a regulator that provides enough current for the XBee in transmit.
- The XBee's ground and the ground of the Stamp that's sending data to be transmitted by the XBee have to be connected together.
- You're using Stamp modules, which have 5V signals on their I/O pins. The XBee expects 3.3V signals on its DIN and DOUT pins. Some people say you can get away with 5V, I guess, but I wouldn't expect to. Have you looked at this?
http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/CategoryID/36/List/0/SortField/0/catpageindex/2/Level/a/ProductID/664/Default.aspx
You need a couple of these. If you're going to work with XBees, these are going to be really handy.
- I'm not sure it's literally true that XBees "work right out of the box". If I remember correctly, they're typically set with MY = 0 and DL = 1. That means every module thinks its name is 0, and every module tries to transmit to a module whose name is 1. You need to set one of your modules - the receiver - so that it has an MY = 1 (that is, so that it thinks its name is 1). You can read about this here:
http://selmaware.com/appbee/AppBee_Doc.PDF
particularly in the section beginning on page 13. Beginning on page 18 is a section with code examples showing how to set this up from inside your Basic Stamp program. Read this stuff and you'll find the scales fall from your eyes with respect to using XBees.
Post Edited (sylvie369) : 4/14/2010 11:03:16 PM GMT
Looking closer, I see that you have the Din going to the RX of the BASIC Stamp and Dout to the TX. The Dout of the XBEE module goes to the RX on the BASIC Stamp and Din to TX on the BASIC Stamp. So the output from the BASIC Stamp is going to the input of the XBEE module to be sent, and what the XBEE module receives outputs·on the Dout which is the receive pin of the BASIC Stamp module. Can you verify that both XBEE modules are connected like this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,
Joshua Donelson
www.parallax.com
The specs say 1.4 is logic threshold....but then, nuts & volts vol2 (predates the bs1-ic) says 1.5.·
·· Either way, 3.3 beats 1.5.
··All things being equal...It should follow that the amplification adapter should only be needed if,
· the operating Freq doesn't allow·sense circuit to saturate beyond threshold in a timely manner.
········································ ····· ············· ||
...All thing really are equal aren't they?···\__/·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Before you criticize someone, walk a mile in his shoes. That way if he gets angry, he'll be a mile away and barefoot. - unknown
First, the original poster isn't running his Stamp at 3.3V, and even if that's possible on a bare Stamp, I wouldn't assume it'd be okay for his entire setup. In light of the fact that he's already having issues, I wouldn't suggest that he change his Stamp supply to 3.3V. ALL of the Stamp modules say they need 5-12VDC or 5-15VDC.
Second, I hadn't thought of the XBee 3.3V/5V adapter board as an "amplification adapter", though I suppose you could think in that direction. I've thought of it as a way of bringing a 5V signal from a microprocessor DOWN to the 3.3V required by the XBee. I suppose both are true, but you need to be concerned with protecting the XBee as much as you need to be concerned with whether or not the XBee outputs will be read properly by Stamp I/O pins.
I'm a little confused about the DIN/DOUT pins. Right now I have DIN - pin 2 and DOUT - pin 1 on the Tx end. And on the Rx end I have DIN - pin 1 and DOUT - pin 2. I first had the pins matching on both ends but then I was told to have it switched to how I have it now. I only need to send information one way.
On the Rx end I have the same setup except for the switching of the DIN/DOUT pins as I just mentioned. I feel like this should be working but it's not and I have no idea why. I would greatly appreciate some assistance on this.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Can you confirm that you're using that board? That's part of what is confusing the people who are trying to help you. It's not clear that you understand that the data pins need to be connected at 3.3V, not just the power to the XBee.
Also I really do think that you should be using the capacitors for that 3.3V regulator, not just the bare regulator. It .would help if you also confirmed with a voltmeter that you're getting 3.3V to the appropriate pin of the XBee (and that its ground is the ground).
It would also help if you could confirm that you have set the MY and DL settings of the two XBees as I described above.
Not exactly sure how I lost that particular train of thought..but you're quite right.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Before you criticize someone, walk a mile in his shoes. That way if he gets angry, he'll be a mile away and barefoot. - unknown