In this post we'll show you how to use the Low Voltage Detection (LVD) feature of the Programmable XBee to print a message when a minimum voltage is reached on the module's power pins. This is useful in battery-powered applications to generate a warning when the batteries need to be replaced.
To test the Low Voltage Detection sample you need to install Codewarrior 10.2 (download from Digi) and Programmable XBee SDK from (download from Digi).
Once installed, open Codewarrior 10.2 and go to File -> New -> Programmable XBee Sample Project. In the new window that pops up, select the sample "Low-Voltage Detection Example". You will find it under "Miscellaneous" items.
Hardware Settings
In config.xml you will see the settings to configure the LVD interface.
Here's a screenshot of the config.xml file for the example. For this example, the LVD is configured to trigger an interrupt when voltage of Programmable XBee goes under 1.84V.
To test this sample you need to connect a variable power supply to the XBee module. To do this, you have to locate pin 1 of your THT module (or pin 2 in a SMT module) and connect the variable power supply to that pin. You also need to locate the VRef input pin on your XBee module (Pin 14 in THT module and pin 27 in SMT modules). In some modules, Vcc and VRef are bypassed, so be sure to isolate them.
Once you've set up the hardware, configure the power supply to 3.3V, connect it to the XBee module and open a serial terminal.
Build and Test the Example
Now, you should build and flash the LVD demo application into the Programmable XBee. After flashing the demo, check that you have the application header in the serial console-- that means the demo is running.
While it's running, reduce the voltage of your variable power supply to 1.8 V and check the terminal console of the XBee Module for the message: "Low Voltage detected! System halting"
After that, you must increase the power supply's voltage to >2.5 V to restart the example.
LVD API
The Programmable XBee SDK offers the following APIs to use the Low Voltage detection interface:
void lvd_irq_enable (bool_t enable);
Enables/Disables the Low-Voltage Detection mechanism. |
bool_t lvd_flag (void)
Polls the Low-Voltage Detection flag. Return 1 if Low-Voltage is detected. |
void lvd_clear_flag (void)
Clears the Low-Voltage Detection flag. |
void lvd_set_trigger (bool_t low)
Sets the voltage at which the LVD flag is set. set 1 for 1.85 V and 0 for 2.4 V. |