Shop OBEX P1 Docs P2 Docs Learn Events
Getting closer to using XBee with BS2 BUT ......... — Parallax Forums

Getting closer to using XBee with BS2 BUT .........

kenwtnkenwtn Posts: 250
edited 2008-06-17 15:48 in BASIC Stamp
·· Below is some sample code I came across to use the XBEE, I know this is only the receive part of the code but the question I have is there is another PIN I have to use CTS and I m not sure where that comes into play. Can anyone help me out?
·
' {$STAMP BS2}
' {$PBASIC 2.5}
' **************************************
' * Accept_byte.bs2··················· *
' * Illustrates accepting a Byte······ *
' * recieved as a character··········· *
' **************************************
myAddr··· CON $1··· ·' Node Address
DestAddr· CON $0···· ' Destination address
·
Baud····· CON 84···· ' Baud rate, 9600, 8-N-1, non-inverted, on BS2.
·
RX······· PIN 0····· ' Receive Pin
TX······· PIN 2····· ' Transmit Pin
RTS······ PIN 6····· ' Flow control Pin
·
RFin····· VAR BYTE
·
HIGH TX
·
DEBUG CLS, "Configuring XBee..."
PAUSE 2000······························ ' Guard time for command sequence
SEROUT TX,Baud,[noparse][[/noparse]"+++"]·················· ' Enter command mode
PAUSE 2000······························ ' Guard time for command sequence
SEROUT TX,Baud,[noparse][[/noparse]"ATNI BS Test Node",CR, ' Set description
·············· "ATMY ", HEX myAddr,CR,·· ' Set node address
·············· "ATDL ", HEX DestAddr,CR, ' Set destination node address
·············· "ATD6 1",CR,············· ' Use RTS for flow control
·············· "ATCN",CR]··············· ' Exit command mode
·
PAUSE 1000
DEBUG "Configuration Complete!",CR
DO······································ ' Accept and view a character
· SERIN RX\RTS,Baud,[noparse][[/noparse]RFin]
· DEBUG RFin
LOOP

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-16 22:44
    CTS is only needed if your program might try to send data faster than the receiving device (the xBee) can accept it. The CTS pin is specified in the SEROUT statement similar to the way RTS is specified in a SERIN statement. Read the manual chapter on the SEROUT statement.
  • kenwtnkenwtn Posts: 250
    edited 2008-06-16 22:47
    My problem must be else where then. It sounds like CTS is not required and the sample code I have for send does not use it. I will keep digging. Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-16 22:57
    Usually CTS is used to cause the external device to send to the Stamp. For example, the Parallax Memory Stick Datalogger requires that CTS be connected to ground if it's not controlled by the microprocessor (and made LOW when the Stamp is waiting for serial data).
  • kenwtnkenwtn Posts: 250
    edited 2008-06-16 22:59
    Thanks I will check into that. I sent MICROCONTROLLER a EMail and waiting for reply.
  • kenwtnkenwtn Posts: 250
    edited 2008-06-16 23:44
    There is only one other pin left and that is DTR does that need anything done with it?
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2008-06-17 00:43
    I saw you posted before on this same topic in a separate thread, but I don't recall the symptoms. I guess it is not working, and this stamp is not receiving any data. Is that right? Where is the data coming from that it is supposed to receive, the second xbee that you have? Have you had any luck connecting the receiving end to a PC running hyperterminal or X-CTU?

    Just to be sure of something, are these xBees the original series 1, or are they series 2? If they are series 2 they would have that or "znet" printed on the xbee module. Series 2 have different configuration codes, for example, ATMY is now read only. I was trying series 2 devices over the weekend and the differences really threw me for a while (and still not in the clear).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • FranklinFranklin Posts: 4,747
    edited 2008-06-17 00:45
    You might try your code without the rtx also have you tried the xbees on a pc to make sure they work?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • kenwtnkenwtn Posts: 250
    edited 2008-06-17 00:50
    I have series 2 I have never work with XBee before. Right now I m trying to get to BS2's to talk to each other. I got the sample code from a link someone provide me, but sounds like that is for series 1 units. I have attached what I have to this. If someone could help me with the connections to my microcontroller and some sample code would be GREAT
  • kenwtnkenwtn Posts: 250
    edited 2008-06-17 01:01
    Microcontroller where I bought those DTE boards said I should be able to just plug them into the serial port on the Board of Eduction and use them, but if the code I have is for the series 1 then that might be why that did not work. That would be the slickest way to go, but not sure if that is possible or not.
  • FranklinFranklin Posts: 4,747
    edited 2008-06-17 01:47
    So, exactly what is it you bought and can you post a link to the info on it?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2008-06-17 07:11
    If you do have "series 2" xbees, they are quite different from the original "series 1". http://www.digi.com/

    series 1 (xbee 802.15.4)

    is not inter-operable with

    series 2 (xbee znet 2.5)

    The fact that they partly kept the name the same and partly changed it does not help matters.

    Series 1 comes out of the box as a peer-to-peer device, and it it relatively easy to get one device talking to another by setting the MY and DL addresses as in the above code. I think that is really what you are looking for, initially, and that is what your example code is expecting. The best examples for the Stamp can be found at Selmaware. These devices can also form a network based on a coordinator by setting the a parameter (ATCE=1) in one of the devices in your network to make it the coordinator. The coordinator has certain additional powers and responsibilities, for example, it can hold onto data that is supposed to go from one end point device to another, until the target device is ready to receive it. That is important when setting up the end points for lowest power sleep modes. The coordinator normally operates at higher power and stays awake in order to do its thing. But it takes more planning to make the coordinator mode happen, compared with the default peer to peer mode.

    Series 2 come out of the box set up to operate in the mode with a coordinator in addition to routers and the end points. In series 2 this network can self-organize easily without much planning by the programmer (you and me) and the routers allow the network to be extended over a wider area and more end points. But to do that, series 2 gave up the simple peer to peer functionality of the series 1 devices, at least that is how I read it. Another issue is that in series 2 the end points and routers require different firmware than the coordinator. I think it is currently version 1.041 for the coordinator, and version 1.241 for the end points and routers. That is, a simple command will no longer do it within the one firmware. The firmware can be downloaded from the Digi/Maxstream site and flashed into the device using their X-CTU software and one of their XBIB development boards, or another board with the correct connections. There is other firmware, too, if you want to use an API interface (command + data frames) instead of a command mode (transparent data +++ modem like) interface. You see, it gets more complicated in order for the complicated to get simple. Something like that. rolleyes.gif

    My guess is that if you have series 2 devices, they both came programmed as end points and you do not have a coordinator device. The end points cannot talk to one another until you get a coordinator. Some commands function differently in series 2 versus series 1. Again, that is how I read it, and I'd like to hear from people who have more experience with either or both.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 6/17/2008 7:33:50 AM GMT
  • kenwtnkenwtn Posts: 250
    edited 2008-06-17 14:08
    I m currently working with Microcontroller where I bought the DTE Serial Boards, they say what I have should work. I will let you know as I find out more. Thanks for all the input you have given to me. I bought the XBee because Mike told me it was easy to use and best way to get two way comunication working between stamps, but I sure not having much luck with it.

    Post Edited (kenwtn) : 6/17/2008 2:18:15 PM GMT
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2008-06-17 15:48
    Let me emphasize again that the xbee that you bought is not necessarily the xbee that Mike recommended. That board from Microcontroller should work, as they say, but it's only purpose is to provide the correct power supply and level translation, and that applies to both the series 1 and the series 2. The differences between the series are not very well explained or understood, in my opinion, unless you really dig into it, and the series 2 is relatively new. If you get ahold of a couple of series 1 devices, I am sure the code you have and the recommendation are right on target. To make it work with the Stamp, I am sure that Mike, and Martin at Selmaware, had to peruse the xbee documentation and do the pioneering work that makes it easy for those who want to plug and play. I'm interested to hear what you find out.

    If you do need to change the firmware on the xbee using the Microcontroller PCB, it looks like you'd need to add a connection through to DTR.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com

    Post Edited (Tracy Allen) : 6/17/2008 3:58:19 PM GMT
Sign In or Register to comment.