

where Ts is the sampling time of discrete-time system.

where Kp,Ki and Kd are the proportional, integral and derivative gains respectively. To map to the z-plane we substitute the bilinear relation into the above PID transfer function, so the discrete-time PID controller becomes.


% Discrete PID Controller
% Ts = sampling time
num = [Kp+(Ki*Ts/2)+((2*Kd)/Ts)
(Ki*Ts)-(4*(Kd/Ts))
-Kp+(Ki*Ts/2)+((2*Kd)/Ts)]';
den = [1 0 -1];
pid = tf(num,den,Ts);
In addition, the c2d command in MATLAB can convert
continuous-time to discrete-time PID controller without going through an
algebraic substitution or mapping. This command requires a system
representation of a continuous system, sampling time and the method that
will be used. For the bilinear approximation, the "tustin" method
should be specified.
For example, the c2d command can be
used as follows.
% Discrete PID Controller using c2dm command % Ts = sampling time pid_c = tf([Kd Kp Ki],[1 0]); pid = c2d(pid_c,Ts,'tustin');