WPILIB Analog Potentiometer Class Question

Hi all,

As I’m aware, the AnalogPotentiometer object takes in a port channel, a “full range” value, and a “offset” value in its constructor. I’m confused as to how the “full range” and “offset” parameters work.

We’re using an analog potentiometer that has a 270 degree range. However, because we are using it to measure the angle of a vertical arm, we will only be using it to measure values between 0 and 90 degrees (with 0 being the downwards, resting position of the arm). How do I make sure the potentiometer measures in degrees? What values should I put in for the “full range” and “offset” parameters?

Thanks so much for your help in advance!

It doesn’t matter what range the arm can move, it matters what range the potentiometer measures. So if your potentiometer is 1:1 with the arm it would be 270 degrees (ie the difference between the angle at max and the angle at min. The offset is what angle the potentiometer measures at the minimum value. So if at 0 degrees, the potentiometer measures 0, it would be 0.

It’s better to use the middle range of a potentiometer as they are less accurate at the ends.

We’ve been struggling with the docs on potentiometer as well. I think the 2nd parameter is better described as “scale factor” rather than “full range”, and the 3rd as “our zero point”. So, place your arm at your zero position (horizontal) and read the pot value, let’s say it’s p0. Then place your arm at your 90-degree position and read the pot value, let’s say it’s p90. My current guess as to what 2nd and 3rd arguments should be for you are: 90.0/(p90-p0) and p0.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.