Did You Know?The XBee manual is available from digi.com. Go to. Click Support - Documentation. Scroll down the list and select Xbee / XBee-PRO 802.15.4 Modules.
Click Product Manual: XBee / XBee-PRO 802.15.4 RF Modules.The serial.xbee declaration is global since it is made before any functions. This is useful because it allows any function in the application to pass Xbee device nicknames in calls to simpletext functions like dprint and putChar.Any simpletext function with a textt.device parameter can be used with full-duplex serial peripherals like the XBee.
Prop Plug for Propeller and Basic Stamp (USB-to-Serial) The Prop Plug provides a USB-to-serial port connection for microcontroller programming and communication. This tiny device is capable of asynchronous communication at up to 3 M baud with both 3.3V and 5V devices such as the Propeller and BASIC Stamp.
For a complete list of simpletext functions, see DocumentsSimpleIDELearnSimple LibrariesText DeviceslibsimpletextDocumentation simpletext Library.html.The fdserialopen function is part of the fdserial library. For a full list of (half-duplex) serial functions, see DocumentsSimpleIDELearnSimple LibrariesText DeviceslibfdserialDocumentation fdserial Library.html.The fdserial library’s receive buffer is considered FIFO. That’s an abbreviation of first-in-first-out, meaning the oldest byte that was received is the first one to be returned by fdserialrxChar(xbee).The fdserialopen function’s mode parameters expects a value with binary 1s and 0s. The mode 0 in xbee = fdserialopen(9, 8, 0, 9600) is the most common one, but other variations include:. 0b0000 // Same as 0, true serial communication, nothing special. 0b0001 // Treat incoming signal as inverted (1 is 0, and 0 is 1).
0b0010 // Invert signal for outgoing messages. 0b0100 // Ignores echoes created by a circuit that copies the signal the propeller transmits to its receive lineYou can even set the multiple mode bits. For example, you could pass a mode of 0b0011 to invert both the transmit and receive signals. Try ThisYou might expect to see a function like xbcmd in the code below in an XBee library.
This function simplifies putting the XBee into command mode for configuration. In its default mode, the XBee radio broadcasts the serial data it receives for other xbees. When it is switched to command mode, it treats the serial data it receives as configuration data.
You can use this mode to set its network address, baud rate, and many other features.In the XBee Command Mode example (below), the main function sends to the XBee module to put it into command mode. So long as the XBee doesn’t receive anything else from the Propeller for a couple seconds, it switches to command mode and replies with OK. If the Propeller gets the OK message, it then sends ATBD to find out what baud rate the XBee is set to. According to the XBee manual from Digi, since it’s at 9600, the XBee will reply with 3. Last, but not least, it sends XBCN to exit command mode, and the XBee replies with OK. After exiting command mode, the XBee returns to its normal mode of radio broadcasting the serial messages it receives.
Set the COM port dropdown to your Activity Board. Open XBee UART Command Mode Example.side from.DocumentsSimpleIDELearnExamplesProtocols. Click Run with Terminal. Verify that the conversation with your XBee matches the one in the terminal capture above.
There is no such thing as an ATBc command. What do you think will happen if you change ATBD to ATBc in xbcmd('ATBDr', response, 10, 20).Does the reply make sense to you?
Try adding this code right below the xbcmd you just modified: if(!strcmp(“ERROR”, response)) print(“The XBee didn’t understand!”); Your TurnTo drive home the point that you can have multiple full-duplex serial connections, let’s update the Try This example so that it uses fdserial to communicate with SimpleIDE terminal, and another instance of fdserial running in another cog to communicate with the XBee. Here is a start on modifications to the code from Try This:We created another fdserial identifier named term, which is short for terminal. The simpletermclose function call shuts down the default half-duplex communication, which will cause print calls to stop working. But that’s fine because we can use full-duplex serial.Note the last command in this example was modified from print(“cmd = ”) to dprint(term, “cmd = ”). If you do that with all the print statements, it’ll work the same as before, but will be running a full-duplex serial connection (instead of half-duplex serial) under the hood.