Enable Digital Output Pin and Toggle High/Low in Xbee

In this post we will remotely configure the I/O Pin of the XBee end device as digital output and toggle it by making it high/low. XBee supports many pins that can be configured as  digital output pins. The end device I/O pin we are considering here is DIO3(pin no 17). A Led is connected across the pin and ground, which should glow when pin is made high and vice versa.

Hardware/Software environment settings

  • One XBee node configured as Zigbee Coordinator API (Firmware version: 21A7)
  • One XBee node configured as Zigbee End Device API(Firmware version: 29A7)
  • Digi X-CTU application software (Version: 5.2.8.6)

The approach followed here, to configure remote end device from coordinator is by passing AT commands in API mode. While working with API firmware version, we need to check Enable API in the PC Settings tab of the X-CTU.

Enable API

In XBee we have the API frame type 0x17, called Remote AT Command Request frame, available to ease our job in setting the pin as digital output.

API Frame to Enable a DIO Pin as Digital Output High

7E 00 10 17 01 00 13 A2 00 40 7C 0F D3
Delimiter Length of payload Frame Type Frame ID 64 bit address of destination
FF FE 02 44 33 05 19
16 bit network address of destination Command options AT command Command parameter Checksum

Length of payload: Calculated by the number bytes between Frame Type and Command parameter. In the above, there are 16 bytes(HEX equivalent 10) between Frame Type and Command parameter.
Frame Type: 0x17 for Remote AT Command Request frame.
Frame ID: 0x01 for ACK.
64 bit address of the destination: Assigned by the manufacturer.
16 bit address of the destination: Assigned by the coordinator while forming network.
Command Options: 0x02 for update.
AT Command: D3(0x4433).
Command Parameters: 0x05 for digital output high.
Checksum: Calculated by adding all bytes after length(exclude delimiter and length) and then keeping only the lowest 8 bits of the result. Next subtract the result from 0xFF to obtain checksum.

API Frame to Enable a DIO Pin as Digital Output Low

7E 00 10 17 01 00 13 A2 00 40 7C 0F D3
Delimiter Length of payload Frame Type Frame ID 64 bit address of destination
FF FE 02 44 33 04 1A
16 bit network address of destination Command options AT command Command parameter Checksum

Length of payload: Calculated by the number bytes between Frame Type and Command parameter. In the above, there are 16 bytes(HEX equivalent 10) between Frame Type and Command parameter.
Frame Type: 0x17 for Remote AT Command Request frame.

Frame ID: 0x01 for ACK.
64 bit address of the destination: Assigned by the manufacturer.
16 bit address of the destination: Assigned by the coordinator while forming network.
Command Options: 0x02 for update.
AT Command: D3(0x4433).
Command Parameters: 0x04 for digital output low.
Checksum: Calculated by adding all bytes after length(exclude delimiter and length) and then keeping only the lowest 8 bits of the result. Next subtract the result from 0xFF to obtain checksum.

As you have seen above, separate API frames have to be written to change the state of the output line. Pass the above API frames one after the other to toggle the digital output from high/low as seen in the image below. To verify, check whether the LED(connected across the pin and gnd) is turning on/off when the Digital output pin is toggled high/low.

In X-CTU, go to Terminal Tab and select Assemble Packet. This will pop up send packet window. Select display as HEX. Enter the API frame that you would like to transfer to the remote end device here and click on send data. The API frame type is 0x17 i.e, Remote AT Command Request frame.

DO Highlow

The text in blue is the API frame passed out from the coordinator to the remote end device. The text in red is the response received from the remote end device by the coordinator. The API response frame type is 0x97, called Remote Command Response.

7E 00 0F 97 01 00 13 A2 00 40 7C 0F D3
Delimiter Length of payload Frame Type Frame ID 64 bit address of source
65 6C 44 33 00 CC
16 bit network address of source AT command Command status Checksum

Length of payload: Calculated by the number bytes between Frame Type and Command parameter. In the above, there are 15 bytes(HEX equivalent 0x0F) between Frame Type and Command status.
Frame Type: 0x97 for Remote Command Response frame.
Frame ID: 0x01 .
64 bit address of the source: Address of the remote radio returning this response.
16 bit address of the source: Network address of the remote radio.
AT Command: D3(0x4433).
Command Status: 0x0o for OK.
Checksum: Calculated by adding all bytes after length(exclude delimiter and length) and then keeping only the lowest 8 bits of the result. Next subtract the result from 0xFF to obtain checksum.

 

Leave a Reply