Difference between revisions of "PID Control"
Jump to navigation
Jump to search
Dsteinmark (talk | contribs) |
Dsteinmark (talk | contribs) |
||
| Line 52: | Line 52: | ||
* Cascading controllers? | * Cascading controllers? | ||
* Info about the mentor PID Controller code when completed? | * Info about the mentor PID Controller code when completed? | ||
| − | * Additional topics: tips for tuning (i.e. testing with drag), typical places to apply on the robot. | + | * Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot. |
[[Category:Programming]] | [[Category:Programming]] | ||
Revision as of 20:16, 8 December 2021
Intro
PID Control is a closed loop control architecture that uses monitoring and feedback to improve control of a process variable - that is something you wish to control. It is more robust than open loop controllers that have a set it and forget it type of mentality, which do not monitor what is happening.
Before learning about PID Control, it is important to know where it fits in with other types of control options. The introduction to PID is on this other page:
- See page: Intro to Control Theory and PID Loops
Tips and Guides
- PID control works best if the underlying control mechanism does a decent job first
- That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.
- This implies that your feed-forward/open loop/bias component should be calculated appropriately, and not rely on the PID portion to perform basic operation. Proper bias is an important element of the controller, and will allow you to focus efforts on tuning for step changes or variability, and not for basic performance. It is unnatural to combine them into the P, I, and D, and it will complicate the tuning process considerably if you do not account for a proper bias.
- Get your bias right before tuning P, I, or D. If the bias is incorrect, you will have a hard time tuning with only P. Figure out a good bias for as many setpoints as you find appropriate. If you have more than one setpoint of interest, and they would work best with different biases, create an equation or lookup table to help provide an appropriate bias for whatever setpoint is used.
- Tune P before I or D. P should generally be the largest input to correct the error, and should be tuned first. If you have to retune P, you will likely need to retune I and then D.
- Tune I before D. I should be used to help with variation and unexpected inputs, that can be corrected over time. If you have to retune I, you will likely need to retune D.
- Consider if windowing would be helpful. Windowing limits the impact of lengthy error accumulation, reducing windup, or effects after the problem has been corrected. However, if the window is too small, it may not guarantee that you ever reach the goal (setpoint).
- D often does not need to be used
- Only use D values if you have issues with oscillation, and are confident that is the best approach after considering:
- Is your I value too high?
- Would windowing the I integration to only recent samples help?
- The Derivative component D is often subject to noise and can be difficult to control
- You can perform noise filtering to get improvements at a cost of slightly delayed response for the D component. Usually the delayed response is insignificant.
- In order to filter, you need to keep track of several samples, and determine the slope using a longer time period, and perhaps averaged samples.
- For example, instead of comparing 2 samples 20 ms apart, keep track of the last 10 samples, spanning 200 ms. Compute the slope using the first and last values, using the time span between them.
- Another good idea to help with noise is to average 2-3 samples at the beginning and end of the period (be sure to average the times too!) before computing the slope.
- When tuning, be mindful of what is available for corrections:
- Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max negative output.
- Negative output is any output that causes the process variable to lessen
- Note that either the max positive or max negative output may be nil (zero)
- For example, when heating to a specific temperature, the best you may want to do when it is already too hot, is to turn off the heating element (not introduce cooling). Similarly, when cooling, you may only want to turn off cooling and not want to introduce heating when it has gotten too cold.
- Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response
- Banding of the PID controller is a simple way to get maximum controllability around the setpoint. The idea is that maximum positive output is applied below (setpoint - LOWER_THRESHOLD), and maximum negative output is applied above (setpoint + UPPER_THRESHOLD), and PID is used in-between the two thresholds.
- If you do not band, you will distribute the response of the PID controller over a wide area, thereby weakening it, especially when it is near to the setpoint. If it is so weak that the I component needs to take over, you will likely have issues with oscillation. On the other hand, if you make the bands too tight, it may act more like a Bang Bang controller.
- Multiple DLOs are used when you've identified different setpoint areas that require different types of responses. This may happen near boundary points, or due to some other aberration. You can create a controller for each of the setpoint areas, and they don't have to be the same.
- For example, for setpoints in range 0-10 you could use constant output, for setpoints in range 10-20 you could uses Bang Bang, and for 20+ you could use a PID controller.
Resources
Links:
- Control Gurus - The P-Only Control Algorithm Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same.
- Control Gurus - Table of Contents. Practical Process Control - Proven Methods and Best Practices for Automatic PID Control Some of the most comprehensive documentation on PID Control on the net. Includes beginner topics and advanced topics.
- Control Gurus Non-linear Processes and Design Level Of Operation (DLO) To tune a non-linear process that responds differently to changes at different levels of output, you need to determine a representative operating point (DLO). Maybe you need more than one because there is too much variation, in which case - you need more than one controller, each based on its own range of operation.
- Wikipedia PID Controller Pretty thorough introduction with examples, plus lots of concepts not presented above.
- Wikipedia Control Theory Pretty thorough introduction to Control Theory, with examples and more details.
- Talon SRX PIDF controller PID Control built into the Talon SRX controllers
To Do:
- Cover use of the PIDF controller built into the Talon SRX controllers by descriptive text here.
- Cascading controllers?
- Info about the mentor PID Controller code when completed?
- Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.