|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#2
|
||||||
|
||||||
|
Re: PID Loops
Quote:
There are many ways to use this for your robot. Let's say you have an arm that you want to control. You can put a sensor on that arm that measures the angle of the arm (for example, a potentiometer or an encoder). Using a PID loop, you can tell your arm what angle to go to, and the PID will command the motor automatically to get to that angle. If you can measure the heading of your robot (using a gyro or two encoders) you can use a PID loop to automatically drive along a desired heading in autonomous. There are unlimited uses: if you can think of something you want the robot to do automatically, a PID loop can help you do it. How does it work? It's actually fairly simple. Let's say you're driving your car and you want to accelerate to 40 MPH and hold that speed. How much do you push the pedal while you accelerate? (think about that for a minute before going on). I'm willing to bet that when you are far away from 40 MPH you push the pedal a lot, and as you get closer to 40 MPH you gradually back off. In other words, the farther you are from your desired speed, the more you push the pedal. Let's add some mathematics to this driving technique: You can determine how far you are away from your desired speed with a simple subtraction: How Far From Desired Speed = DesredSpeed - ActualSpeed The jargon is to call the above subtraction the "error". In other words, the "error" is how far away you are from what you desire. Mathematically: Error = Desired - Actual For the cruise control: Error = DesiredSpeed - ActualSpeed. Example: you want to be going 40 MPH (above example) and you are going 30 MPH. Then: Error = 40 MPH - 30 MPH Error = 10 MPH As we said before, when you drive you push the pedal more when you're farther away from 40 MPH and back off as you get closer. We can restate this by saying that as the "Error" is larger, you push the pedal more. When the Error is smaller, you back off on the pedal. Mathematically, this is: Pedal = K * Error Where K is some constant to convert between the Error and how much you push the pedal. The above equation (Pedal = K * Error) is exactly what is being done by the P part of the PID. P means proportional, and the above equation pushes the pedal in proportion to how much error you have. The I and the D part are a little more complicated. If this all makes sense so far, let me know and we can continue on with the I and the D part. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|