Hi,
I am REALLY confused, but what are PID loops? I am getting all sorts of weird answers. I am looking for a definitive answer…
THANKS!!!
-Masoug
Hi,
I am REALLY confused, but what are PID loops? I am getting all sorts of weird answers. I am looking for a definitive answer…
THANKS!!!
-Masoug
PID is an acronym for Proportional Integral Derivative. It is one very popular and effective way to do closed-loop control.
The easiest kind of PID loop to understand is the “P-only” loop - that is, it contains only Proportional control (no Integral or Derivative).
It is fairly easy to explain and understand intuitively. Let’s say you have a wheel with an encoder on it which senses the wheel’s speed. Let’s say you want to be able to make the wheel turn at a desired speed by sending the necessary command to the drive motor.
To create a “P” loop to do this in software, you take the desired wheel speed (called the “set speed”) and you subtract the actual wheel speed as measured by the sensor (sometimes called the “process variable”). This creates a “speed error”. When the speed error is positive, it means that the wheel is turning slower than what you want. When the speed error is negative, it means the wheel is turning faster than what you want.
Take the speed error and multiply it by a gain, Kp. Kp is a constant in your software which you will “tune” (by experimenting) to get the right value. This product (Kp*error) becomes your command to the motor.
OK, start asking questions!
~
(First, ignore the word “loop”. It can mean two completely different things depending on context, neither of which is important to the basic concept of PID control.)
PID stands for the three words Proportional, Integral, and Derivative. Those are fancy ways of saying that the output depends on the input right now, on the accumulated input over time, and on how quickly the input is changing. It’s a way to control something in order to cause a measured value to match a desired value. Changing the relative strength of the three parameters is called “tuning” the system, with the goal of reaching the target quickly with minimal overshoot and oscillation.
Most PID control algorithms start by computing an error value, which is just the difference between the target and the measured values.
With that simple description, you should be able to look at any number of detailed references and understand them better.
Every year when we teach PID to our students, I use the following definitions of the terms and examples. I think they’re very straight forward to grasp and gives you an understanding before diving into math.
The P term makes your speed proportional to how far you are away from your target. The farther you are away, the faster you will go. Think of this as running as fast as possible and stopping on a dime. You will run as fast as you can while you’re far away, but as you get close, you start slowing down.
The I term makes you go faster the longer you’ve been away from your target. It is dependent on time. Think of this as trying to run at a constant speed with a parachute on your back. You’ll start out running at the constant speed you are supposed to be at, but at some point the parachute makes it so that constant speed doesn’t get you to your end point. So what do you do? You run faster since you’ve haven’t been making progress.
The D term counteracts fast change. Picture a conveyor belt that’s supposed to be running at a constant speed. If a heavy box is dropped onto the belt, it is going to slow down quickly. The desired action here is to apply a speed increase to counteract the slowdown. Alternatively, if you’re walking at a constant speed and I shove you in the back, you will speed up because of the push, but you will slow your steps down until you’re back at a constant rate.
Hope that helps.
Oh, I forgot to mention:
The “loop” part refers to the fact that PID is a form of closed-loop control… there is a feedback loop. You are “looping” the output from the “plant” (explained in a moment) back into the controller (PID).
The “plant” is the device your PID is controlling, in the example I gave it is the drivetrain (motor+gearbox+wheel etc). The “output” of the plant is the wheel speed. The wheel speed signal is “looped back” to the PID.
Questions? Fire away…
Here’s a tutorial that 1114 programmer, Mike DiRamio, did on PID a couple of years ago.
The accompanying code and powerpoints are available on our website, which is currently down. I’ll update this post with the links to those once the site is back up.
As promised, now that the website is back up:
The PID specific powerpoint can be found on this page: http://www.simbotics.org/workshops
The PID code described in the video can be found on this page: http://www.simbotics.org/controls
Thanks a lot Karthik!
-Masoug