<br> [MAS.865](../../index.html) > [Control](../../Control) > Heuristic Control - PID #Heuristic Control ##PID P - Proportional Control: U proportional to distance to target I - Integral Control: U proportional to integrated distance to target over time (helps correct for nonlinear behavior) D - Derivative Control: U proportional to derivative of distance to target w.r.t. time (smooths) Output actuation = Kp P + Ki I + Kd D Kp, Ki, and Kd are all gains that need to be chosen by users. [Interactive Applet](https://sites.google.com/site/fpgaandco/pid) Variants (in increasing popularity): P controller PI controller PD controller PID controller It is very suitable for when you don't have a model of the system. ##Tweaking the Gains [Main method - Ziegler-Nichols Method](https://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_method) Basic idea: 1. Set all gains to 0 2. Tweak Kp until it is stable - sans some oscillations 3. Then, set Ki and Kd based off a function of that oscillation period Closed form transfer function. [More info here](http://www.mstarlabs.com/control/znrule.html) [OCW course here](https://ocw.mit.edu/courses/mechanical-engineering/2-04a-systems-and-controls-spring-2013/) ##Cascade Control It is possible to connect multiple PID controllers in cascade, where the input to one is the output of the previous one and the data of a different sensor. This can cause the system to react faster and better ignore disturbances if the inner PID is measuring a faster changing process that affects the outer controller. The main disadvantages are the extra complexity of the system as well as needing extra measurements. A complete example can be seen [here](http://blog.opticontrols.com/archives/105) or in [mathworks](https://www.mathworks.com/help/control/examples/designing-cascade-control-system-with-pi-controllers.html) ##Discrete Time The open loop PID controller in continuous time is $$ u(t) = K_p e(t) + \frac{K_p}{T_i}\int_0^t e \text{ d} \tau + +K_p T_d \dot{e}(t) $$ It can be approximated using a discrete time; however this can cause the system to become unstable depending on the sampling rate. This becomes more obviously when the derivative term is increased. An small amount of noise in the input can result in a large output for a whole time step, which will increase the speed of the system and result in oscillations. One could use a low pass filter to help solve this problem. > As a rule of thumb (this can be confirmed from > a frequency response based analysis), the stability reduction is small and > tolerable if the time delay is less than one tenth of the response-time of the > control system as it would have been with a continuous-time controller or a > controller having very small sampling time. More details about this can be seen on the freeware book [Discrete-time signals and systems, By Finn Haugen](http://techteach.no/publications/discretetime_signals_systems/discrete.pdf), session 8.3.3.