Intro to Control Theory and PID Loops
Control Examples
- Car cruise control
- Thermostat for Heat or Air Conditioning
- Navigational control for maintaining a ships heading
- Autopilot for an aircraft
- Keeping a Tesla in its own lane
Robotic Control Examples
Open Loop - No Feedback
Simple
- Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)
- Stop a motor from running by setting the voltage to zero immediately
- Disadvantages?
- Advantages?
Trapezoidal (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)
- Ramp the motor speed up to the set voltage
- Stop a motor from running by ramping the voltage down to zero.
- Disadvantages?
- Advantages?
Closed Loop - Uses Feedback
- Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down
- Maintain a constant speed up a ramp of varying inclination
- Rotate toward a target at a variable rate. The rate varies such that it rotates faster when it has more to turn.
Close Loop Examples
- Bang Bang Control. This control is simple like a typical thermostat - either full on (if below the setpoint) or full off, if above the setpoint. There is a typically a banding (or window) for the control points above and below the set points, to avoid constant switching on and off and to account for hysteresis (lagging of output). For example, if a thermostat is set at 70° F, a bang bang controller may be set to full output below 69° F, and no output above 71° F. A system will use full positive control to increase the process variable, and full negative control to decrease it. The process value usually oscillates about the setpoint in a triangular shaped pattern.
- Bang Bang with Bias. This adds a bias or maintenance element when in the window- a partial output that is intended to increase the time spent between the lower and upper control points. Not applicable for control systems that can only be full ON or full OFF.
- Trapezoidal, when based on error (distance from target)
- PID (See below.)
See image: Stepped output and ramped output
Control Theory Intro
- Wikipedia Control Theory See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.
Control theory deals with the controlling dynamic systems. The objective is to develop a control model for controlling such systems using a control action in an optimum manner without delay or overshoot and ensuring stability.
To do this, a controller with the requisite corrective behavior is required. This controller monitors the controlled process variable (PV), and compares it with the reference or set point (SP). The difference between actual (PV) and desired value (SP) of the process variable, called the error signal, or SP-PV error, is applied as feedback to generate a control action to bring the controlled process variable to the same value as the set point. Other aspects which are also studied are controllability and observability. This is the basis for the advanced type of automation that revolutionized industries. This is feedback control, which involves taking measurements using a sensor and making calculated adjustments to keep the measured variable within a set range by means of a "final control element", such as a control valve.
Open Loop and Closed Loop
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.
In open loop control, the control action from the controller is independent of the "process output" (or "controlled process variable" - PV). A good example of this is a central heating boiler controlled only by a timer, so that heat is applied for a constant time, regardless of the temperature of the building. The control action is the timed switching on/off of the boiler, the process variable is the building temperature, but neither is linked.
In closed loop control, the control action from the controller is dependent on feedback from the process in the form of the value of the process variable (PV). In the case of the boiler analogy, a closed loop would include a thermostat to compare the building temperature (PV) with the temperature set on the thermostat (the set point - SP). This generates a controller output to maintain the building at the desired temperature by switching the boiler on and off. A closed loop controller, therefore, has a feedback loop which ensures the controller exerts a control action to manipulate the process variable to be the same as the "Reference input" or "set point". For this reason, closed loop controllers are also called feedback controllers.
The definition of a closed loop control system according to the British Standard Institution is "a control system possessing monitoring feedback, the deviation signal formed as a result of this feedback being used to control the action of a final control element in such a way as to tend to reduce the deviation to zero."
Likewise; "A Feedback Control System is a system which tends to maintain a prescribed relationship of one system variable to another by comparing functions of these variables and using the difference as a means of control."
Other Examples (straight from wikipedia)
An example of a control system is a car's cruise control, which is a device designed to maintain vehicle speed at a constant desired or reference speed provided by the driver. The controller is the cruise control, the plant is the car, and the system is the car and the cruise control. The system output is the car's speed, and the control itself is the engine's throttle position which determines how much power the engine delivers.
A primitive way to implement cruise control is simply to lock the throttle position when the driver engages cruise control. However, if the cruise control is engaged on a stretch of non-flat road, then the car will travel slower going uphill and faster when going downhill. This type of controller is called an open-loop controller because there is no feedback; no measurement of the system output (the car's speed) is used to alter the control (the throttle position.) As a result, the controller cannot compensate for changes acting on the car, like a change in the slope of the road.
In a closed-loop control system, data from a sensor monitoring the car's speed (the system output) enters a controller which continuously compares the quantity representing the speed with the reference quantity representing the desired speed. The difference, called the error, determines the throttle position (the control). The result is to match the car's speed to the reference speed (maintain the desired system output). Now, when the car goes uphill, the difference between the input (the sensed speed) and the reference continuously determines the throttle position. As the sensed speed drops below the reference, the difference increases, the throttle opens, and engine power increases, speeding up the vehicle. In this way, the controller dynamically counteracts changes to the car's speed. The central idea of these control systems is the feedback loop, the controller affects the system output, which in turn is measured and fed back to the controller.
Using Multiple (Different) Controls for Different Portions of a Non Linear Process
Suppose you have to control a single process variable, but you need it to behave differently near different setpoints or when approaching from above or below.
- 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.
So the answer is to use different controllers for different portions of the response curve. You can choose from open or closed loop controllers, PID and non PID, or all PID but different parameters.
PID Loops
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.
PID Controllers have up to 3 components:
- P, the Proportional component
- I, the Integral component
- D, the Derivative component
But if you want them to work, they also have to have the feed-forward or steady state component, also known as the controller bias or null value.
The basic form for the controller output is:
- CO = CObias + P + I + D,
or more specifically:
- CO = CObias + Kp∙e(t) + Ki∙Sum(e(t0..tt)dt) + Kd∙Slope(e(t))
whereby:
- CO is the controller output
- CObias is the null value for the controller
- Kp is the tuning constant multiplier for P, the Proportional element
- e(t) is the error SP-PV at the current time (t)
- Ki is the tuning constant multiplier for I, the Integral element
- Sum(e(t0..tt) is the integral or summation of the errors from time 0 to time t
- dt is the delta time from the first time integral element to the last time integral element
- Kd is the tuning constant multiplier for D, the Derivative element
- Slope(e(t)) is the slope of the error curve at time t
More Details
- CObias is critical to achieve an output that attempts to remain under control when at the setpoint. With no bias, when the system is at the setpoint, control would turn off, allowing the system to drift with no support. Much better to drift with appropriate support, which is what the bias adds. Moreover, without a bias, proportional control may be insufficient to fully reach the setpoint value, especially when close to the setpoint, as controller output drops towards zero.
- Zero Bias. You can get away without a bias if your process variable is neutral - there is no inherent drift and the necessary control output to reach the setpoint is independent on the setpoint value, and only on the error (distance from setpoint). For example, if you need to orient a robot's attitude (direction) on flat ground. It does not matter that it is pointing due north or due south, the effort to correct an orientation is based solely on the error (angular difference).
- Setting CObias Typically, bias is determined experimentally. There are several ways to set the bias, including:
- Statically - with a fixed value that is the same always
- Manual input - keep it at a user entered position (value)
- Functionally - set it with an equation
- Lookup table - look values up in a table, and use interpolation when in-between
- P The P component is the proportional component, and is the most important element of a PID controller. In fact, many successful controllers use only the P component, or the P component with an appropriate bias. A P component by itself works a lot like a Trapezoidal controller. The proportional element is based on the magnitude and direction of the current error, and compensates based on the size - the greater the error, the greater the correction, the smaller the error, the smaller the correction, in a linear (proportional) manner. For example - a 10% error (from 0 to max error) would result in a 10% of max correction, a 25% error would be a 25% correction, and so forth.
- TBD more explanation about I, and D, and why and when each is used
Edits To do (some goes in PID page):
- banding the PID control (I.e) multiple DLOs) to create a stronger response
- emphasis on error
- oscillations
- can’t correct with > 100% effort
More on PID Loops
- Mentor wiki page for PID Control. Contains more links and guides, plus practical lessons.
- Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only.
- Control Gurus - The P-Only Control Algorithm Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same.
More Info
- Wikipedia PID Controller
- Control Gurus - Table of Contents Some of the most comprehensive documentation on PID Control on the net. Includes beginner topics and advanced topics.
- Talon SRX PIDF controller PID Control built into the Talon SRX controllers
- Practical Guide to State-space Control: Graduate-level control theory for high schoolers - Tyler Veness Designed by an ex-FRC team member for high schoolers in FRC. This is not a basic introduction, but rather a fairly comprehensive coverage of beginning, intermediate, and advanced control theory topics at a level of instruction that the author believes can be synthesized by high schoolers. Yeah, it’s about 200 pages.