LagLead Compensator Second Order Type 1, Step Response and Bode Plot

Cuthbert Nyack
The applets here show the step response and Bode plots of a type 1 second order system with LagLead Compensation.
The continuous system is discretised by the bilinear transform to get D(z) and a ZOH transformation of the system transfer function.

eg parameters (20.0, 0.5, 1.5, 8.0, 1.0, 0.01, 0.1) show the continuous and sampled response of the uncompensated system. The phase margin of the continuous system is 17.96° and for the sampled system, it is 16.19°. The sampling frequency is 628.3rad/s. Comparing the phase curves show that the continuous system is always stable while the sampled system phase becomes less than -180° at ~15rad/s.
Changing the parameters to (21.3, 0.5, 1.5, 8.0, 1.0, 0.1, 0.7) show oscillation of the sampled uncompensated system with the oscillation frequency approximately 0.1 of the sampling frequency.

eg parameters (20.0, 0.5, 1.5, 8.0, 10.0, 0.07, 0.7) show the response with laglead compensation and reasonable agreement between the continuous and discrete systems. The phase margin of the continuous system is 69.39° and for the sampled system, it is 60.00°. Comparing the cyan curve for the sampled system with the green curve for the continuous system show the phase of the sampled system becoming less than -180° at ~ 15rad/s while the sampling frequency is 89.75rad/s.

eg parameters (20.0, 0.5, 1.5, 8.0, 10.0, 0.4, 3.0). Significant damped oscillation on the discrete response. The phase margin of the continuous system is 69.39° and for the sampled system, it is 11.89°. The phase of the sampled system becomes less than -180° at ~ 5rad/s with the sampling frequency at 15.7rad/s. The phase of the sampled compensator begins to deviate from that of the continuous one at ~ 3rad/s. The pole of the Lead part of the LagLead compensator is at 6.67rad/s.

eg parameters (20.0, 0.5, 1.5, 8.0, 10.0, 0.51, 3.0). Discrete system oscillatory at ~ 4.5rad/s with the sampling frequency at 12.31rad/s.
eg parameters (20.0, 0.5, 1.5, 8.0, 10.0, 0.53, 5.0). Discrete system unstable with growing oscillation.

Applet below show the closed loop frequency response on a linear plot.

Applet below show the magnitude and phase of the continuous and sampled compensator transfer function.

Gif images below show how the applets should appear.   