PID Controllers

I am wondering what the different kinds of PID controller applications are and what they solve.
I’m new to PID and I’ve heard that there are different types of PIDs like slant control for driving straight or turning, and I’d appreciate it if someone could tell me more about the different kinds and how they work

2 Likes

A PID is useful when you want to go fast when you’re far away and slow when you’re close.

So if the robot is drifting a lot you want to add a lot of power and when it’s drifting a little you add a little power.

There’s no need for different kinds here’s the most common uses:

Driveforward PID: to drive forward to the desired distance
HeadingPID: to keep the robot straight
Turn PID: to turn to the desired angle
Bring lift to position PID: bring lift to consistent to positon

all of these are coded the same, to use the drivePID and headingPID simply add their output values together before sending it to the motors

4 Likes

PID (or any closed loop controllers) does one thing. When given a target value and a sensor, it will try to bring the sensor value toward the target by controlling the output. Anything that has a sensor which you want to bring to a specific value can use PID.

Driving for a certain distance? That’s the same as getting the motor encoders to get to a certain reading. PID can do that.

Driving straight by maintaining heading? You are trying to getthe imu heading be at 0, PID can do that.

Trying to make the lift stay at a certain height? You are trying to make the lift encoder be at a certain value. PID can do that.

Trying to control the flywheel velocity? You are trying to make the velocity reading reach a target. PID can do that.

Basically anything can use PID if the answer to the following question is yes. Use your imagination.

  • Will moving the motor (or any output) affect the sensor value in any meaningful way?
  • Are you trying to make the sensor reading reach a target value?
5 Likes

PID Use Cases:

  • Drivetrain for Autonomous if you use PID with a Slew Rate. This allows you to move your robot with an uncertainty of 0.25 centimeters, roughly. For me, when moving to specific positions, my favorite algorithm is Slew Up → PD Down → PID when motor’s voltage is 0.5 > x > -0.5. I can explain a bit more on how it’s done, if you’d like.
  • Lift, for Autonomous and also semi-automation during driver control. If your lift has perfect banding (that is your banding’s force negates gravity’s force in all positions of your lift), you can use PID. If not, you can do PID + Gravity Compensation.
  • Flywheel. You can use PID on a flywheel where you do PID on speed instead of position. You would basically grab the motor’s velocity (rpm preferred) as the current position, and when applying motor power, you do motorpower = motorpower + (error * kP + totalError * kI + derivative * kD). Or we can simplify this to motorpower += (error * kP + totalError * kI + derivative * kD)

P Use Cases:

  • Claw If you are using a claw, do NOT use a PID as it will cause motor burnout, if a load is required on the claw. This is why motors burnout when using default integrated motor.spin commands with claw. Just doing a P loop would be beneficial to not cause the motor to unnecessarily hurt itself.
  • Lift Hard Stops Oftentimes you will find that it is more precise to use a hard stop (pressing up the lift against a piece of metal) to make tasks more efficient. Hard stops should ALWAYS use a P loop instead of a PID loop.

Now, I am betting you’re hearing words, but you have absolutely no idea where to start. Here is PID but in ROBOTC. You can easily replicate this in PROS and most other languages as well:

To be extremely dumbed down for the sake of simplicity on PID:
P = Proportional = error = distance from you and desired target. Increasing kP constant this helps reach the goal easier
D = derivative = speed = a measurement on how fast you are (also known as derivative of P). Increasing kD constant will help dampen oscillations
I = Integral = absement = totalError = accumulation of the distance over time. It is the integral of P. Increasing kI will ‘nudge’ the current position to the desired position if the system is only like a couple of ticks from the desired position but settles too early.

4 Likes

Could you clarify what sensors are needed for PID? @Connor @Ryan_4253B @DanTheMan

We will be using it in synchronous of 3 wheel odometry

If you’re using 3 wheel odometry you don’t really need any other sensors for using PID loops to control your drivetrain. Maybe an intertial for heading? but you could figure out your heading from the 3 wheel odom.

3 Likes

ok thank you so much! We will have position and heading from our odom, i was just double checking if we needed anything else