# Thread: Possible Look Up Table Solution

1. ## Possible Look Up Table Solution

Hi,

I am struggling to read an ADC value, offset this value then convert into a battery voltage.

Below are my value:

* The ADC read range i am interesting in is (1.5V - 2.4V) == (309 - 491)

* I would like to convert 309 ADC value into battery minimum voltage 10V, and 491 ADC value into battery max voltage 14.4V. Also i would like to display all the battery voltages between 309 and 491.

At this point i do not know a conversion factor to convert ADC values into battery voltage. Would this be an ideal application for a look up table?

Thanks,

Rocketman46

2. Originally Posted by RocketMan46

Originally Posted by RocketMan46
* The ADC read range i am interesting in is (1.5V - 2.4V) == (309 - 491)
Wrong... if you got an 10 bits ADC, 1.5 V will be closer to 307 (306.9)...

Originally Posted by RocketMan46
* I would like to convert 309 ADC value into battery minimum voltage 10V, and 491 ADC value into battery max voltage 14.4V.
What seems to be the problem? You have 2 linear ranges. You can do this with a simple linear equation:

Voutput = ( Istep - 307 ) * ( ( 14.4 - 10 ) / ( 491 - 307 ) ) + 10

Where Istep is between 307 and 491 and Voutput is your desired value (in volts).