The PID controller (an abbreviation of Proportional Integral Differential) is the most widely applied feedback control formula/algorithm. It is applied in a huge variety of 'things' to automate them, such as planes, drones, cars, coffeemakers, wind turbines, furnaces, and manufacturing units. It is fair to say that the PID controller is the work horse for automation. The PID formula has three parameters that must be set or tuned in the right way and that is what is the PID Tuner is used for. In this article we will explain a suitable way to program a PID controller yourself (if you do not want to use standard libaries), and we present some background on different tuning methods.

The PID Controller has three parameters that should be tuned. The proportional term (Kp), the integral term (Ti) and the differential term (Td). The figure below shows the effects of varying Kp and Ti.

The equations below present a PID formula that can be programmed in a control computer (note that we define the output of the PID controller as MV or u, and the controlled variable as PV):

\( \Delta u_k = K_p \left( e_k - e_{k-1} + \frac{T_s}{T_i}e_k + \frac{T_d}{T_s} \left( e_k - 2 e_{k-1} + e_{k-2} \right) \right) \)\( u_k = u_{k-1} + \Delta u_k \)

With:

\( k = \) discrete time (0,1,2,..)

\( u_k = MV = \) Manipulated Variable at time k

\( e_k = PV-SP = \) Error at time k

\( SP = \) Setpoint at time k

\( PV = \) Process Variable at time k

\( K_p = \) Proportional Gain

\( T_i = \) Integraltime

\( T_d = \) Derivative time

\( T_s = \) Sample time

Example code for the discrete PID controller implemented in Matlab can be seen below. Also, you can directly download this code:

- DOWNLOAD (Matlab)

Various methods exist to tune a PID Controller:

- Open loop method, combined with model based (= method used in PID Tuner)
- Closed loop Ziegler and Nichols

- Freeze the PID output
- Make a step change on the PID output (MV) in order of 3-10%. Step should be sufficiently big to see its effect on the controlled process variable (PV)
- Log response of MV and PV and fit the model parameters of a First Order Time Delay model to this response.
- Use model based tuning method, such as Table 1 for single PID loops

Table 1: PID Open Loop Tuning Rules based on [1]

Kp | Ti | Td | |
---|---|---|---|

P | -- | -- | -- |

PI | 0.35*Tp / (Tdt * K) | min( 8*Tdt, Tp) | -- |

PID | 0.5*Tp / (Tdt*K) | min( 8*Tdt , Tp ) | 0.5*Tdt |

- Switch on proportional control only, i.e. choose:
- Ti = ‘maximum value’
- Td = 0 (unless you know which value to choose here)
- Increase proportional gain until loop oscillations hardly dampen.
- Then note:
- Ultimate gain (KU ) = proportional gain
- To = period of oscillation
- Apply settings from Table 2

Image: Period of oscillation

Table 2: Closed Loop PI Tuning Rules (Tuning rules for PID are not reliable to our opinion).

Kp | Ti | Td | |
---|---|---|---|

PI | 0.45*Ku | T0/1.2 | 0 |

if ( u < 100 OR u > 0 ) du = 0 end

du = min( du, 3) du = mmax( du, -3)

If |e| < 1 , then delta Uk = 0

- Tip 1. Be careful with the D action: it amplifies noise from the sensor signal.
- Tip 2. Oscillations in process variables can have three causes, and it's essential to know which one applies in order to reduce the oscillations.

- External disturbance

- Instability in loop resulting in limit cycle

- Stick-slip-like phenomena in valves or other actuators - For more tips, check out
__this link (Tuning tips)__and subscribe to our newsletter

Having tuned many PID controllers for companies in the field, we noticed our jobs become repetitive. That's when we decided that we needed a software tool to help us speed-up and streamline this process. The result of this is the PID Tuner - a 'toolbox' for our control engineers. You can try out a demo of the PID Tuner for free.

If you are interested in the help of one of our control engineers, or if you have any questions, send us a mail at info@dotxcontrol.com