expander battery level

I was thinking about making an algorithm that changes numbers in the program based on the battery level of the thrower, (TBH variable, ect…) but my thrower motors are on my expander. I know how to use the code to find the battery level of the battery connected to the cortex, but not the expander. Is this possible? if so, does anyone know how?

Their is an analog (I think) port on the power expander which you can hook your cortex analog port. I realise now that the wiki is missing sooo have a read of the setup instructions here.

You can connect a digital or analog port on the cortex to the status port on the power expander. See page 2 of this document for more information:

Just for clarification.

On the cortex you must connect the power expander status output to a Analog port. The Analog/Digital reference in that documentation refers to the older Pic 0.5 controller where ports were dual purpose.

Thanks for clarifying. I’ll be honest, I’ve actually never used a power expander (although I plan on doing so in a couple weeks).

Thanks. This will be very helpful to our code.

I hope so.

I didn’t want to hijack this thread but I figured this would be the best place to put this post. After reading where you have to divide the analog number by 70 (My power expander is a A2) I went and wrote the code but I was not sure where you actually divide the number. This is what I have now but it still doesn’t work, any help is welcome.
Power Expander.png

Okay so what you want to do is save a variable that is the number divided by 70. What you are currently doing is printing the characters “/70” rather than actually printing the number after it was divided by 70.

How would you go about doing this ? I tried making another variable (int) and for its value I wrote (expander_batt/70) and then changed my LCD block to retrieve to that variable but after testing it only retrieves a value of 13,790.

Any and all help is appreciated. Thanks :slight_smile:

The easiest way to do this is just to write

expander_batt / 70

in the variable box within the LCD block dialog. You will also want to put a decimal and zero after the 70 (so use 70.0) to force the compiler to use floating point division and not truncate the decimal answer. This allows you to read battery voltages like 7.2 instead of just 7.0 or 8.0.