Is it possible to show the battery level of the secondary battery (i.e. the one from the power expander) on the LCD screen? I currently have our main battery, and our backup battery showing, but I would like to know the charge of the secondary battery as well.
We got it working. For future reference for others, we casted SensorValue as a float and had to use the 270ish divisor. I’m not sure why, but the divisor needed to be slightly higher than 270…
Also, the expander battery was reporting a value of 8.3V but when swapped with the main battery (whose voltage was read at 7V by the cortex), was read slightly incorrectly at 7.1V, acceptable error. Even more oddly was that the off battery was also showing a weird reading, I think Jesse said 2.3V.
I know Jesse is more than competent to respond, but I wanted to say something before many replies are made to a resolved issue.
You are correct, the numbers on the Wiki assume 10 bit A to D and ROBOTC is 12 bit.
I usually convert to the same units as the other batteries (ie. mV), here’s an extract from some of my old code.
#if defined( BATERY_2_PORT )
// NC1, A or A1 power expander 182/volt
battery2Level = (int)((float)SensorValue BATERY_2_PORT ] * 5.46);
// try and auto detect a new power expander, over 9000, probably an A2
if( battery2Level > 9000 )
// A2 power expander level 280/volt
battery2Level = (int)((float)SensorValue BATERY_2_PORT ] * 3.57);