data conversion / scale

hello everyone,

I have a uC device, that, using a potentiometer, let me dial a time interval (in milliseconds) The problem is that it doesn't display (on the LCD) the actual time interval, it only shows a value between 0 and 127 (128 values). So in order to understand the actual time interval of each value of the potentiometer, I measured some of the values and I came up with this table

p(0)=0ms p(10)=11ms p(20)=28ms p(30)=50ms p(40)=88ms p(50)=150ms p(60)=250ms p(70)=430ms p(80)=760ms p(90)=1340ms p(100 )=2210ms p(110 )=3750ms p(120 )=6520ms p(127)=9700ms

(where p(20) is when I set the potentiometer to "20", and so on..)

With this, I noticed that it doesn't go linear, it looks like exponential. How can I approximate the other values, for example p(65), without having to measure them all?

Make sure your pot is a linear type and not a logarithmic (audio) type.

|500x239

Yep, looks like an audio (volume control) pot.

I mean. If OP wanted to he could use the above equation to get the values he needed without switching components. However, if the range that he required was as small as 70 ms MAX, then he would be wasting a large section of the range of the pot and his resolution would suck.

If that didn't matter he could do so.

Dimitree: it doesn't display (on the LCD) the actual time interval, it only shows a value between 0 and 127 (128 values).

If you want to convert the numbers to the time values you could use a series of IF statements - such as

if (inVal > 120) {
   timeVal = 9700;
}
else if (inVal > 110) {
   timeVal = 6520;
}
// etc

...R

is almost exponential - y =4.9267 * exp(0.0597 * x); but difficult to match exactly in the middle

so it is a job for multimap() - http://playground.arduino.cc/Main/MultiMap -

actually it is the opposite, the potentiometer is linear, and indeed you can dial a value between 0 and 127 in a linear fashion (in the middle, you get 63). The response that you get, in ms, is somewhat log (or exp?).

btw what I need is to obtain the table used to map the linear value (0-127) to the ms values, knowing only those values I already found. Of course that table can't be obtained in full precision, but an approximation would be good.

I think the only way is to interpolate the values that I already got?

Dimitree: I think the only way is to interpolate the values that I already got?

that is what multimap does