You are on page 1of 14

# Control Systems

Compensation
and PID Compensation with
MATLAB®.
13 December 2005

Christian Winter
University of North Texas
College of Engineering
ELET 4720 - Control Systems
Control Systems Compensation 2

Abstract
Compensation in control systems is necessary if a given system does not conform to

set design criteria. System designers can improve transient response characteristics, such as

rise time, settling time, and overshoot, as well as steady state error. This paper outlines the

steps necessary to utilize MATLAB® to create compensators. Using a simple control system,

I will explain the steps to create lead and lag compensation and the implementation of a

## Proportional-Integral-Derivative (PID) controller.

Introduction
Compensators are used to alter the response of a control system in order to

accommodate set design criteria. By introducing additional poles and/or zeros to a system

the response of the system will change significantly. One must use proper design procedures

in order to ensure that the added poles and/or zeros have the desired effect the designer is

seeking.

## This paper discusses the use of MATLAB® to implement three types of

compensators -- lead, lag, and PID. Lead compensation alters the transient response of

systems. This includes overshoot, rise time (TR), settling time (TS), and peak time (TP). Lag

compensation alters steady-state error of systems. PID controllers (compensators) are used

## to alter transient response and steady-state error simultaneously. To achieve PID

compensation, an active proportional derivative (PD) compensator first adjusts the transient

response, followed by an active proportional integral (PI) compensator that adjusts steady

## state error. [1]

Control Systems Compensation 3

## Designing compensators by hand is a tedious effort, because the designer must

conduct several difficult calculations. Further, root locus technique helps identify the correct

gain, zero, and pole location(s) for the compensators. If one would have to draw and re-

draw root locus diagrams during the design phase, the task can easily be too difficult to

properly master. Fortunately, MATLAB® can do most of the work for the designer.

Compensator Theory
The method of compensation that this paper discusses is called cascade

compensation. Cascade compensation assumes a unity feedback system with a controller and

plant in the forward path. To compensate the system, the transfer function for the

compensator will be in series (cascaded) with the controller and plant. The overall system

## the form ( s + Zc ) (1)

Gc ( s ) = K
( s + Pc )

where Zc and Pc are the zero and pole of the compensator, respectively. K denotes the gain

necessary to ensure that the proper overshoot at the compensated pole and zero is met. For
Control Systems Compensation 4

proper lead compensation, PC must be greater than ZC, while for proper lag compensation

## A PID controller compensates systems in a different manner. Figure 2 shows the

implementation of PID compensation. Values K1, K2, and K3 designate required gains for

proper compensation, while the compensator itself has two zeros and two poles; one of the

K3 s

K2
s

K1 G1(s) G2(s)

## Figure 2 - PID controller (compensator) [1]

The controller is between the two summing junctions and has the following transfer

function

K2 (2)
Gc ( s ) = K 1 + + K3⋅s
s

To achieve proper compensation, one zero of the compensator, together with the pole at the

origin, act as the PI compensator while the remaining zero characterizes the PD

compensator. Using MATLAB® I will illustrate how to incorporate each of the three

compensators.
Control Systems Compensation 5

## Control System Description

The control system I am using as an example for this paper is completely random. It

does not serve a set purpose other than to illustrate how MATLAB® can provide solutions

to effectively and quickly design compensators. The control system that I will compensate is

shown in Figure 3.

9.57
(s + 0.2)(s + 3.1)

## This system has the following characteristics:

 %OS = 15%

 Tp = 1.14 s

 TR = 0.52 s

 TS = 2.46 s

 Ess = 0.383

Additionally, the system has two poles (-0.2, -3.1) and no zeros and a final steady-state value

of 0.94.

To improve the transient response of this system, I will design a lead compensator

that keeps the percent overshoot at 15 percent and adjusts the settling time, TS, to 0.5
Control Systems Compensation 6

seconds. I will follow the same steps used in my MATLAB® code, which is available as an

## attachment to this project report.

First, I compute ζ for the desired 15% overshoot. This value will be used to insert

lines into the root locus graph in MATLAB®. Next, I find the location on the root locus

