# RobotC Power Expander Status Battery Voltage

I wish to view the voltage level in the battery attached to the power expander in RobotC. I have this quick calculation:

``````
string exp_bat = (float)SensorValue[in6]/45.6;

``````

(for the LCD display) but it returns me a value of about 4.8. Am I doing something wrong? I am using the VEX Cortex.

Thanks

The numbers on the Wiki were assuming a 10bit A-D conversion, the code I use with my power expander is as follows.

``````
battery2Level = (int)((float)SensorValue BATERY_2_PORT ] * 5.48);

``````

Why 5.48 ?

Well I wanted the battery level in mV not V. As I said, the number 45.6 was for a 10 bit A-D conversion so for ROBOTC with 12 bit A-D the number would be 4 times larger, 45.6 x 4 = 182.4 so

V = AnalogValue / 182.4

but I want mV so

mV = AnalogValue / 182.4 * 1000

1000 / 182.4 = 5.48

Now having said that if you use 182.4 then you will get an even smaller value, so there are two possible explanations.

1. You have something connected wrong, you should have analog input 1 connected to the status port on the power converter. 4.8 x 45.6 gives an analog value of 219, this feels like you are reading an unconnected analog input as it is about the value of a floating input. Does the value on analog in1 change when you connect and disconnect the power expander battery?

2. There is a theory that there are two versions of power converter, I know the one I have is an older model, it has an issue that when the status port is connected then the led flashes red indicating an error even when there is not one. If there is indeed a new model then the calibration may have changed and different numbers needed, I have not been able to test this as the new unit I ordered is still on backorder.

There is some discussion in this thread
https://vexforum.com/t/power-expander-status-port/20846/1

and also this one

https://vexforum.com/t/power-expander-analysis/20794/1

Thank you for the reply; I will test out the new conversion tonight and respond back with results.

As for the 4.8 number, it does fluctuate when the arm and only the arm is being moved (which are the 4 motors in the expander) and I do believe it went to 0 when the battery was removed, but I am not fully certain of this. I’ll respond back later today.

Okay, so after testing, it actually gives a value of 48.[something] normally. Multiplying by 5.48 gives me 118[something]. However, I am certain this is tied to the battery because it fluctuates whenever the arm is moved.

(sorry I don’t have the [something]s for you; I shorten the number to a 3 character string so I can view the battery, the power expander battery, and the backup batter voltage in one line on the LCD)

Ok, well that sounds like they did change the hardware. 48 * 45.6 gives 2189, this would be about 2.67V on the AD converter.