Hi, I'm taking readings from a potentiometer which is set up as a simple voltage divider (left pin to ground, wiper to arduino pin A0 and right pin to 5v). I have noticed that the readings at the bottom end and the top end of the pot are not as linear as the rest of the readings (the ones in the middle). I have the overall readings divided by 2 (giving me a total of 512) and i'm finding that i need to turn the pot approximately one third of it's full rotation to reach a reading of 32. After that however I can reach a reading of 64 after just a very small turn and the same to reach 96 and so on... all the way up until 480 and then I get the same issue as before... I need to do a much larger turn to reach a reading of 512.
Is this down to poor quality potentiometers? or is there something I can do to rectify this?
int pot = 0;
int div2 = 0;
pot = analogRead(A0);
div2 = pot / 2;
Thanks in advance
I'd guess you have an audio taper pot. Our ears are not linear and volume controls are designed so the signal is much lower than 50% at the mid-position.
no it's not audio taper. The whole of the mid-range is perfectly linear whilst both the top and bottom end seem to require a much larger rotation. If it were audio taper the bottom end would require more turn but the top end would require less... as it's curve is exponetial.
also.. The marking on the chassis says B10K (which indicates linear).
You could linearize it in software. Do some manual calibration to see what you get at each point and build an array to contain the mapping data.
yeah i did think of that... and it's probably what I'll end up doing but I just thought i'd post on here to see if anyone had any idea what might actually be happening.
Do you have input pullup enabled?
I just tried INPUT_PULLUP on A0 and I get exactly the same problem so it's not that.
but thanks anyway
INPUT_PULLUP will do nothing useful for a potentiometer with its ends connected to supply and ground.
If the potentiometer is more than about 5K, it will distort the readings somewhat.
The matter you describe as "the readings at the bottom end and the top end of the pot are not as linear as the rest of the readings (the ones in the middle)" is a matter of construction of the carbon track pot. It has metallisation at each end to facilitate a good connection to the carbon.
If you want more linearity, you would need to use a wire wound pot - and one manufactured deliberately for such precision.
Given a non linear pot then it would be theoretically possible to map the output from analogRead() to a linear range but whether it is sensible to do so is another matter
You probably just have a cheap pot with poor quality wiper.
Thanks guys. I'm going to have a go at mapping the readings tomorrow morning. Failing that I'll have a look at some different pots. Ideally I need them to be not so space consuming... and relatively inexpensive if possible. Any recommendations would be greatly appreciated.
You might want to look at cermet pots. I think they are more linear than those with carbon film elements
You don't say what you are using the pot for but maybe a rotary encoder could be used instead
What size do you need? How much can it cost?
I think I recall that Asian manufacturers swap A and B, but I can never remember which is which.
The way pots are made means thay can not be precisely linear at the ends. Your best solution is to mechanically restrict the range of movement (say 5% to 95%) and adapt your program for thos evalues..
If you want a precise measurement of position you need to use a purpose made position sensor - eg a rotary encoder.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.