graph where the root locus intersects with the ζ-line. This compensated design point is

-1.65+2.73j. To find the actual design point of the lead compensator, I divide the current

settling time by the desired settling time in order to find the factor of improvement. In order

to decrease the settling time by this factor, I must multiply the compensated design point

## Factor ⋅ (σd + ωdj ) = −8.12 + 13 .43 j (3)

To start the design process, I arbitrarily choose the compensators zero, ZC, to be -2.

Using a calculator or MATLAB®, I find the sum of angular contribution of all zeros and

poles of the system, including the arbitrarily chosen pole. I subtract this angle from 180° to

receive the angular contribution, θLead, required for the compensator pole. Using geometry I

## find the compensator’s pole as follows

ωdesign (4)
PC = + σdesign = 14.82

The values for ZC and PC are acceptable, since PC is greater than ZC. To finish the

design, I use MATLAB® to find the appropriate gain for the entire system. The appropriate

gain for this system to achieve 15 percent overshoot and a settling time of 0.5 seconds is

287.6. I verified the design by graphing the step responses of the uncompensated and lead-

compensated systems.
Control Systems Compensation 7

Lag Compensation
To improve the steady-state error of the system, I tried to decrease the error by a

factor of ten. Since this system is unity-feedback without any pure integrators in the plant’s

denominator, we can utilize the assumptions for a Type 0 system. Hence, I find the position

constant KP as follows

1 (5)
KP = = 15.44
1 + lim G ( s )
s →0

In order to improve the steady-state error of the system by a factor of ten, I must

find the value of the desired steady-state error first by dividing the uncompensated system

steady-state error by ten. Now, I can find the target value for KP as indicated below

1 (6)
KPT arg et = − 1 = 25.13
ESST arg et

## To continue, I assume the compensator’s pole, PC, at 0.01. It is important to choose

a value that is close to the origin, to ensure that the added pole has little effect on the

transient response of the system. Using this value and the previous values for KP I find the

## KPT arg et − PC (7)

ZC = = 0.0163
KP

Because the compensator’s zero is larger than the compensator’s pole, this qualifies

as a valid design for a lag compensator. Using MATLAB®, I identify the required gain for

the system to be 10.94. I verify the design be observing the step responses of the

## uncompensated and lag-compensated systems.

Control Systems Compensation 8

PID Compensation
In order to improve both the transient response and the steady-state error, I

continue by designing a PID compensator. To do so, I try to reduce the peak time by a

## First, I designed the PD compensator. I reused the uncompensated design point

from the lead compensator, because the system is the same and the overshoot did not

change. However, to find the new compensated design points I had to use the relationship

π (8)
ωd design = = 13.77
TPcurrent ⋅ 0.2

Next, I found the angle, α, between the ζ-line and the positive real-axis. Using this

## angle I can calculate σd for the design point as follows

ωd (9)
σd = = −8.33
design
design
tan(α )

Using MATLAB®, I find the sum of angles for all uncompensated poles and zeros to

be 231.31°. Subtracting 180° from this number yields the required angle, β, for the PD

compensator’s zero. The PD compensator zero, pdZC is calculated using the following

relationship

ωd (10)
pdZ c = − σddesign = 19.36
design

tan( β )

In order to adjust for PD compensation, the gain of the compensator is found to be 7.63.

Next, the values for the PI compensator are chosen, as any ideal PI compensator will

## work. The following transfer function is used for the PI compensator

s + 0 .5 (11)
GPI ( s ) =
s
Control Systems Compensation 9

Unfortunately, I was unable to properly find the overall gain for the entire PID

compensator. While I could not find an error in my code, I realize that the gain in all

likelihood has to be something other than one. However, I did check my results comparing

the step responses of the uncompensated system, PD-compensated system, and PID-

compensated system. The graphs indicated that the PID design was at least somewhat

## successful, as both steady-state error and transient response improved.

Results/Discussion
The lead and lag compensators I designed using MATLAB® performed well. Figure

response.

## Figure 4 - Lead compensator performance to step input

Control Systems Compensation 10

