Shop OBEX P1 Docs P2 Docs Learn Events
Trouble using 3 xbee units — Parallax Forums

Trouble using 3 xbee units

si8si8 Posts: 20
edited 2012-03-02 08:01 in BASIC Stamp
I am trying to get 2 bits of info sent from separate xbees to a central xbee but the info keeps getting messed up and i dont know why. Here is a bit of cde from the receiving unit:

recievetemp2:
PAUSE 10
SEROUT Tx,Baud,["+++"]
PAUSE 100
SEROUT Tx,Baud,["ATDL 2",CR]
PAUSE 10
SEROUT Tx,Baud,["ATCN",CR]
PAUSE 100
SERIN Rx\RTS,Baud,[DEC tC2]
PAUSE 1000
RETURN


recievetemp3:
PAUSE 10
SEROUT Tx,Baud,["+++"]
PAUSE 100
SEROUT Tx,Baud,["ATDL 3",CR]
PAUSE 10
SEROUT Tx,Baud,["ATCN",CR]
PAUSE 100
SERIN Rx\RTS,Baud,[DEC tC3]
PAUSE 1000
RETURN

Thank you for your help

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-02-28 08:37
    Welcome to the forums!

    The ATDL command sets the destination for a transmission. Yet in those subroutines it seems with the SERIN like you are expecting it to set something about the reception.

    Are these series 1 XBees? Each of the 3 remote XBees will set their DL to match the MY address of the central XB.

    I don't see the whole program, but the default requires 2 full seconds of guard time around the +++ to get into command mode.
  • si8si8 Posts: 20
    edited 2012-02-28 08:48
    Thank you,

    This is only the subroutines from the receiving unit. Would you like to see more of it?

    Yes i am using series 1 xbees. I have since realised i was using "0" as the address of the receiving unit which was not working, But now I there seems to be no comunication at all between the devices. I believe i have the DL and MY matching
  • FranklinFranklin Posts: 4,747
    edited 2012-02-28 08:52
    I would go back to a simple program that talks to one xbee and get that working. There is sample code available and a tutorial manual also. Where they are I could not tell you as I have to search for them every time I need to look at them.
  • si8si8 Posts: 20
    edited 2012-02-28 09:05
    Haha,
    I am sitting here with the "getting started with XBee RF modules" book!
  • si8si8 Posts: 20
    edited 2012-02-28 09:56
    I still cant them to communicate properly using manual polling.
    Here is a copy of what i got so far...

    Reciever:
    Main:
    DEBUG CLS,"config"
    PAUSE 1000
    SEROUT Tx, Baud, ["+++"]
    PAUSE 2000
    SEROUT Tx, Baud, ["ATD6 1",CR]
    PAUSE 1000
    SEROUT Tx, Baud, ["ATGT 3, MY 11",CR]
    PAUSE 1000
    SEROUT Tx, Baud, ["ATCN",CR]
    PAUSE 1000
    DEBUG CLS
    DO
      GOSUB SHT_Measure_Temp
     ' GOSUB recievetemp2
      PAUSE 500
      GOSUB recievetemp3
     'SERIN Rx\RTS,Baud,[DEC tC3]
      DEBUG CRSRXY, 0, 3,
      '"soT...... ", DEC soT, CR,
      "Temp terminal 3 ", DEC (tC3/10), ".", DEC1 tC3, DegSym, " ", CR ,
      "Temp terminal 2 ", DEC (tC2/10), ".", DEC1 tC2, DegSym, " ", CR ,
      "temp at main terminal ", DEC (tC1/10), ".", DEC1 tC1, DegSym, " ", CR
      '"tF....... ", DEC (tF / 10), ".", DEC1 tF, DegSym, " "
    
    
    
    
    
    
      GOSUB SHT_Measure_Humidity
      'DEBUG CRSRXY, 0, 7,
      '"soRH..... ", DEC soRH, CR,
      SEROUT Tx, Baud, [DEC rhTrue,CR]
    
    
    
    
      '"rhLin.... ", DEC (rhLin / 10), ".", DEC1 rhLin, "% ", CR,
      '"rhTrue... ", DEC (rhTrue / 10), ".", DEC1 rhTrue, "% "
    
    
    LOOP
    
    
    recievetemp2:
      PAUSE 10
      SEROUT Tx,Baud,["+++"]
      PAUSE 2000
      SEROUT Tx,Baud,["ATDL 2",CR]
      PAUSE 100
      SEROUT Tx,Baud,["ATCN",CR]
      PAUSE 100
      SERIN Rx\RTS,Baud,[DEC tC2]
      PAUSE 1000
      SEROUT Tx,Baud,[CR,DEC 1,CR]
      GOSUB emptybuffer
    RETURN
    
    
    recievetemp3:
      PAUSE 10
      SEROUT Tx,Baud,["+++"]
      PAUSE 2000
      SEROUT Tx,Baud,["ATDL A",CR]
      PAUSE 1000
      SEROUT Tx,Baud,["ATCN",CR]
      PAUSE 1000
      SERIN Rx,Baud,[DEC tC3]
      PAUSE 1000
      'SEROUT Tx,Baud,[CR,DEC 1,CR]
      'GOSUB emptybuffer
    RETURN
    
    Initialize:
    GOSUB SHT_Connection_Reset ' reset device connection
    PAUSE 250 ' let DEBUG window open
    PAUSE 1000
    SEROUT Tx, Baud,["+++"]
    PAUSE 2000
    SEROUT Tx,Baud,["ATD6 1",CR]
    PAUSE 1000
    SEROUT Tx,Baud,["ATMY A",CR]
    PAUSE 1000
    SEROUT tx,Baud,["ATDL 11,CN",CR]
    PAUSE 1000
    ' -------------------------------------------------------------------------
    ' Program Code
    ' -------------------------------------------------------------------------
    Main:
    
    
    DO
    
    
      GOSUB SHT_Measure_Temp
      'GOSUB SHT_Measure_Humidity
      GOSUB sendtemp
      PAUSE 1000
    LOOP
    
    
    
    
    
    
    
    
    sendtemp:
      SEROUT Tx, Baud, [DEC tC3,CR]
      PAUSE 100
    
    
    RETURN
    
  • FalconFalcon Posts: 191
    edited 2012-02-28 10:44
    si8,
    Can you post a sketch of your circuit and an overview of your project? And please post the full code when you get this resolved.

    I just bought a few XBee Series 1 units and plan to monitor several locations for temp and some discrete switch closures. I've planned to use LM34's but it looks like you're using the Sensiron units. Did you need increased accuracy, or did you have a requirement for humidity data?

    falcon
  • si8si8 Posts: 20
    edited 2012-02-28 14:09
    Falcon,
    I have left my stuff in the lab but will post some more if you want.

    I am using the Sensirion due to their 2 in 1 nature, which is exactly what I need. All the coding for it is available here http://emesystems.com/BS2index.htm, thanks to Tracy Allen.

    Im still having trouble getting 3 XBees working together...
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2012-02-28 16:12
    The receiveTemp2 and receiveTemp3 routines are overkill. The receiver does not have to be configured to receive from the remotes. It can receive from any remote that sends to its MY address, which you have apparently set as 11 to match on both ends.
    [FONT=courier new]'[s]GOSUB recievetemp3[/s]  [COLOR=#000000]
    SERIN Rx\RTS,Baud,[DEC tC3][/COLOR][COLOR=#020FC0] ' -- you had it this way; it should work [/COLOR][/FONT]
    

    Be sure the RTS handshaking is set up correctly in hardware, because you have it enabled in the program firmware, also watch out for confusion between the rx and tx lines. There may be blinking lights on the XBee carrier boards that indicate when data is going in or out, and those can help with troubleshooting. It really is best to start off without the sensor data, and just try to send single ascii characters until you are sure of the basic connections.

    On the transmitting end, you may eventually add a preamble to each transmission from the remotes, something like this:
    [FONT=courier new]  SEROUT Tx, Baud, [HEX myMY,",",DEC tC3,CR][/FONT]
    
    The variable myMY is the MY address of the remote transmitter. The receiver can then WAIT for a transmission from that particular remote, here the one with MY=$A.
    [FONT=courier new][COLOR=#000000]SERIN Rx\RTS,Baud,timeout,target,[WAIT($A), DEC tC3][/COLOR][/FONT][FONT=arial][COLOR=#000000]
    [/COLOR][/FONT]
    

    It can get a lot more involved than that, but maybe that is what you were trying to do with the
    receiveTemp3 routine. There are many ways to skin a... XBee.



  • si8si8 Posts: 20
    edited 2012-03-02 08:01
    Thank you Tracy, you helped allot!
Sign In or Register to comment.