Gary J. McGrath
November 27, 1995 The differential equation of the PID compensator is:
(equation 1)
Where u(t) is the input and x(t) is the output. The gain constants ( Kp, Ki, and Kid ) are to be determined. Taking the Laplace transform, we have the continuous transfer function in the frequency domain:
(equation 2)
To implement equation 1 digitally, we will need to perform numerical integration and differentiation. Euler's method will be used for the integration. The integral is equal to the sum of rectangular areas under the curve, or:
m((k + 1)T) = m(k T) + T u((k + 1)T) (equation 3)
Where m(t) is the integral of u(t). The z-transform of this equation is:
z(M(z) - m(0)) = M(z) + T z(U(z) - u(0)) (equation 4)
Ignoring initial conditions, the transfer function of this integrator is:
M(z) / U(z) = (T z) / (z-1) (equation 5)
The derivative is performed by backward differences, or:
m((k + 1)T) = [u((k + 1)T) - u(k T)] / T (equation 6)
Where m(t) is the derivative of u(t). The z-transform of this derivative is the transfer function:
M(z) / E(z) = (z-1) / (T z) (equation 7)
We can now implement the PID compensator of equation 1 using the integral and derivative transfer functions in the z-domain ( equations 5 and 7).
(equation 8)
The difference equations are written using the integral as one state, and the output of the PID compensator as the other state. Using the difference equations for the integral and derivative (equations 4 and 6), the difference equations of the PID compensator are:
(equations 9)
The states of the system are defined as x1 and x2. x1 is also the output of the system.