# 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:

http://www.digikey.com/product-detail/en/EVA-NF4R15D14/PNF100SD-ND/244380

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.

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;