Potentiometer reading error


#1

Hello

My team is using Potentiometer for Auton Selection. They ran few tests with the Potentiometer and noticed that the percentage value readings Pot.value(vex::percentUnits::pct) for the rotation on the shaft are off from the expectation. Please see attached for values read for the shaft rotation. Can someone help how to fix this?

int main() {
int32_t S1=0;
while(1) {
S1=Pot.value(vex::percentUnits::pct);
Brain.Screen.setFont(fontType::prop20);
Brain.Screen.printAt(140, 60, “analog: %d percent”, Pot.value(vex::percentUnits::pct));

    this_thread::sleep_for(50);
}

}
Potentiometer reading.PNG


#2

The potentiometer only has a range of motion a little larger than 3pi/2. If you rotate a gear in the potentiometer, you will feel some resistance at a certain point. Continue to turn and the values will reset.


#3

Your potentiometer is broken. They have internal stops to prevent them from turning beyond their sensor range, but those stops are easily destroyed by high torque robot mechanisms if you don’t pay attention to where they are positioned.


#4

Thanks,John. Will ask the team to test with a diffferent potentiometer.


#5

We are having problems w/potetiometers in V5 as well so may not be your code but a bug - then again it could bu us :slight_smile:

I am unaware the pot could be read as a percentage but rather an A/D value - we use
pot.value(analogUnits::range12bit)

FWIW we use the pot as a selector for autonomous and while the if/else echos the correct code to the controller it always runs one of the autonomous.

Good luck!