ADC non linear reading correction table


Closed Thread
Results 1 to 4 of 4
  1. #1

    Default ADC non linear reading correction table

    Hi all

    I'm measuring a voltage from an RF power detector which is not linear with an 8bit ADC (if possible later with 10bit)

    I would like to display the coresponding power level on an lcd based on a few reference measurements during calibration

    So i would like to do a 255 lookup table where I have a few true measured value's, the values in between needs to be calculated

    Any idea how to handle this ?

    example:

    During calibration i measure:

    ADC Power level watt

    51 36
    63 44
    70 54
    80 66
    89 82
    98 98
    109 119
    118 143
    130 180
    136 210

    now i have to calculate the power level for each ADC step between 51 and 63 etc..

    I think that using 255 bytes variables is to complicated, is there a way to fill the lookup table automaticly calculated from the know values ?


    HNY

  2. #2
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: ADC non linear reading correction table

    HNY

    Try the "Lookup" command as found in the PBP_Reference_Manual.pdf

    Norm

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: ADC non linear reading correction table

    You may not need more than a few points on the curve (depending on how much error you can tolerate) and linear interpolation to retrieve the values. I normally use this technique to curve-fit temperature sensors to real world readings. This is how it works in an example (ADC is assumed 8 bit)
    Code:
    array of                        array of 
    Real values                measured values
        0                                   5
      25                                  40
      100                               150
      175                               180
      200                               225
    
    Pseudo code
    
    ' Enter with ADC_reading in the range of 5-225(meas values)
    ' return with Actual_reading in the range 0-200
    
    Linearize:
         for cnt = 4 to 1 step -1              ' I assume array to be starting at 0 (like in C)
              if ADC_reading < Meas_Value[cnt] then
                   m1 = Meas_Value[cnt-1]
                   m2 = Meas_Value[cnt]
                   r1 = Real_Value[cnt-1]
                   r2 = Real_Value[cnt]
    
                   'interpolate the adc reading between m1, m2 and r1, r2 to get the actual value
                   ' multiply first using 16 bit integers to ensure the result is within 16bits
    
                   Actual = [(Adc_reading - m1)  * (r2-r1)] / (m2-m1) + r1
                   return
              endif
         next
         return 0  ' unsuccessful in finding a match
    Hope that helps

  4. #4
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: ADC non linear reading correction table

    Quote Originally Posted by Jerson View Post
    You may not need more than a few points on the curve (depending on how much error you can tolerate) and linear interpolation to retrieve the values. I normally use this technique to curve-fit temperature sensors to real world readings. This is how it works in an example (ADC is assumed 8 bit)
    [code]

    array of array of
    Real values measured values
    0 5
    25 40
    100 150
    175 180
    200 225

    Pseudo code

    ' Enter with ADC_reading in the range of 5-225(meas values)
    ' return with Actual_reading in the range 0-200

    Linearize:
    for cnt = 4 to 1 step -1 ' I assume array to be starting at 0 (like in C)
    if ADC_reading < Meas_Value[cnt] then
    m1 = Meas_Value[cnt-1]
    m2 = Meas_Value[cnt]
    r1 = Real_Value[cnt-1]
    r2 = Real_Value[cnt]

    'interpolate the adc reading between m1, m2 and r1, r2 to get the actual value
    ' multiply first using 16 bit integers to ensure the result is within 16bits

    Actual = [(Adc_reading - m1) * (r2-r1)] / (m2-m1) + r1
    return
    endif
    next
    return 0 ' unsuccessful in finding a match]

    Hope that helps
    Excellent contribution!

    Norm

Similar Threads

  1. Reading a LTC1865 ADC
    By JTCullins in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th December 2011, 15:54
  2. Reading (ADC) negative current
    By sougata in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st November 2006, 18:38
  3. Reading a linear hall sensor
    By peu in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd October 2006, 23:31
  4. PIC 18F452 Table Pointer/ Table Read
    By sougata in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th March 2006, 04:07
  5. adc reading ac
    By Ruben Pena in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 20th December 2005, 22:57

Members who have read this thread : 1

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts