Getting closer to using XBee with BS2 BUT .........
kenwtn
Posts: 250
·· 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
·
' {$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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
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.
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
Post Edited (kenwtn) : 6/17/2008 2:18:15 PM GMT
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