WPILIB's new 2020 PID controller

Hi everyone, fairly new programmer for our team here so bear with me!

I have come to understand what a PID controller is and how it works, but our team has opted to use VictorSPX’s and a absolute encoder for our PID on our “arm” this year and the new PID system no longer has a bunch of past year examples for reference.

Our teams robot is a java “TimedRobot”, two jointed(mechanically locked at a 2.5:1 ratio) arm that will use the encoder to set us at set heights using the two CIM motors lifting it

The function of lifting is fine and the stall torque holds it up without issue

NOW to the beef and beans… Our team needs a PID for it and I cant for the love of me figure it out. I see topics that say it should be “easier to understand” but as a new programmer, i cant figure it out

  1. How do i set the encoder to work with the PID
  2. How do i use the calculate() function and get its values to put into the motors

Please help if at all possible, our teams example coding we’ve been working for the arm and CAD model is available if needed

1 Like

Make sure you re-read: https://docs.wpilib.org/en/latest/docs/software/advanced-control/introduction/introduction-to-pid.html

Then, take a look at the simple example projects: https://github.com/wpilibsuite/allwpilib/tree/master/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples

There is a simple elevator PID example that will show you exactly how to use the encoder and the calculate method to set the motor.

Don’t forget to read the first section again just to be sure you understand what is happening.


i looked at this and even had it saved its link in the code facepalm, Im 99% sure this will work but i need to test it tomorrow, I’ll update how it works when I get it running! Thank you so much!

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