Reading Battery Voltage

The Vex controller does not have a built-in function to read the battery voltage. But you can wire the battery into one of the analog ports, using two resistors to reduce the maximum voltage from 7.5v to 5v.

https://vexforum.com/gallery/files/1/4/6/1/batteryvoltage.jpg

What code would be needed to transform this into the battery voltage, anything?

You would configure that I/O port for Analog input and then feed the “analog” value you get (gotten by reading/getting that port’s input value) into a little one line equation that would give you decent estimation of the voltage the battery is able to sustain across all the loads attached to it at the moment the analog value was sampled/read.

I’ll let LTK supply the equation. Creating it isn’t hard, but I’m hungry and tired…

Blake.

Volts = AnalogInputValue / 34.0

Well this is neat I might have to try this.

That formula assumed an 8-bit analog measurement. The vex controller is also capable of 10-bit measurement, in which case the formula is:

Volts = AnalogInputValue / 136.0