Technical Info
Users Forum
Main
Quick Start
The PIC-BEE module creates a simple interface between the Maxstream/Digi XBee module and real world data acquisition and control. At the center of the design is a Microchip PIC processor that communicates with the XBee and transfers data between its digital and analog interfaces over the Zigbee RF link.

The simple nature of using any terminal program to communicate with the XBee makes this product very easy to use. The ASCII commands can be sent from any embedded or stand alone computing system. The baud rate is set for 9600/1/N as is the default mode for the XBee when received from the factory. Although you can change the baud rate in the XBee, it does not change for the PICBEE, so that is essentially a fixed rate. However for most data transmissions, that speed is sufficient.

When the module is first powered up, it will read several registers from the XBee module, and transmit them over the Zigbee RF link. If a host is setup with the proper settings to communicate with the module, the following data will be displayed which provides the current addressing information.


.PIC-BEE V1.0
[MY=0] [ID=3332] [DH=0] [DL=0]


Note: The values shown are only representative of typical values, and actual may be different depending on how the XBee module is configured.



CONFIGURATION

There are two jumper blocks on the assembly that allow a XBee reset, and a forced DL address. In the event the XBee module will not respond due to mis-configuration, or an unknown configuration, placing a shorting block across the 'RESET' block will send the factory reset command to the Xbee and reset all the parameters. Shorting the CFG block, will temporarily force the DL value to be a value of 0xFFFF and a MY=0x00. This provides a communications link that can be reserved to be a configuration address only within a system, and allows the host to send configuration commands to the XBee. See the command instruction below for further information.

COMMANDS

All commands to the module are prefaced with a "%" character, and terminated with a carriage return (hex 0x0D) The following is a list of valid commands:
  • A : control analog or digital settings of PortA
  • B : control the direction of PortB
  • C : Xbee command mode
  • G : Gets the values on PortA and PortB
  • H : timer module hours setting
  • L : LED control
  • M : timer module minutes setting     
  • P : puts a value on portB, for those set to output
  • Q : query mode - polling (1) or Periodic reports(0) * default is 0
  • S : timer module seconds setting
  • V : reports back software version
  • Z:  controls sleep mode 1 of the XBee, in conjunction with Query mode

%A    PortA on the micro controller can either be a digital or analog input (it cannot be an output port). Sending the command by itself will return a hex value that indicates the current settings for Port A of the micro controller, with a ‘1  indicates a digital while a ‘0  represents an analog input. The setting is stored in non-volatile memory such that on power cycles, it will retain its settings. Sending a ASCII value with the command will force a setting change for it. The valid range is 0xA thru 0xF per the following table (anything below 9 defaults to A)


    Hex Port       Bit Assign
    Value         4  3  2  1   0
    0xA           A  A  A  A  A
    0xB           D  A  A  A  A
    0xC           D  D  A  A  A
    0xD           D  D  D  A  A
    0xE           D  D  D  D  A
    0xF           D  D  D  D  D


For example, sending a %AC is equivalent of "set PORTA inputs to a '11000', where a '0' makes the bit an analog input, and a '1' makes it an digital input. Note that the range for then inputs are limited from the reference ground to the board voltage of 3.3V (typical) on both analog and digital. In technical terms, this is setting the ADCON1 register in the micro controller.


%B   The micro controller has a 8 bit digital I/O port, called "PortB". Sending this command by itself, will return a value that indicates if the particular input on the port is an input (1) or an output (0), represented by two byte hex value. Sending a hex value with the command will force a setting change for it. The setting is stored in non-volatile memory such that on power cycles, it will retain its settings. Valid range for setting is 00-FF

For example, sending the command "%BC3  is equivalent of saying "set PORTB I/O equal to a '10110011', where a '0' makes the bit an output, and a '1' makes it an input (this is shown from B7:B0). In technical terms, this is setting the value for TRISB


%P   Puts a value to PortB. This will allow those pins that are set as output to be turned on and off.

For example "%P12  would be interpreted as a binary string of 00010010 where if a bit was previously set for an output, a value of 1 would place a logic high on the terminal block and a 0 would place a logic low on the terminal block. If a port bit was set for an input, this would not affect that signal.

