Find the percentage of a value within a logarithmic range?

Calab

New member
Joined
Dec 19, 2025
Messages
3
Forgive me if I don't explain clearly... I'm not a math expert by any means...

I have a range of numbers between 1 and 32768. This range increases logarithmically. In other words 50% of this range is not 16384, but a much lower number, which I would guess is around 2600 - but that is a guess.

If I have a value between 1 and 32768, how would I find out what percentage of the scale that value falls at?

My problem is that I am reading a potentiometer and my sensor returns a value between 1 and 32768. As I turn the potentiometer, the increase in readings starts out small. The further I turn the faster the value climbs. I need to get a linear reading from this sensor.

Any kind of assistance with this problem would be greatly appreciated.
 
I think I stated my problem backwards. I know the value between 1 and 32768. I need to know the percentage that it falls at.

In other words, if my value is 0, then it's 0%. If my value is 2600 (a guess), then it's 50%, if my value is 32768, then it's %100. It's the percentage I'm after.

I believe I'm working in a natural logarithm, but could use a specific base if needed.
 
Last edited:
What function did you graph? Does that represent what you have in mind, or is it just similar?

One trouble is that if you want this to be an exponential function (so that the percentage is a logarithmic function), then there can't really be a zero point as shown (without some adjusting). Furthermore, you need some other number to determine the scaling, such as your example of 2600 being 50%. The 0% and 100% values are not sufficient to determine the curve, even if we assume a particular form.

Here's an example:

1766202584495.png

Note that this doesn't pass through (0, 0).

How close is that to what you want?
 
The 0% and 100% values are not sufficient to determine the curve, even if we assume a particular form.
Not sure I completely agree with this. If we assume that the exponent depends on just 2 parameters [imath]a[/imath] and [imath]b[/imath], i.e.: [imath]y = a b^x[/imath] then the values at 0 and 100 are sufficient. In this particular case it is a given that [imath]f(100) = 32768[/imath], and [imath]a = f(0)[/imath] (which, as you pointed out, cannot be 0). To illustrate, I've plotted several graphs for different values of [imath]a[/imath]:
1766240421243.png
 
Not sure I completely agree with this. If we assume that the exponent depends on just 2 parameters [imath]a[/imath] and [imath]b[/imath], i.e.: [imath]y = a b^x[/imath] then the values at 0 and 100 are sufficient. In this particular case it is a given that [imath]f(100) = 32768[/imath], and [imath]a = f(0)[/imath] (which, as you pointed out, cannot be 0). To illustrate, I've plotted several graphs for different values of [imath]a[/imath]:
View attachment 39908
But that's exactly my point: All of these curves are possible. We can't know the value of a without more information, such as the suggested 50% point. But we'd need to modify the equation if we really want [imath](0, 0)[/imath]).

My graph is [imath]y=32768e^{k\left(x-100\right)}[/imath] with [imath]k\approx0.05[/imath] to fit that point.

Of course, you're right that, taking it literally, if we knew [imath]f(0)[/imath] exactly, then that would be enough (though if [imath]f(0) = 0[/imath], then [imath]f(x) = 0[/imath]!); but clearly we don't! I should have said, if we know only that it has this form (so that [imath]f(0)\approx0[/imath]), and that [imath]f(100) = 32768[/imath], then we need more information.
 
Top