One of our robot’s potentiometers on our lift is fine when we move the lift ourselves, but returns weird values that are obviously not correct (mostly 248-249) when motors move it.
What is going on?
I would guess that the pot isn’t plugged in. 245 is around the value you see when an analog port is just floating.
Also double check the pot is not able to spin 360 degrees. If it is then you broke the pot.
It only happens when the motors drive the lift…
I’ll still try to see if one of those is the case during the next session.
. @tmwilliamlin168 Definitely try to see if you can spin it in a circle for my team have noticed after 3 weeks of wear on our potentiometer they break causing the readings to differ
You have of course made sure nothing mechanical is affecting the potentiometers readings? The pot has a solid reference place and you are not knocking or pushing it in any damaging way? You might also like to check the wires and possibly even try and separate the motor and pot wires (as I guess there could be the possibility for interference). Maybe write the potentiometer values to debug stream and have a play round with the pot at different points and in different configurations. Try changing the pot and connected port to see if that has any affect?
I have definitely tried using broken potentiometers and the values have then been quite random, so it may be just that.
If you can get an ohmmeter or multimeter, try measuring the electrical resistance as you rotate the pot. Inside, the pot has a “wiper” that rubs over a resistive element. If the element gets dirty, or the wiper gets distorted or is just going bad, you might see dead spots or bad readings in places. The speed of the rotation might have some effect on things as the wiper might skip around or stick at some speeds and not others. Pots are great but they don’t last forever.
My teams have never had good luck with pots. Usually you see a number between 0 and 1400 but frequently we will have dead spots (floating numbers) when we test them. Even using new units fresh out of the package. They work okay for large movements (IE: detect if a claw is open) but when using them to sense the position of an arm then I recommend using optical encoders. If you must use pots you can add error handling and have the code ignore floating values but this may have unpredictable results.
We have had the exact opposite experience. Encoders have never served us well (especially with fast-moving mechanisms), but potentiometers have been wonderful and rather accurate (literally all of our potentiometers have infinite rotation too).
I would say this: made sure your wire connections are secure, verify that you’ve declared the potentiometers properly in your code, and test the full range of your mechanism to make sure it’s within the potentiometer’s true range.
Doesn’t that mean that they’re all broken?
Yes, it does. They still work though - just do extensive testing to make sure your mechanism doesn’t go outside [what were once] the potentiometer’s limits.