Simulation of Feedback Control System with Controller and Second-Order Plant

Initializing live version
Download to Desktop

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.

This Demonstration simulates a second-order linear system represented as a mass-spring-damper and analyzes the effect of adding a controller on the step response of the overall system in a closed loop. You can select one of four types of controller: P, PI, PD, or PID. You can simulate the plant with and without the controller to see the effect on the step response. Bode and Nyquist plots of the open-loop transfer functions are plotted and the gain and phase margins are shown, as well as the locations of the closed-loop poles. You can change the simulation time and speed as well as the controller parameters using sliders.

Contributed by: Nasser M. Abbasi (May 2012)
Open content licensed under CC BY-NC-SA



A feedback control system is simulated using a controller and a second-order plant. The controller operation can be proportional, proportional-integral, proportional-derivative, or proportional-integral-derivative. Mathematica 8 control system functions are used in all the computation.

To determine relative stability of the closed loop, the gain margin in db and phase margin in degrees of the open loop are shown above the Bode plots. For the case of multiple crossover frequencies, the highest frequency is used. The plant and closed-loop transfer functions are shown above the step response plot. For analysis of the absolute stability, the closed-loop poles' locations on the -plane as well as their coordinates are displayed below the plot in the left side. The closed loop is unstable when the real part of any pole is positive. SI units are used throughout.

The plant transfer function is given by , where is the DC gain, is the damping ratio, is the natural frequency, is the Laplace transform of the output of the plant, and is the Laplace transform of the input to the plant. The controller used in the parallel form is given by , where , , and are the proportional, derivative, and integral parameters, respectively. The open-loop transfer function is and the closed-loop transfer function is .


[1] J. J. D'Azzo and C. H. Houpis, Linear Control System Analysis & Design, 3rd ed., New York: McGraw–Hill, 1988.

[2] R. C. Dorf and R. H. Bishop, Modern Control Systems, 11th ed., Englewood Cliffs, NJ: Prentice–Hall, 2007.

[3] K. Ogata, System Dynamics, 4th ed., Englewood Cliffs, NJ: Prentice–Hall, 2003.

Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.