Phase and Gain Margins by Bode Plot for 3 Real Poles

Cuthbert Nyack
This applet shows the Bode plot(red, yellow) step response(green) and phase and gain margins(cyan, pink) of a 3 real poles system.
The gain margin is the difference between the gain and 0dB at the frequency where the phase is -180°. The phase margin is the difference between the phase and -180° at the frequency where the gain is 0dB.

The examples below illustrate the relation between the phase and gain margins and the transient response.
eg parameters (8.0, 1.0, 1.0, 1.0, 0.7, 1.0, 1.73) shows the gain and phase margins to be ~0(within the resolution of the applet). The system is oscillatory with an angular frequency of 1.73.

The case (9.0, 1.0, 1.0, 1.0, 1.0, 3.0, 1.8) show an unstable case with -ve gain and phase margins.

Parameters (7.0, 1.0, 1.0, 1.0, 1.0, 3.0, 1.66) show a case with +ve gain and phase margins.

(3.3, 0.34, 1.0, 1.0, 1.0, 3.0, 1.6), phase margin ~45°, gain margin ~10dB.
(2.4, 0.34, 0.2, 2.4, 1.0, 3.0, 1.5), phase margin ~90°, gain margin ~20dB.
(5.8, 0.24, 8.2, 6.4, 1.0, 7.0, 0.32), phase margin ~45°, gain margin ~20dB.
(10.0, 0.2, 0.2, 5.6, 1.0, 1.0, 1.62), phase margin ~60°, gain margin ~15dB.

The applet below show how the phase and gain margin can be deduced from the the magnitude vs phase plot.

Gif image below shows how applet should appear. 