Please note that the digital range is limited to the board voltage of reference ground to 3.3VDC (typical) with a maximum current of 25mA per pin. It is typically suggested that outputs are current sinking, rather than sourcing. Both reference ground and power are available on the terminal blocks for user interfacing.


%G   Get the input status for both port A and port B. This will read the A and B ports, and return a string of values for each port on separate lines. For those locations on port B that are outputs, a zero value will return. The format of the string is as follows:

    B=00[00000000]

If Port A is set for digital, the output would be formatted as

    A=[00000]

If Port A is set for both digital and analog, the output would be formatted as

    A=[00] 2:A9C0|1:6080|0:FFC0|

If Port A is set for all analog, the output would be formatted as

    A=4:FF80|3:B000|2:5BC0|1:3740|0:FFC0|

Note that Port A analog values are always returned in a two bytes since the A/D is 10 bits in value. The actual value is represented by [9/8/7/6/5/4/3/2] [1/0/-/-/-/-/-/-]


%C   XBee commands. This may be used to query the XBee module using the XBee AT command set, or set a new value in the device. Setting a new value is always followed by a write command to the module to store the new value in non-volatile memory.

For example, sending a %CATID (return) would act as a query only, and return the PAN ID value. However sending a %CATID5 (return) would set the PAN ID to a value of 5 and store it to memory.

Refer to the Xbee users documentation for a full listings of available commands.


%L This command controls the LED on the module to be turned on, off, beacon once per minute or indicate the module is being accessed.

%L0 turns off the LED
%L1 turns on the LED where it remains on till another command affects it
%L2 beacons the LED so once per minute it will turn on for approximately one second.
%L3 turns on the LED if the module is be addressed and is activated via the serial link.  This is useful to determine if the module is seeing activity


%Q  There are two query modes of operation, either a periodic reading of the ports, that occurs based on the H:M:S timer settings or wake on request (polling).

When Q is set to 1, polling is enabled. This will put the processor to sleep, and wakes when any serial character is received. Typically a carriage return is sent to wake up the processor, because the XBee will not pass data to the processor that is not addressed to it. When the processor is woken from sleep, it discards the first character in the buffer, since that was the wake command. The Xbee module is not put to sleep in this mode. The processor will go back to sleep based on the H:M:S timer settings.

When Q is set to 0, the processor will wait for the time period set in the H:M:S timer settings, take a reading of the ports, transmit and reset the timer. The Xbee module will not be put asleep in this mode. Using the command mode to place it asleep can be enabled, and the wake is asserted by the processor when it is ready to transmit.

%Z  Setting to a 0 (default) disables the XBee sleep mode 1.  Setting to a 1, allows the XBee to be placed in hibernate mode (lowest power) if, and only if, the Query mode is set to 0.  Query mode 1 is remote polling, so the XBee must always be awake for this to work.  If sleep is enabled, after each transmission there is a 5 second delay to wait for data to reply, such as taking it out of the current mode.  If no data arrives, the XBee goes back to sleep until the timer has completed and the data is transmitted again.

If Query mode is set to 1, sleep is not allowed and will always return a 0 (zero)


%V Reports the firmware version number.


%H Hour timer value. The processor includes a timer that is represented in the format hours:minuts:seconds and is used for either a timer for sending data on a periodic basis or how long the processor stays awake after receiving a serial command, depending on its mode (see command Q). The value is stored in non-volatile memory, and is has a range of 00 - 59, and always must be two digits. For example, 5 hours is represented by ‘05’.  Default value is 0 (zero)


%M Minutes timer value. The processor includes a timer that is represented in the format hours:minuts:seconds and is used for either a timer for sending data on a periodic basis or how long the processor stays awake after receiving a serial command, depending on its mode (see command Q). The value is stored in non-volatile memory, and is has a range of 00 - 59, and always must be two digits. For example, 5 hours is represented by ‘05’.  Default value is 1 (one).


%S Seconds timer value. The processor includes a timer that is represented in the format hours:minuts:seconds and is used for either a timer for sending data on a periodic basis or how long the processor stays awake after receiving a serial command, depending on its mode (see command Q). The value is stored in non-volatile memory, and is has a range of 00 - 59, and always must be two digits. For example, 5 hours is represented by ‘05’.  Default value is 0 (zero).