LOG pot to linear (when you HAVE TO use a LOG pot)

So I'm building a device for my psychology lab that will allow subjects to continuously rate their moods on a slide potentiometer (which will be analyzed on a 0 to 100 scale). I need a rather large slider to do this in order for participants to easily visualize their ratings on an actualized scale. I picked up a 5" slider from Digi-Key, linked here:


The problem is that this slider (and any slider I could find in this size) is an audio pot designed to be used as a fader on a mixing board. In order to collect data on a linear scale I clearly need a linear pot.

From what I've read, there are not any feasible hardware tricks to correct this- a logarithmic set resistor won't do me any good. In my googling, I have found this line of code:

linear = log(sensorValue) / log(1000) * 1023;

It seems to almost correct the problem, but the midway point is still slightly off. I know this might be futile, but does anyone have any other suggestions? The data sheet did list multiple tapers, but I frankly have no idea what I'm looking at there, and there is no visible toggle or adjustment on the slider that I can find. If you think this would be better suited on the coding board, I can move myself over there.

Thanks for your patience.

I'd suggest to "calibrate" your pot. Depends on how precise output has to be, define how many points you need to store in table, than use http://arduino.cc/playground/Main/MultiMap Though, I can't be sure how good linear approximation would be, never use this library. Other way is polynomial approximation.

I wouldn't have thought that statement/formula would have done very much. log(1000) is 3, so "log(sensorValue) / log(1000) * 1023" is the same as "log(sensorValue) * 341" I would have expected that in order to reverse the effect of a log taper you would need to use the pow() function. Try this statement, which maps an ADC reading from the integer range 0-1023 to a floating point range of 1-100 and then converts that to an integer 1-100. I can't test this - hope it works!

    int ADC;
    float f_outRange;
    int   i_outRange;

    ADC = analogRead(0);
    f_outRange = 10*pow(ADC/1023.,10);
    i_outRange = (f_OutRange + 0.5);

According to a wikipedia article, most log taper pots are actually two (or perhaps a few) linear potentiometers connected in such as way as to approximate a log taper. True log taper pots are apparently rather expensive. To get an accurate conversion of your potentiometer, you might have to measure its resistance at many points and then figure out how to map it properly.


I had the same problem, the output from the pot was unlinear. What helped was replacing the pot for a normally functional one :)


This one seems to be 10k lineair.