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:

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

HNY

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

Norm

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

' 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)
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

return
endif
next
return 0  ' unsuccessful in finding a match```
Hope that helps

Originally Posted by Jerson
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

' 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)
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

return
endif
next
return 0 ' unsuccessful in finding a match]

Hope that helps
Excellent contribution!

Norm