Skip to content

Instantly share code, notes, and snippets.

@bencholmes
Created November 25, 2017 17:19
Show Gist options
  • Save bencholmes/87ceeaee702ec0dc1d0426283d2ae2f6 to your computer and use it in GitHub Desktop.
Save bencholmes/87ceeaee702ec0dc1d0426283d2ae2f6 to your computer and use it in GitHub Desktop.
Versatile logarithmic potentiometer law model.
% travel is the location of the wiper along the pot from 0 to 1
travel = linspace(0,1,1000);
% Define the factor of resistance at the middle pot position
mid = 0.15;
% b is the base of the exponential equation
b = (1/mid - 1)^2;
% a is the multiple and also the offset
a = 1/(b-1);
% Calculate the resistance
resistance = a*b.^travel - a;
figure;
plot(travel,resistance)
xlabel('Potentiometer Position'); ylabel('Resistance Factor');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment