Skip to content

Accessing Battery Values

Jeffrey Shen edited this page Jul 24, 2017 · 2 revisions

This library provides the ability to access the voltages of the main battery and that of the power expander battery (Useful information to adjust motor voltages and display on the LCD).

Setup

There is no additional setup required to track the main battery's voltage. If you want to monitor a secondary battery's voltage write #define USE_SECOND_BATTERY 1 in config.c. You also need to plug the status port of the power expander into a digital port on the cortex. In RobotC, define a potentiometer called "PWR" that is mapped to the port you plugged the power expander in.

Usage

To access the main battery's voltage call int getMainBatteryVoltage() which returns the voltage in milliVolts.
To access the secondary battery's voltage (if defined), call int getSecondBatteryVoltage() which returns the voltage in millivolts.