Simulation
Load scenario:
How to run the simulation  3 steps
Control System
The purpose of control system for a plan is to improve the following characteristics of the system
There are various types of compensators that achieve these objectives in a feedback control system. Two common types of compensators are lead and lag compensators. Both the compensators introduce a pole and a zero the system. The transfer function of the compensator takes the form of:
In this article the lead and lag compensators will be briefly discussed.
Lag Compensation
The compensator can be defined as a lag compensator if a > p. In a lag compensator, the low frequency gain is increased and this helps reduce the steady state error. The typical bode plot of a lag compensator is as shown below for an example compensator of:
It can be observed that at low frequencies the compensator has a high gain and the magnitude at high frequencies is insignificant. Thus, this type of compensator reduces the steady state error without affecting the high frequency transients.
Key fact about the compensator: The lag/lead compensator provides maximum lag near the center frequency but this corner (= center) frequency needs to be placed below the new gain crossover frequency. The corner frequency is sqrt(a * p).
The main motivation of the lag compensator is to improve the steady state error without affecting the shape of the root locus of the uncompensated system.
A special case of the lag compensator is the PI controller when the pole is place at the zero (i.e P=0):
For more details on PI compensation schemes, please see this article: PI Controller : Theory + Demo.
Lead Compensation
The compensator can be defined as a lag compensator if p > a. The compensator improves the transient performance of the system as it affects the high frequency components significantly. The typical bode plot of a lead compensator is as shown below for an example compensator of:
The bode plot indicates that the gain margin of the plant would be unaffected if a lead compensator is used but the phase margin would be improved. However, it is important to note that in a lead compensator as high frequency response has a high gain, noise at high frequency would also be amplified and this is an issue in a practical system and appropriate care in the sensing system must be adopted.
Add the compensator so that the closed loop transfer function has a pair of complex poles with the desired damping ratio and natural frequency.
The complex poles dominate the system response
In the design process it is key to go through step 3 several times to ensure proper overshoot. If required overshoot is not achieved after several trails, the damping ratio and resonant frequency would need adjustment.
A special case of the lead compensator is the PD controller when the zero is place at the zero (i.e A=0):
Summary
Lag compensator  Lead compensator 



Tausif Husain
Version of this article is 11/2/2017.
Further Reading
In MatLab, DSPs, and FPGAs.
.
The fundamentals of signal flow.
Introduction to dynamic systems.
It is all sine waves.