Algorithm Background

Unlike simple control algorithms, the PID controller is capable of manipulating the process inputs based on the history and rate of change of the signal. This gives a more accurate and stable control method.

Figure 2 shows the PID controller schematics, where Tp, Ti, and Td denotes the time constants of the proportional, integral, and derivative terms respectively. The transfer function of this system is:

ue(s)=H(s)=Kp(1+1Tis+Tds)

This gives u with respect to e in the time domain:

u(t)=Kp(e(t)+1Ti0te(σ)σ+Tdde(t)dt)

Approximating the integral and the derivative terms to get the discrete form, using:

0te(σ)σTk=0ne(k) de(t)dte(n)e(n1)T t=nT

Where n is the discrete step at time t.

This gives the controller:

u(n)=Kpe(n)+Kik=0ne(k)+Kd(e(n)e(n1))

Where:

Ki=KpTTi Kd=KpTdT

To avoid that changes in the desired process value makes any unwanted rapid changes in the control input, the controller is improved by basing the derivative term on the process value only:

u(n)=Kpe(n)+Kik=0ne(k)+Kd(y(n)y(n1))