Shop OBEX P1 Docs P2 Docs Learn Events
XBEE Communication Help — Parallax Forums

XBEE Communication Help

BKaneBKane Posts: 9
edited 2010-05-06 02:59 in BASIC Stamp
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

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-04-07 04:05
    It would help if you include the entire programs you are running on the stamps and how you have things wired and how you have the xbees configured. It would also help if you sent a start character with the transmission and waited for that character in your receive code. Also if you could include what you are receiving that would help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • BKaneBKane Posts: 9
    edited 2010-04-07 07:08
    Ok here is my Tx and Rx code.

    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.
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-04-07 10:59
    This isn't going to be helpful to your problem, but just a programming suggestion. You have X = 25 inside your DO loop on the transmitting side, which means that it runs over and over again unnecessarily. I'd put that statement before DO.

    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?
  • stamptrolstamptrol Posts: 1,731
    edited 2010-04-07 12:11
    Are you using an XBee adapter/interface board to account for the signal level difference between stamp and xbee?

    Did you configure the xbee and set the baudrate?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • BKaneBKane Posts: 9
    edited 2010-04-14 07:15
    Right now I'm just using 9V batteries for both Tx and Rx. I know that there is a voltage difference for the stamp and xbee so I have a 3.3V voltage regulator hooked up going into Vcc.
    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.
  • JDJD Posts: 570
    edited 2010-04-14 21:50
    BKane,

    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
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-04-14 22:57
    BKane said...
    Right now I'm just using 9V batteries for both Tx and Rx. I know that there is a voltage difference for the stamp and xbee so I have a 3.3V voltage regulator hooked up going into Vcc.
    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.
    This raises quite a few issues:

    - 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
  • JDJD Posts: 570
    edited 2010-04-14 23:49
    BKane,

    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
  • sumdawgysumdawgy Posts: 167
    edited 2010-04-15 04:14
    sylvie369 said..
    - 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.
    I've been geting my bs1 to respond to 3.3 fairly decently....
    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
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-04-15 09:14
    sumdawgy said...
    sylvie369 said..
    - 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.
    I've been geting my bs1 to respond to 3.3 fairly decently....
    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?···\__/·

    Hmm. Two things:

    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.
  • BKaneBKane Posts: 9
    edited 2010-04-19 23:33
    I have attached a picture of my setup to hopefully try to make things easier. I attached a picture of my transmitter. I have Vdd from the board going into my voltage regulator. From there I have the output of the voltage regulator going into Vcc. I have both the voltage regulator and adapter board/XBEE grounded into Vss. I have DIN going into pin 2 and DOUT going into pin 1.

    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.
    3072 x 2304 - 1M
  • WildatheartWildatheart Posts: 195
    edited 2010-04-20 00:59
    Review, copy and paste my two programs (rx & tx) listed under the "Xbee XCTU Range Test" forum. Do use flow control by connecting the flow control from RTSn of the 3/5 volt adapter board to a BS2 pin. Also, if you're using a 9 volt battery, make sure its a fresh one. Comment out all references to initializing and running the HB25 and "Motor subroutine. This should give you good results.
  • FranklinFranklin Posts: 4,747
    edited 2010-04-20 03:33
    From your picture it looks like you are connecting an input (3.3v) pin on the xbee to an output (5v) on the bs2. This can destroy the xbee if you're unlucky.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • BKaneBKane Posts: 9
    edited 2010-04-21 03:15
    I have 5V from the BS2 going into the 3.3 voltage regulator. 3.3V from there is going into the xbee
  • FranklinFranklin Posts: 4,747
    edited 2010-04-21 04:39
    On the data pins also?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sylvie369sylvie369 Posts: 1,622
    edited 2010-04-21 09:37
    I believe that he is using a 3.3V/5V level shifting board, under the XBee in the photo. I can't find the post that made me think that yesterday, but the pins he is using correspond to the ones for that board (the Parallax version), not to the bare XBee pins.

    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.
  • sumdawgysumdawgy Posts: 167
    edited 2010-05-06 02:59
    @sylvie369 I wanted to apolgize for not properly applying the i/o logic. I was just saying that the 3.3 triggers my stamp. But for THIS circuit to work properly the stamps 5 HAS to become 3.3 to the Xbee.....

    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
Sign In or Register to comment.