<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mort11.com/mentor.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dsteinmark</id>
	<title>FRC11 - Mentor Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://mort11.com/mentor.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Dsteinmark"/>
	<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php/Special:Contributions/Dsteinmark"/>
	<updated>2026-11-26T10:59:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=930</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=930"/>
		<updated>2021-12-09T21:31:37Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Open Loop - No Feedback */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* [[Tank Drive - Joystick Control | Set motor speeds based on joystick position (see link)]]&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Simple Closed Loop Controllers ==&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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 or to account for hysteresis (lagging of output).  There are different ways to use the setpoints, but if hysteresis (lag) is minimal, and there is a desire to avoid constant switching, the setpoints could be implement as follows:  For example, if a thermostat is set at 70° F, a Bang-Bang controller may be set to full output below 69° F, and keep running until the system reaches 71° F, then no output above 71° F, and until it falls below 69° F, whereupon the cycle repeats.  A system will use full positive control to increase the process variable, and nothing (or full negative control) to decrease it.  The process value usually oscillates about the setpoint in a sawtooth shaped pattern.&lt;br /&gt;
** '''Bang-Bang with Bias'''.  This adds a bias or ''maintenance'' element when ''in the window'' after the upper threshold has been reached, and before falling back to the lower threshold.  The bias is used instead of full off (or full negative output) - it is a partial output that is intended to increase the time spent between the lower and upper control points.  This is only applicable for systems with variable output - NOT applicable for control systems that can only be FULL ON or FULL OFF.&lt;br /&gt;
* '''Trapezoidal''' or '''Ramping''', when based on error (distance from target).  Trapezoidal or Ramping control can be achieved with by a formula for controller output based on distance from the target setpoint.  The correction is proportional to the error (maximum output when error exceeds thresholds), and is very similar to just the ''P'' portion of PID control.&lt;br /&gt;
&lt;br /&gt;
::: Sample equations.  Note, this is for systems with both positive and negative outputs.&lt;br /&gt;
::: NOTES - in the below equations:&lt;br /&gt;
::::: THRESHOLD_LOWER and THRESHOLD_UPPER are both positive numbers.  If the problem is symmetrical, then they are equal (otherwise not necessarily)&lt;br /&gt;
::::: MAX_POSITIVE_OUTPUT is chosen for the problem at hand, it is always &amp;lt;= ''The Maximum System Output''&lt;br /&gt;
::::: MAX_NEGATIVE_OUTPUT is chosen for the problem at hand, it is always &amp;gt;= ''The Maximum System Negative Output'' (in some systems this may be zero)&lt;br /&gt;
&lt;br /&gt;
:: Error = SetPoint - ProcessVariable (actual) ''so positive means actual is below setpoint, negative means actual is above setpoint''&lt;br /&gt;
:: if (Error &amp;gt; THRESHOLD_LOWER)&lt;br /&gt;
:::    { Controller Output = MAX_POSITIVE_OUTPUT }&lt;br /&gt;
:: if (Error &amp;lt; (-1 * THRESHOLD_UPPER))&lt;br /&gt;
:::    { Controller Output = MAX_NEGATIVE_OUTPUT }&lt;br /&gt;
:: if ((Error &amp;gt; 0) and (Error &amp;lt;= THRESHOLD_LOWER))&lt;br /&gt;
:::    { Controller Output = MAX_POSITIVE_OUTPUT * Error / THRESHOLD_LOWER } &lt;br /&gt;
:: if ((Error &amp;lt; 0) and (Error &amp;gt;= -1 * THRESHOLD_LOWER))&lt;br /&gt;
:::    { Controller Output = -1 * MAX_NEGATIVE_OUTPUT * Error / THRESHOLD_UPPER }&lt;br /&gt;
:::    (note - make sure you re-evaluate the signs for the last case, and test for proper sign usage based on your design)&lt;br /&gt;
&lt;br /&gt;
:: NOTE - you may wish to have a deadzone near the setpoint where it's ''close enough'' and no output is specified&lt;br /&gt;
&lt;br /&gt;
* '''PID''' (Not so simple. See below.)&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
Also, these sources are excellent&lt;br /&gt;
*[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
*[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
*[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=929</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=929"/>
		<updated>2021-12-09T21:23:29Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Simple Closed Loop Controllers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Simple Closed Loop Controllers ==&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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 or to account for hysteresis (lagging of output).  There are different ways to use the setpoints, but if hysteresis (lag) is minimal, and there is a desire to avoid constant switching, the setpoints could be implement as follows:  For example, if a thermostat is set at 70° F, a Bang-Bang controller may be set to full output below 69° F, and keep running until the system reaches 71° F, then no output above 71° F, and until it falls below 69° F, whereupon the cycle repeats.  A system will use full positive control to increase the process variable, and nothing (or full negative control) to decrease it.  The process value usually oscillates about the setpoint in a sawtooth shaped pattern.&lt;br /&gt;
** '''Bang-Bang with Bias'''.  This adds a bias or ''maintenance'' element when ''in the window'' after the upper threshold has been reached, and before falling back to the lower threshold.  The bias is used instead of full off (or full negative output) - it is a partial output that is intended to increase the time spent between the lower and upper control points.  This is only applicable for systems with variable output - NOT applicable for control systems that can only be FULL ON or FULL OFF.&lt;br /&gt;
* '''Trapezoidal''' or '''Ramping''', when based on error (distance from target).  Trapezoidal or Ramping control can be achieved with by a formula for controller output based on distance from the target setpoint.  The correction is proportional to the error (maximum output when error exceeds thresholds), and is very similar to just the ''P'' portion of PID control.&lt;br /&gt;
&lt;br /&gt;
::: Sample equations.  Note, this is for systems with both positive and negative outputs.&lt;br /&gt;
::: NOTES - in the below equations:&lt;br /&gt;
::::: THRESHOLD_LOWER and THRESHOLD_UPPER are both positive numbers.  If the problem is symmetrical, then they are equal (otherwise not necessarily)&lt;br /&gt;
::::: MAX_POSITIVE_OUTPUT is chosen for the problem at hand, it is always &amp;lt;= ''The Maximum System Output''&lt;br /&gt;
::::: MAX_NEGATIVE_OUTPUT is chosen for the problem at hand, it is always &amp;gt;= ''The Maximum System Negative Output'' (in some systems this may be zero)&lt;br /&gt;
&lt;br /&gt;
:: Error = SetPoint - ProcessVariable (actual) ''so positive means actual is below setpoint, negative means actual is above setpoint''&lt;br /&gt;
:: if (Error &amp;gt; THRESHOLD_LOWER)&lt;br /&gt;
:::    { Controller Output = MAX_POSITIVE_OUTPUT }&lt;br /&gt;
:: if (Error &amp;lt; (-1 * THRESHOLD_UPPER))&lt;br /&gt;
:::    { Controller Output = MAX_NEGATIVE_OUTPUT }&lt;br /&gt;
:: if ((Error &amp;gt; 0) and (Error &amp;lt;= THRESHOLD_LOWER))&lt;br /&gt;
:::    { Controller Output = MAX_POSITIVE_OUTPUT * Error / THRESHOLD_LOWER } &lt;br /&gt;
:: if ((Error &amp;lt; 0) and (Error &amp;gt;= -1 * THRESHOLD_LOWER))&lt;br /&gt;
:::    { Controller Output = -1 * MAX_NEGATIVE_OUTPUT * Error / THRESHOLD_UPPER }&lt;br /&gt;
:::    (note - make sure you re-evaluate the signs for the last case, and test for proper sign usage based on your design)&lt;br /&gt;
&lt;br /&gt;
:: NOTE - you may wish to have a deadzone near the setpoint where it's ''close enough'' and no output is specified&lt;br /&gt;
&lt;br /&gt;
* '''PID''' (Not so simple. See below.)&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
Also, these sources are excellent&lt;br /&gt;
*[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
*[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
*[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=928</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=928"/>
		<updated>2021-12-09T19:28:17Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Simple Closed Loop Controllers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Simple Closed Loop Controllers ==&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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 or to account for hysteresis (lagging of output).  There are different ways to use the setpoints, but if hysteresis (lag) is minimal, and there is a desire to avoid constant switching, the setpoints could be implement as follows:  For example, if a thermostat is set at 70° F, a Bang-Bang controller may be set to full output below 69° F, and keep running until the system reaches 71° F, then no output above 71° F, and until it falls below 69° F, whereupon the cycle repeats.  A system will use full positive control to increase the process variable, and nothing (or full negative control) to decrease it.  The process value usually oscillates about the setpoint in a sawtooth shaped pattern.&lt;br /&gt;
** '''Bang-Bang with Bias'''.  This adds a bias or ''maintenance'' element when ''in the window'' after the upper threshold has been reached, and before falling back to the lower threshold.  The bias is used instead of full off (or full negative output) - it is a partial output that is intended to increase the time spent between the lower and upper control points.  This is only applicable for systems with variable output - NOT applicable for control systems that can only be FULL ON or FULL OFF.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target).  Trapezoidal control can be achieved with by a formula for speed based on distance from the target setpoint.&lt;br /&gt;
::: NOTES - in the below equataions:&lt;br /&gt;
::::: LOWER_THRESHOLD and UPPER_THRESHOLD are both positive numbers.  If the problem is symmetrical, then they are equal (otherwise not necessarily)&lt;br /&gt;
::::: MAX_POSITIVE_OUTPUT is chosen for the problem at hand, it is always &amp;lt;= ''The Maximum System Output''&lt;br /&gt;
::::: MAX_NEGATIVE_OUTPUT is chosen for the problem at hand, it is always &amp;gt;= ''The Maximum System Negative Output'' (and sometimes this is zero)&lt;br /&gt;
&lt;br /&gt;
:: Error = SetPoint - ProcessVariable (actual) ''so positive means actual is below setpoint, negative means actual is above setpoint''&lt;br /&gt;
:: if (Error &amp;gt; LOWER_THRESHOLD) { Controller Output = MAX_POSITIVE_OUTPUT }&lt;br /&gt;
:: if ((-1 * Error) &amp;gt; UPPER_THRESHOLD) { Controller Output = MAX_NEGATIVE_OUTPUT }&lt;br /&gt;
:: if ((LOWER_THRESHOLD &amp;lt;= Error) and (Error &amp;lt;= &lt;br /&gt;
* '''PID''' (Not so simple. See below.)&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
Also, these sources are excellent&lt;br /&gt;
*[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
*[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
*[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=927</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=927"/>
		<updated>2021-12-09T19:09:49Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Simple Closed Loop Controllers ==&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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 or to account for hysteresis (lagging of output).  There are different ways to use the setpoints, but if hysteresis (lag) is minimal, and there is a desire to avoid constant switching, the setpoints could be implement as follows:  For example, if a thermostat is set at 70° F, a Bang-Bang controller may be set to full output below 69° F, and keep running until the system reaches 71° F, then no output above 71° F, and until it falls below 69° F, whereupon the cycle repeats.  A system will use full positive control to increase the process variable, and nothing (or full negative control) to decrease it.  The process value usually oscillates about the setpoint in a sawtooth shaped pattern.&lt;br /&gt;
** '''Bang-Bang with Bias'''.  This adds a bias or ''maintenance'' element when ''in the window'' after the upper threshold has been reached, and before falling back to the lower threshold.  The bias is used instead of full off (or full negative output) - it is a partial output that is intended to increase the time spent between the lower and upper control points.  This is only applicable for systems with variable output - NOT applicable for control systems that can only be FULL ON or FULL OFF.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (Not so simple. See below.)&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
Also, these sources are excellent&lt;br /&gt;
*[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
*[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
*[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=926</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=926"/>
		<updated>2021-12-09T19:01:33Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Close Loop Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Closed Loop Controller Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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 or to account for hysteresis (lagging of output).  There are different ways to use the setpoints, but if hysteresis (lag) is minimal, and there is a desire to avoid constant switching, the setpoints could be implement as follows:  For example, if a thermostat is set at 70° F, a Bang-Bang controller may be set to full output below 69° F, and keep running until the system reaches 71° F, then no output above 71° F, and until it falls below 69° F, whereupon the cycle repeats.  A system will use full positive control to increase the process variable, and nothing (or full negative control) to decrease it.  The process value usually oscillates about the setpoint in a sawtooth shaped pattern.&lt;br /&gt;
** '''Bang-Bang with Bias'''.  This adds a bias or ''maintenance'' element when ''in the window'' after the upper threshold has been reached, and before falling back to the lower threshold.  The bias is used instead of full off (or full negative output) - it is a partial output that is intended to increase the time spent between the lower and upper control points.  This is only applicable for systems with variable output - NOT applicable for control systems that can only be FULL ON or FULL OFF.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
Also, these sources are excellent&lt;br /&gt;
*[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
*[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
*[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Mentoring&amp;diff=925</id>
		<title>Mentoring</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Mentoring&amp;diff=925"/>
		<updated>2021-12-09T18:29:38Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://www.firstinspires.org/sites/default/files/uploads/resource_library/frc/game-and-season-info/2015-frc-mentoring-guide.pdf FIRST Mentoring Guide] (dead link)&lt;br /&gt;
&lt;br /&gt;
This has a lot of very subtle yet very crucial points in it that I (Dan Snyder) think we could all benefit from keeping in mind. I particularly enjoyed sections:&lt;br /&gt;
:{|&lt;br /&gt;
|5&lt;br /&gt;
|Coaching through Facilitation&lt;br /&gt;
|-&lt;br /&gt;
|8.3&lt;br /&gt;
|Transferring Ownership&lt;br /&gt;
|-&lt;br /&gt;
|9&lt;br /&gt;
|Facilitation Techniques&lt;br /&gt;
|-&lt;br /&gt;
|10&lt;br /&gt;
|Mentoring Tools&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
I'd recommend giving it a thorough read through, and maybe we could arrange some way to share our thoughts on it. I think it's a good start for tackling some of the topics brought up in the last meeting. A big takeaway for me is the emphasis on mentors communicating with students as equals and the trust it establishes between them. I think that's something we're missing with the students.&lt;br /&gt;
&lt;br /&gt;
I also think finding more mentors should be a very high priority on all of our lists, as some of the specifics in the guide are impossible to accomplish when we have between 0 and 1 mentors per subteam.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=924</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=924"/>
		<updated>2021-12-09T15:36:13Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=0&amp;gt;&lt;br /&gt;
'''&amp;lt;li&amp;gt; PID control works best if the underlying control mechanism does a decent job first &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
* 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. Consider the final step about using a ''setpoint sequence'' as part of this analysis.&lt;br /&gt;
'''&amp;lt;li&amp;gt; Get your ''bias'' right before tuning ''P'', ''I'', or ''D''. &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
'''&amp;lt;li&amp;gt; Tune ''P'' before ''I'' or ''D''. &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* ''P'' should generally be the largest input to correct the error, and should be tuned first.&lt;br /&gt;
*If you have to retune ''P'', you will likely need to retune ''I'' and then ''D''.&lt;br /&gt;
'''&amp;lt;li&amp;gt; Tune ''I'' before ''D''. &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* ''I'' should be used to help with variation and unexpected inputs that can be corrected over time.&lt;br /&gt;
* If you have oscillations, consider if windowing would be helpful, limiting the time error samples are included.  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).&lt;br /&gt;
* If you have to retune ''I'', you will likely need to retune ''D''.&lt;br /&gt;
'''&amp;lt;li&amp;gt; ''D'' often does not need to be used &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
:: Is your ''I'' value too high?&lt;br /&gt;
:: Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
* 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.&lt;br /&gt;
:* In order to filter, you need to keep track of several samples, so you can determine the slope using a longer time period, and also perhaps to average the samples.&lt;br /&gt;
:* For example, instead of creating the slope from only the 2 most recent 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
'''&amp;lt;li&amp;gt; When tuning, be mindful of what is available for corrections &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* Know that you cannot correct with MORE than 100% of system max positive output or MORE than 100% of system max ''negative'' output.&lt;br /&gt;
* Negative output is any output that causes the process variable to lessen&lt;br /&gt;
* Note that either the system max positive or system max negative output may be nil (zero).  (And max positive and max negative values chosen for corrections can be less than the extremes that the system allows.)&lt;br /&gt;
::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.&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;li&amp;gt; Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* Banding of the PID controller is a simple way to get maximum controllability around the setpoint.  The idea is that maximum positive output chosen is applied ''below'' (setpoint - LOWER_THRESHOLD), and maximum ''negative'' output chosen is applied ''above'' (setpoint + UPPER_THRESHOLD), and PID is used in-between the two thresholds.&lt;br /&gt;
:: '''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.&lt;br /&gt;
* 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 even have to be the same type.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;li&amp;gt; Consider guiding a PID controller through a planned and timed ''setpoint sequence'' &amp;lt;/li&amp;gt;'''&lt;br /&gt;
: For example, maybe you want to have a trapezoidal style ramp up and ramp down, but don't want a simple trapezoidal controller due to variability in the environment.  You can feed the PID controller setpoints that ramp up to a max over time, just like in trapezoidal control, but the PID controller will tend to keep it on track better, more closely following the velocity curve that you give it.&lt;br /&gt;
: Caution: if you are going to feed in lots of tiny step changes, you may want to make sure the banding is tight enough (and thereby strong enough) to accommodate the small changes in the correct amount of time.  It will self correct, however - if the setpoints get too far away from the actual value, the error will increase, thereby increasing the response.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]&lt;br /&gt;
:Control Guru offers '''a really good, solid basis for understanding PID Control''' and intro to PID loops by discussing Proportional only.  Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents.  Practical Process Control - Proven Methods and Best Practices for Automatic PID Control]&lt;br /&gt;
:'''Some of the most comprehensive documentation on PID Control''' on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ Control Gurus Non-linear Processes and Design Level Of Operation (DLO)] &lt;br /&gt;
: Good explanations for when and how to use DLOs.  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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
: Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
: Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller]&lt;br /&gt;
: PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=923</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=923"/>
		<updated>2021-12-09T15:32:13Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol start=0&amp;gt;&lt;br /&gt;
'''&amp;lt;li&amp;gt; PID control works best if the underlying control mechanism does a decent job first &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
* 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. Consider the final step about using a ''setpoint sequence'' as part of this analysis.&lt;br /&gt;
'''&amp;lt;li&amp;gt; Get your ''bias'' right before tuning ''P'', ''I'', or ''D''. &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
'''&amp;lt;li&amp;gt; Tune ''P'' before ''I'' or ''D''. &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* ''P'' should generally be the largest input to correct the error, and should be tuned first.&lt;br /&gt;
*If you have to retune ''P'', you will likely need to retune ''I'' and then ''D''.&lt;br /&gt;
'''&amp;lt;li&amp;gt; Tune ''I'' before ''D''. &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* ''I'' should be used to help with variation and unexpected inputs that can be corrected over time.&lt;br /&gt;
* If you have oscillations, consider if windowing would be helpful, limiting the time error samples are included.  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).&lt;br /&gt;
* If you have to retune ''I'', you will likely need to retune ''D''.&lt;br /&gt;
'''&amp;lt;li&amp;gt; ''D'' often does not need to be used &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
:: Is your ''I'' value too high?&lt;br /&gt;
:: Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
* 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.&lt;br /&gt;
:* In order to filter, you need to keep track of several samples, so you can determine the slope using a longer time period, and also perhaps to average the samples.&lt;br /&gt;
:* For example, instead of creating the slope from only the 2 most recent 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
'''&amp;lt;li&amp;gt; When tuning, be mindful of what is available for corrections &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* Know that you cannot correct with MORE than 100% of system max positive output or MORE than 100% of system max ''negative'' output.&lt;br /&gt;
* Negative output is any output that causes the process variable to lessen&lt;br /&gt;
* Note that either the system max positive or system max negative output may be nil (zero).  (And max positive and max negative values chosen for corrections can be less than the extremes that the system allows.)&lt;br /&gt;
::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.&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;li&amp;gt; Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response &amp;lt;/li&amp;gt;'''&lt;br /&gt;
* Banding of the PID controller is a simple way to get maximum controllability around the setpoint.  The idea is that maximum positive output chosen is applied ''below'' (setpoint - LOWER_THRESHOLD), and maximum ''negative'' output chosen is applied ''above'' (setpoint + UPPER_THRESHOLD), and PID is used in-between the two thresholds.&lt;br /&gt;
:: '''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.&lt;br /&gt;
* 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 even have to be the same type.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;li&amp;gt; Consider guiding a PID controller through a planned and timed ''setpoint sequence'' &amp;lt;/li&amp;gt;'''&lt;br /&gt;
: For example, maybe you want to have a trapezoidal style ramp up and ramp down, but don't want a simple trapezoidal controller due to variability in the environment.  You can feed the PID controller setpoints that ramp up to a max over time, just like in trapezoidal control, but the PID controller will tend to keep it on track better, more closely following the velocity curve that you give it.&lt;br /&gt;
: Caution: if you are going to feed in lots of tiny step changes, you may want to make sure the banding is tight enough (and thereby strong enough) to accommodate the small changes in the correct amount of time.  It will self correct, however - if the setpoints get too far away from the actual value, the error will increase, thereby increasing the response.&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]  Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=922</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=922"/>
		<updated>2021-12-09T14:30:45Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of system max positive output or MORE than 100% of system max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the system max positive or system max negative output may be nil (zero).  (And max positive and max negative values chosen for corrections can be less than the extremes that the system allows.)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* Banding of the PID controller is a simple way to get maximum controllability around the setpoint.  The idea is that maximum positive output chosen is applied ''below'' (setpoint - LOWER_THRESHOLD), and maximum ''negative'' output chosen is applied ''above'' (setpoint + UPPER_THRESHOLD), and PID is used in-between the two thresholds.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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 even have to be the same type.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
* Consider guiding a PID controller through a planned and timed ''setpoint sequence''.  For example, maybe you want to have a trapezoidal style ramp up and ramp down, but don't want a simple trapezoidal controller due to variability in the environment.  You can feed the PID controller setpoints that ramp up to a max over time, just like in trapezoidal control, but the PID controller will tend to keep it on track better, more closely following the velocity curve that you give it.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]  Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=921</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=921"/>
		<updated>2021-12-09T14:22:26Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of system max positive output or MORE than 100% of system max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the system max positive or system max negative output may be nil (zero).  (And max positive and max negative values chosen for corrections can be less than the extremes that the system allows.)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* Banding of the PID controller is a simple way to get maximum controllability around the setpoint.  The idea is that maximum positive output chosen is applied ''below'' (setpoint - LOWER_THRESHOLD), and maximum ''negative'' output chosen is applied ''above'' (setpoint + UPPER_THRESHOLD), and PID is used in-between the two thresholds.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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 even have to be the same type.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]  Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=920</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=920"/>
		<updated>2021-12-09T14:21:56Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of system max positive output or MORE than 100% of system max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the system max positive or system max negative output may be nil (zero).  (And max positive and max negative values chosen for corrections can be less than the extremes that the system allows.)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* Banding of the PID controller is a simple way to get maximum controllability around the setpoint.  The idea is that maximum positive output chosen is applied ''below'' (setpoint - LOWER_THRESHOLD), and maximum ''negative'' output chosen is applied ''above'' (setpoint + UPPER_THRESHOLD), and PID is used in-between the two thresholds.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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 type.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]  Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=919</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=919"/>
		<updated>2021-12-09T01:57:25Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of system max positive output or MORE than 100% of system max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the system max positive or system max negative output may be nil (zero).  (And max positive and max negative values chosen for corrections can be less than the extremes that the system allows.)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* Banding of the PID controller is a simple way to get maximum controllability around the setpoint.  The idea is that maximum positive output chosen is applied ''below'' (setpoint - LOWER_THRESHOLD), and maximum ''negative'' output chosen is applied ''above'' (setpoint + UPPER_THRESHOLD), and PID is used in-between the two thresholds.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]  Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=918</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=918"/>
		<updated>2021-12-09T01:46:54Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Close Loop Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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 or to account for hysteresis (lagging of output).  There are different ways to use the setpoints, but if hysteresis (lag) is minimal, and there is a desire to avoid constant switching, the setpoints could be implement as follows:  For example, if a thermostat is set at 70° F, a Bang-Bang controller may be set to full output below 69° F, and keep running until the system reaches 71° F, then no output above 71° F, and until it falls below 69° F, whereupon the cycle repeats.  A system will use full positive control to increase the process variable, and nothing (or full negative control) to decrease it.  The process value usually oscillates about the setpoint in a sawtooth shaped pattern.&lt;br /&gt;
** '''Bang-Bang with Bias'''.  This adds a bias or ''maintenance'' element when ''in the window'' after the upper threshold has been reached, and before falling back to the lower threshold.  The bias is used instead of full off (or full negative output) - it is a partial output that is intended to increase the time spent between the lower and upper control points.  This is only applicable for systems with variable output - NOT applicable for control systems that can only be FULL ON or FULL OFF.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
Also, these sources are excellent&lt;br /&gt;
*[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
*[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
*[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=917</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=917"/>
		<updated>2021-12-09T01:16:20Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]  Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: more tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=916</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=916"/>
		<updated>2021-12-09T01:15:23Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]  Pretty thorough introduction to Control Theory, with examples and more details.&lt;br /&gt;
* '''[https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=915</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=915"/>
		<updated>2021-12-09T01:06:33Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Intro */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
:'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=914</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=914"/>
		<updated>2021-12-09T01:04:27Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=913</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=913"/>
		<updated>2021-12-09T01:04:06Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=912</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=912"/>
		<updated>2021-12-09T01:03:27Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
* Use banding or multiple Design Levels of Operation (DLOs) to provide a stronger and more tunable response&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
:* 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.&lt;br /&gt;
:: 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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
* Banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=911</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=911"/>
		<updated>2021-12-09T00:41:44Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Cascading controllers? &lt;br /&gt;
* Info about the mentor PID Controller code when completed? &lt;br /&gt;
* Additional topics: tips for tuning (i.e. testing with drag), typical places to apply on the robot.&lt;br /&gt;
* Banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=910</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=910"/>
		<updated>2021-12-09T00:37:28Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=909</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=909"/>
		<updated>2021-12-09T00:36:05Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
::* 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.&lt;br /&gt;
::* For example, instead of comparing 2 samples 20 ms apart, keep track of the last 10 samples, spanning 200 ms.  Compare the first and last values, using the time span between them.  &lt;br /&gt;
::* Another good idea 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=908</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=908"/>
		<updated>2021-12-09T00:26:23Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=907</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=907"/>
		<updated>2021-12-09T00:25:55Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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 that 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=906</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=906"/>
		<updated>2021-12-09T00:21:00Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Resources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=905</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=905"/>
		<updated>2021-12-09T00:19:51Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
:* 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).&lt;br /&gt;
* ''D'' often does not need to be used  &lt;br /&gt;
:* Only use ''D'' values if you have issues with oscillation, and are confident that is the best approach after considering:&lt;br /&gt;
::* Is your ''I'' value too high?&lt;br /&gt;
::* Would windowing the ''I'' integration to only recent samples help?&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, windowing for I, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, keeping away from D unless necessary, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=904</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=904"/>
		<updated>2021-12-09T00:09:24Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* ''D'' often does not need to be used&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
* When tuning, be mindful of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, windowing for I, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, keeping away from D unless necessary, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=903</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=903"/>
		<updated>2021-12-09T00:00:03Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Tips and Guides */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* ''D'' often does not need to be used&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
* Be mindful when tuning, of what is available for corrections:&lt;br /&gt;
** Know that you cannot correct with MORE than 100% of max positive output or MORE than of 100% max ''negative'' output.&lt;br /&gt;
** Negative output is any output that causes the process variable to lessen&lt;br /&gt;
** Note that either the max positive or max negative output may be nil (zero)&lt;br /&gt;
:::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.&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, windowing for I, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, keeping away from D unless necessary, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=902</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=902"/>
		<updated>2021-12-08T22:45:19Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
== Tips and Guides ==&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior.&lt;br /&gt;
:* 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.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* 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''.&lt;br /&gt;
* ''D'' often does not need to be used&lt;br /&gt;
:* The Derivative component ''D'' is often subject to noise and can be difficult to control&lt;br /&gt;
:* 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.&lt;br /&gt;
* When tuning, know that you cannot correct with MORE than 100% of positive correction or MORE than of 100% negative correction.  Note that either positive or negative correction (which causes process variable to lessen) may be nil (zero).  For example, when heating, usually the best you want to do when its too hot is to turn off the heating element (not introduce cooling).  Similarly, when cooling, you frequently turn off cooling and do not want to introduce heating when it has gotten to cold.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers by descriptive text here. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, windowing for I, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, keeping away from D unless necessary, typical places to apply on the robot.&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=901</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=901"/>
		<updated>2021-12-08T22:23:13Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Intro */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edits To Do:&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''Some basic tips:'''&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior&lt;br /&gt;
:* 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&lt;br /&gt;
* Tune P before I or D&lt;br /&gt;
* Tune I before D&lt;br /&gt;
* D often does not need to be used&lt;br /&gt;
:* The Derivative component (D) is often subject to noise and can be difficult to control&lt;br /&gt;
:* You can perform noise filtering to get improvements at a cost of slightly delayed response for the D component&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, windowing for I, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, keeping away from D unless necessary, typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=900</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=900"/>
		<updated>2021-12-08T22:19:45Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* More on PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
Also, these sources are excellent&lt;br /&gt;
*[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
*[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
*[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=899</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=899"/>
		<updated>2021-12-08T22:16:37Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* More on PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
:[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
:[https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=898</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=898"/>
		<updated>2021-12-08T22:15:54Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
==== Description and Formula ====&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
:[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=897</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=897"/>
		<updated>2021-12-08T22:13:39Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
=== Description and Details ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
:[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=896</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=896"/>
		<updated>2021-12-08T22:12:23Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | See additional page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
:[https://controlguru.com/the-p-only-control-algorithm/ 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 K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
:[https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]  Pretty thorough introduction with examples, plus lots of concepts not presented above.&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=895</id>
		<title>PID Control</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=PID_Control&amp;diff=895"/>
		<updated>2021-12-08T22:00:10Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Intro */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Intro ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Before learning about PID Control, it is important to know where it fits in with other types of control options.&lt;br /&gt;
&lt;br /&gt;
'''See page: [[Intro to Control Theory and PID Loops]]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Edits To Do:&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
'''Links:'''&lt;br /&gt;
* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm]  A decent intro to Proportional Control, and a solid basis for understanding PID Control.  Careful - ControlGuru uses Kc instead of Kp, and Kc/Ti instead of Ki. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
'''Some basic tips:'''&lt;br /&gt;
&lt;br /&gt;
* PID control works best if the underlying control mechanism does a decent job first&lt;br /&gt;
:* That way, the correction constants can be tuned to correct disturbances, and not to control the system for its default behavior&lt;br /&gt;
:* 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&lt;br /&gt;
* Tune P before I or D&lt;br /&gt;
* Tune I before D&lt;br /&gt;
* D often does not need to be used&lt;br /&gt;
:* The Derivative component (D) is often subject to noise and can be difficult to control&lt;br /&gt;
:* You can perform noise filtering to get improvements at a cost of slightly delayed response for the D component&lt;br /&gt;
&lt;br /&gt;
'''To Do:'''&lt;br /&gt;
&lt;br /&gt;
* Cover use of the [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html PIDF controller] built into the Talon SRX controllers. &lt;br /&gt;
* Maybe include advanced treatment (noise filtering, especially for D, windowing for I, cascading controllers?) and possibly info about the mentor PID Controller code when completed. &lt;br /&gt;
* Additional topics: tips for tuning, keeping away from D unless necessary, typical places to apply on the robot.&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=894</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=894"/>
		<updated>2021-12-08T21:57:50Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
Edits To Do (on PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, including for the Talon SRX, plus practical concepts.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
* [https://controlguru.com/table-of-contents/ 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.&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
&lt;br /&gt;
== More Info on Process Control ==&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory]&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control Bang Bang Control]&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=893</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=893"/>
		<updated>2021-12-08T21:44:21Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
Edits To Do (on PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=892</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=892"/>
		<updated>2021-12-08T21:43:15Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* More Info */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
Edits To Do (on PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=891</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=891"/>
		<updated>2021-12-08T20:56:43Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  '''This can be the beginning of ''oscillation'''''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
Edits To Do (on PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=890</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=890"/>
		<updated>2021-12-08T20:43:08Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Fixing the Error'''&lt;br /&gt;
Note that all of the components (aside from the CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;) are to deal with ''the Error'', or difference between the setpoint and the process variable.&lt;br /&gt;
* P deals directly with Error: '''e(t) is the error SP-PV at the current time (t)'''&lt;br /&gt;
* I deals with the summation of the Error over time: '''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;) is the integral or summation of the errors from time ''0'' to time ''t'''''&lt;br /&gt;
* D deals with the slope of the Error over time: '''change in Error / change in time''', computed as (e&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - e&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;) / (time&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt; - time&amp;lt;sub&amp;gt;t-1&amp;lt;/sub&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  This can be the beginning of ''oscillation''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=889</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=889"/>
		<updated>2021-12-08T20:25:57Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - i.e. there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  This can be the beginning of ''oscillation''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=888</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=888"/>
		<updated>2021-12-08T20:24:38Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** '''Zero Bias?''' You can get away without a bias if your process variable is neutral - there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  This can be the beginning of ''oscillation''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  The ''D'' portion is the ''Derivative'' component, and is often not even used.  It looks at how the error changes over time - its slope.  The idea is that if the error is changing too rapidly, (especially close to the setpoint) the system will likely cross the setpoint rapidly and begin ''oscillating''.  The goal is to have a rapidly changing system ''damped'' so it does not swing too wildly - therefore some of the controller output correction is reduced if the process variable (and consequently ''error'') is changing too quickly.  '''The Derivative element is based on the magnitude and direction of the slope of the error over time.'''  The greater the slope, the greater the cancellation of correction.  (Be mindful of the signs of the slope).&lt;br /&gt;
&lt;br /&gt;
*'''D Component Issues and Solutions'''&lt;br /&gt;
:'''Sampling Noise'''  The ''D'' component is calculated as a change in error divided by a change in time.  If the time slice is small, these are very small changes.  Small errors in sampling the process variable (or ''noise'') can contribute to significant errors in the calculated value of the slope, causes errors not just in magnitude, but even in direction.  Because of this, simplistic approaches using only the last time slice to calculate the slope, can result in poor performance when incorporating ''D''.  Many systems simply do not use D.&lt;br /&gt;
:A more sophisticated solution involves averaging recent slopes or calculating the slope over a longer period of time.  This is usually a suitable approach - the slope is often not expected to change rapidly, and any lag introduced in the slope computation because it is now over a longer time period, is usually of little significance.&lt;br /&gt;
:'''Slope versus Error'''  A steep slope for error over time is a greater issue when the process variable is close to the actual setpoint (error near 0).  Rapid changes far from the setpoint are actually desirable, but not when the process variable approaches the setpoint.  The D component, in its form currently described, does not account for that.  A more sophisticated approach might be to ''increase the effect'' of the D component as the process variable gets ''closer to the setpoint'', i.e. ''as the error tends towards zero''.&lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=887</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=887"/>
		<updated>2021-12-08T19:45:52Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** Zero Bias. You can get away without a bias if your process variable is neutral - there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''K&amp;lt;sub&amp;gt;P&amp;lt;/sub&amp;gt;, K&amp;lt;sub&amp;gt;I&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;D&amp;lt;/sub&amp;gt; Constants'''  These constants are multipliers of each of their respective components, and affect how much or how little they participate in the controller output.  Typically, the P component is largest.  Each of these constants needs to be determined, usually via initial estimates and some testing.&lt;br /&gt;
*'''P Component''' The ''P'' portion 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.&lt;br /&gt;
*'''I Component''' The ''I'' portion is the ''Integral'' component - it integrates (or ''sums'') the error terms over time.  This is particularly useful if the standard proportional error correction cannot sufficiently accommodate an external force on the process variable.  '''The Integral element is based on the magnitude and direction of the accumulated error over time.'''  The more accumulated error, the greater the correction.&lt;br /&gt;
:: For example, if a ship's autopilot is trying to maintain a heading (direction) and a side wind is pushing it off course, proportional control will attempt to bring it back, but if the wind is strong enough, it will never quite make it.  Over time, the ''accumulated error'' can be used to as a component to affect the control output so the correction is stronger, thereby overcoming the wind.&lt;br /&gt;
: The downside, is that the accumulated error doesn't disappear once the correction is strong enough, and can keep the correction going even past the setpoint.  This can be the beginning of ''oscillation''.  Advanced techniques, such as ''windowing'' the accumulation of error, can help to mitigate some of this.&lt;br /&gt;
&lt;br /&gt;
*'''D Component'''  TBD&lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=886</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=886"/>
		<updated>2021-12-08T17:41:59Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** Zero Bias. You can get away without a bias if your process variable is neutral - there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look up values in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''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.&lt;br /&gt;
&lt;br /&gt;
* TBD more explanation about I, and D, and why and when each is used&lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=885</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=885"/>
		<updated>2021-12-08T17:40:42Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** Zero Bias. You can get away without a bias if your process variable is neutral - there is no inherent drift regardless of setpoint, and the necessary control output to reach the setpoint is independent on the setpoint value, only on the error (distance from setpoint).&lt;br /&gt;
::: 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 from the setpoint).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  Once determined, there are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look values up in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''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.&lt;br /&gt;
&lt;br /&gt;
* TBD more explanation about I, and D, and why and when each is used&lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=884</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=884"/>
		<updated>2021-12-08T17:35:12Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
'''More Details'''&lt;br /&gt;
* '''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' 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.&lt;br /&gt;
** 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).&lt;br /&gt;
* '''Setting CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' Typically, bias is determined experimentally.  There are several ways to set the bias, including:&lt;br /&gt;
** Statically - with a fixed value that is the same always&lt;br /&gt;
** Manual input - keep it at a user entered position (value)&lt;br /&gt;
** Functionally - set it with an equation&lt;br /&gt;
** Lookup table - look values up in a table, and use interpolation when in-between&lt;br /&gt;
&lt;br /&gt;
*'''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.&lt;br /&gt;
&lt;br /&gt;
* TBD more explanation about I, and D, and why and when each is used&lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=883</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=883"/>
		<updated>2021-12-08T16:56:03Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* importance of CO bias.  Setting bias statically, or setting it with an equation or lookup table with interpolation. &lt;br /&gt;
* more explanation about P, I, and D, and why and when each is used&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=882</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=882"/>
		<updated>2021-12-08T16:55:21Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* Robotic Control Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Open Loop - No Feedback ===&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal''' (Note - trapezoidal can be either open loop or closed loop depending on how it's implemented.)&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
=== Closed Loop - Uses Feedback ===&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
==== Close Loop Examples ====&lt;br /&gt;
* '''[https://en.wikipedia.org/wiki/Bang%E2%80%93bang_control 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.&lt;br /&gt;
** '''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.&lt;br /&gt;
* '''Trapezoidal''', when based on error (distance from target)&lt;br /&gt;
* '''PID''' (See below.)&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* importance of CO bias.  Setting bias statically, or setting it with an equation or lookup table with interpolation. &lt;br /&gt;
* more explanation about P, I, and D, and why and when each is used&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
* Bang Bang controllers, Bang Bang with bias&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
	<entry>
		<id>https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=881</id>
		<title>Intro to Control Theory and PID Loops</title>
		<link rel="alternate" type="text/html" href="https://mort11.com/mentor.wiki/index.php?title=Intro_to_Control_Theory_and_PID_Loops&amp;diff=881"/>
		<updated>2021-12-08T16:30:34Z</updated>

		<summary type="html">&lt;p&gt;Dsteinmark: /* More on PID Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Control Examples ==&lt;br /&gt;
* Car cruise control&lt;br /&gt;
* Thermostat for Heat or Air Conditioning&lt;br /&gt;
* Navigational control for maintaining a ships heading&lt;br /&gt;
* Autopilot for an aircraft&lt;br /&gt;
* Keeping a Tesla in its own lane&lt;br /&gt;
&lt;br /&gt;
== Robotic Control Examples ==&lt;br /&gt;
&lt;br /&gt;
'''Simple'''&lt;br /&gt;
* Set a motor speed by setting a voltage to be supplied immediately (MAX_SPEED)&lt;br /&gt;
* Stop a motor from running by setting the voltage to zero immediately&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Trapezoidal'''&lt;br /&gt;
* Ramp the motor speed up to the set voltage&lt;br /&gt;
* Stop a motor from running by ramping the voltage down to zero.&lt;br /&gt;
&lt;br /&gt;
:: Disadvantages?&lt;br /&gt;
:: Advantages?&lt;br /&gt;
&lt;br /&gt;
'''Feedback/Closed Loop'''&lt;br /&gt;
* Keep a wheel spinning at a constant velocity, despite varying resistance slowing it down&lt;br /&gt;
* Maintain a constant speed up a ramp of varying inclination&lt;br /&gt;
* Rotate toward a target at a variable rate.  The rate varies such that it rotates faster when it has more to turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See image: [https://www.designnews.com/sites/designnews.com/files/Fig.-1_Trap_Commut_Seq_Program_Jacques-v2.jpg Stepped output and ramped output]&lt;br /&gt;
&lt;br /&gt;
== Control Theory Intro ==&lt;br /&gt;
&lt;br /&gt;
* [https://en.wikipedia.org/wiki/Control_theory Wikipedia Control Theory] See Intro, Open-loop and closed-loop (feedback) control, and Other examples, where much of the following is cribbed from.&lt;br /&gt;
&lt;br /&gt;
'''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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;final control element&amp;quot;, such as a control valve.&lt;br /&gt;
&lt;br /&gt;
=== Open Loop and Closed Loop ===&lt;br /&gt;
Fundamentally, there are two types of control loops: open loop control and closed loop (feedback) control.&lt;br /&gt;
&lt;br /&gt;
In open loop control, the control action from the controller is independent of the &amp;quot;process output&amp;quot; (or &amp;quot;controlled process variable&amp;quot; - 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.&lt;br /&gt;
&lt;br /&gt;
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 &amp;quot;Reference input&amp;quot; or  &amp;quot;set point&amp;quot;. For this reason, closed loop controllers are also called feedback controllers.&lt;br /&gt;
&lt;br /&gt;
The definition of a closed loop control system according to the British Standard Institution is &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Likewise; &amp;quot;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.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Other Examples (straight from [https://en.wikipedia.org/wiki/Control_theory#Other_examples wikipedia])  ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Using Multiple (Different) Controls for Different Portions of a Non Linear Process ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
* [https://controlguru.com/design-and-tuning-recipe-must-consider-nonlinear-process-behavior/ 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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== PID Loops ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
PID Controllers have ''up to'' 3 components:&lt;br /&gt;
* '''P, the Proportional component'''&lt;br /&gt;
* '''I, the Integral component'''&lt;br /&gt;
* '''D, the Derivative component'''&lt;br /&gt;
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'''.&lt;br /&gt;
&lt;br /&gt;
The basic form for the controller output is:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + P + I + D, &lt;br /&gt;
or more specifically:&lt;br /&gt;
:CO = CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt; + '''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;'''∙e(t) + '''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;'''∙Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)dt) + '''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;'''∙Slope(e(t))&lt;br /&gt;
whereby:&lt;br /&gt;
:'''CO''' is the controller output&lt;br /&gt;
:'''CO&amp;lt;sub&amp;gt;bias&amp;lt;/sub&amp;gt;''' is the null value for the controller&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''P'', the Proportional element&lt;br /&gt;
:'''e(t)''' is the error SP-PV at the current time (t)&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''I'', the Integral element&lt;br /&gt;
:'''Sum(e(t&amp;lt;sub&amp;gt;0&amp;lt;/sub&amp;gt;..t&amp;lt;sub&amp;gt;t&amp;lt;/sub&amp;gt;)''' is the integral or summation of the errors from time ''0'' to time ''t''&lt;br /&gt;
:'''dt''' is the delta time from the first time integral element to the last time integral element&lt;br /&gt;
:'''K&amp;lt;sub&amp;gt;d&amp;lt;/sub&amp;gt;''' is the tuning constant multiplier for ''D'', the Derivative element&lt;br /&gt;
:'''Slope(e(t))''' is the slope of the error curve at time ''t''&lt;br /&gt;
&lt;br /&gt;
==== More on PID Loops ====&lt;br /&gt;
:'''[[PID Control | Mentor wiki page for PID Control]].'''  Contains more links and guides, plus practical lessons.&lt;br /&gt;
&lt;br /&gt;
:Control Guru offers a really good, solid basis for understanding PID Control and intro to PID loops by discussing Proportional only. &lt;br /&gt;
::* [https://controlguru.com/the-p-only-control-algorithm/ Control Gurus - The P-Only Control Algorithm] Careful - ControlGuru uses K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;p&amp;lt;/sub&amp;gt;, and K&amp;lt;sub&amp;gt;c&amp;lt;/sub&amp;gt;/T&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt; instead of K&amp;lt;sub&amp;gt;i&amp;lt;/sub&amp;gt;. Essentially works the same. &lt;br /&gt;
&lt;br /&gt;
Edits To do (some goes in PID page):&lt;br /&gt;
* importance of CO bias.  Setting bias statically, or setting it with an equation or lookup table with interpolation. &lt;br /&gt;
* more explanation about P, I, and D, and why and when each is used&lt;br /&gt;
* banding the PID control (I.e) multiple DLOs) to create a stronger response&lt;br /&gt;
* emphasis on error&lt;br /&gt;
* oscillations&lt;br /&gt;
* can’t correct with &amp;gt; 100% effort&lt;br /&gt;
&lt;br /&gt;
* Bang Bang controllers, Bang Bang with bias&lt;br /&gt;
&lt;br /&gt;
=== More Info ===&lt;br /&gt;
* [https://en.wikipedia.org/wiki/PID_controller Wikipedia PID Controller]&lt;br /&gt;
* [https://controlguru.com/table-of-contents/ Control Gurus - Table of Contents]  Some of the most comprehensive documentation on PID Control on the net.  Includes beginner topics and advanced topics.&lt;br /&gt;
* [https://phoenix-documentation.readthedocs.io/en/latest/ch16_ClosedLoop.html Talon SRX PIDF controller] PID Control built into the Talon SRX controllers&lt;br /&gt;
* [https://www.chiefdelphi.com/uploads/default/original/3X/4/3/43b05762b40ee9dd6972d8d328599268a5585a31.pdf ''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.&lt;/div&gt;</summary>
		<author><name>Dsteinmark</name></author>
	</entry>
</feed>