## In Figure 4, the green curve is the lead-compensated curve, and we notice a

tremendous improvement and rise time, peak time, and settling time. Further, the percent

overshoot is still 14.9 percent, with the target being 15 percent. The settling time improved

from 2.46 seconds to the approximate target of 0.53 seconds. At the same time, the final

value only increased minimally from originally 0.94 to 0.98. The final lead-compensated

## system looks as shown in Figure 5.

287.6⋅ (s + 2) 1
(s +14.82) (s + 0.2)(s + 3.1)

## Figure 5 - Lead-compensated control system

Figure 6 shows the performance of the lag compensator. Both the uncompensated

and lag-compensated step responses are pictured. The green curve represents the lag-

compensated system, while the blue curve is the uncompensated system. Both are almost

## overlapping, indicating a successful design, because transient characteristics remained

unchanged. Further, the steady-state error decreased as desired by a factor of ten. The initial

steady state error was 0.383 and the lag-compensated steady-state error was 0.336. The

overshoot of the lag-compensated system is at 15.1 percent. The settling time increased

slightly from 2.46 seconds to 2.77 seconds. The final design for the lag-compensated system

is picture in Figure 7.
Control Systems Compensation 11

## Figure 6 - Lag compensator performance to step input

10.94⋅ (s + 0.0163) 1
(s + 0.01) (s + 0.2)(s + 3.1)

## Figure 7 - Lag-compensated control system

Unfortunately, the design of the PID control was not as successful as I had hoped. I

did check my code numerous times and tried different approaches but I could never fully

find a successful design. Figure 8 shows the step response of the controller, picturing the

## uncompensated, PD-compensated, and PID-compensated responses.

Control Systems Compensation 12

## Figure 8 - PD and PID compensator performance to step input

In Figure 8, the green curve represents the PD-compensated system, the red curve

represents the PID-compensated system, and the blue curve the original, uncompensated

system. We can clearly identify that the PD-compensator performs well. The peak time is

reduced by a factor of 0.2 from originally 1.13 seconds to 0.23 seconds. The overshoot,

however, changes from 15 percent to 26.3 percent. While this change seems significant and

should be avoided, the actual change is minimal. The peak amplitude of the original system

is 1.08, while the PD-compensated peak amplitude is 1.26. Aside from improving transient

## response, the steady-state error is also slightly improved.

Unfortunately, Figure 8 shows that the PID compensator shifts the curve towards

the right, undoing some of the improvements to the transient response. While the transient

response is still better than that of the original system, this should not happen. Further,
Control Systems Compensation 13

MATLAB® indicates that the PID-compensated system does not reach a final value, but

rather tends towards infinity. The graph, on the other hand, does not seem to indicate this.

In fact, the graph itself, even over an extended amount of time, seems to indicate the system

being stable. On the other hand, using the final value theorem shows that the PID-

## compensated system does, indeed, tend towards infinity.

Summary
Compensators in control systems are essential when designing for specific steady-

state or transient responses. I was able to successfully implement a lead and lag

compensator, effectively improving transient response and steady-state error. Each of these

improvements occurred on an individual basis. While I made every effort to design a PID

## simultaneous improvements in transient response and steady-state error.

Conclusion
I conclude that I successfully designed lead and lag compensators in accordance to

the desired target transient response and steady-state error. I incorporated MATLAB® for

the entire design and set-up code that one can modify with ease to quickly and efficiently

## design compensators for other unity-feedback systems.

Contrary, I was unable to design a PID compensator that would decrease peak time

by a factor of 0.2, decrease steady-state error to zero, and remain at 15 percent overshoot.

The procedure I followed is outlined in [1] and should have yielded the desired results.

Continuous analysis of my code and methods did not yield any obvious errors on my part.
Control Systems Compensation 14

Hence, I conclude that the MATLAB® code I am providing with this project should

aid persons in successfully designing lead and lag compensators. I outlined my steps

## thoroughly and presented evidence that my findings are correct.

References
[1] N. S. Nise, Control Systems Engineering, 4th Ed., Indianapolis: Wiley, 2004, pp. 500-
503, 509-536.