How to convert data from a linear pot to that of a logarithmic one?

Hi,

I am using a digital potentiometer to act as a knob in an analog guitar pedal circuit. One of the knobs in that analog circuit calls for an 100k log pot. Issue is, most digipots are only made in linear values. I know how to hook up a linear pot, divide by 255, and send it to the digipot, but how would I take this linear digipot and have it act like a log pot?

Thanks for all your help!

Hello
at least you need a function, e.g. int log(int input); which executes the function y=f(x).

grafik

You will struggle with resolution with only 255 points

I had a similar problem converting a linear input from a Nextion slider into a logarithmic value for PWM control of white lights. If I left the relationship linear then the change in brightness looked wrong for changes of the slider position, due to the eye’s response to changes in brightness being logarithmic.

I used this:

unsigned char white_scale (unsigned char set) {
    return (unsigned char)round((1 - log10(10 - (double)set * 9 / 254)) * 255);
}

To provide the logarithmic value, which is satisfactory in the sense that the brightness of the light changes in what appear to be a linear fashion with the slider movement.

The function returns a logarithmically adjusted value based on the value of set, which is 8 bits.

I’m sorry but I can’t offer an explanation for the exact maths involved, it was too long ago and I have help from a friend who is much better at both maths and programming than I am.

Try the function and see if it does what you need.

1 Like

A lin pot can be made log by adding a resistor between wiper and ground.
I suppose you can do the same with digital pots.

Beware that most digital pots can’t process audio without mid-voltage bias or bi-polar supplies.
Leo…

Check this out: https://acidbourbon.wordpress.com/2016/10/01/brute_force_logpots/

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.