 # how to interpret a nonlinear potentiometer linear through the code?

Hello everybody,

i accidently bought some nonlinear (logarithmic) slide potentiometers which output this curve (see the added picture) by moving it in a constant speed up, so how can i make them output a linear value?

(extra details: i read there value through a 16bit adc so the values are really big and accurate)

• lynes

You could create an array to interpolate the values based on the graph and just look it up.

how accurate do you need it to be?

if not too accurate, you could probably fix it with 2 linear pieces

gcjr:
how accurate do you need it to be?

if not too accurate, you could probably fix it with 2 linear pieces

True. You could split it into 2 or more segment and interpolate each segment using map

lynes:
Hello everybody,

i accidently bought some nonlinear (logarithmic) slide potentiometers which output this curve (see the added picture) by moving it in a constant speed up, so how can i make them output a linear value?

(extra details: i read there value through a 16bit adc so the values are really big and accurate)

If it was me, I would simply read the ADC value for as many wiper positions as I can (more positions = better accuracy) and create a lookup table. If a read falls between any 2 ‘saved’ values, then interpolate for that set as already suggested.

to make it all little bit more clear:

ich have about 12 to 20 inputs and just want a little math converter like the thread forum.arduino.cc show it, except now with a code that actually working. there function "f_outRange = 10*pow(ADC/1023.,10);"

just reverse the direction of the effects, so in the 0 -30% area of the slider change now alot and above just a little .

i dont want to make a number table for that ;D

-lynes

What do you mean by

so in the 0 -30% area of the slider change now alot and above just a little .

Doesn't your graphic show the opposite?

To reverse the direction (if I understand your intention correctly), wire the potentiometer the other way around.

sterretje:
What do you mean by Doesn't your graphic show the opposite?

To reverse the direction (if I understand your intention correctly), wire the potentiometer the other way around.

i mean the code on the website just fliped the result, but not made it look linear, which is my goal.

lynes:
i mean the code on the website just fliped the result, but not made it look linear, which is my goal.

is there a particular reason you need it to be linear if I may ask?

lynes:
i mean the code on the website just fliped the result, but not made it look linear, which is my goal.

to continue what was proposed in reply#4 In the above table, say 'log' was the ADC reads from your logarithmic pot at the various wiper positions.

'linear' is what you would have expected to get should the pot been linear ('linear' = m*wiper_pos).

so from the ADC read, you can estimate the 'wiper pos' using interpolation then use that value to determine the corresponding linear ouput

if all your pots are the same then, you simply would be calling the SAME dataset and formulas every time

hope that helps 