Thread: Possible Look Up Table Solution

  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    56

    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:

    * ADC read range (0V - 5V) == (0 - 1023)

    * 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?

    Look forward to your input.

    Thanks,

    Rocketman46

  2. #2
    Registered User
    Join Date
    Feb 2019
    Posts
    672
    Quote Originally Posted by RocketMan46 View Post
    * ADC read range (0V - 5V) == (0 - 1023)
    So 10 bits ADC.

    Quote Originally Posted by RocketMan46 View Post
    * 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)...

    Quote Originally Posted by RocketMan46 View Post
    * 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).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 08-23-2017, 11:51 AM
  2. Replies: 1
    Last Post: 08-23-2017, 06:54 AM
  3. Need the best solution
    By ginom71 in forum C Programming
    Replies: 11
    Last Post: 07-03-2009, 02:51 PM
  4. Sorting a table and saving a table help!!!
    By MrMe913 in forum C Programming
    Replies: 4
    Last Post: 04-18-2007, 12:19 PM
  5. Solution!
    By Joanna in forum Tech Board
    Replies: 11
    Last Post: 09-12-2004, 07:50 PM

Tags for this Thread