PDA

View Full Version : ADC non linear reading correction table



RFsolution
- 28th December 2013, 22:37
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

Normnet
- 29th December 2013, 02:48
HNY

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

Norm

Jerson
- 29th December 2013, 02:57
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)



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

Normnet
- 29th December 2013, 03:24
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