control systen
TRANSCRIPT
-
8/7/2019 control systen
1/87
http://en.wikipedia.org/wiki/PID_controller
PID controllerFrom Wikipedia, the free encyclopedia
A block diagram of a PID controller
A proportionalintegralderivative controller(PID controller) is a genericcontrol loopfeedback
mechanism (controller) widely used in industrial control systems a PID is the most commonly used feedback
controller. A PID controller calculates an "error" value as the difference between a measured process
variableand a desiredsetpoint. The controller attempts to minimize the error by adjusting the process control
inputs.
The PID controller calculation (algorithm) involves three separate constant parameters, and is accordingly
sometimes called three-term control: theproportional, the integraland derivative values,
denoted P,I, and D.Heuristically, these values can be interpreted in terms of time: Pdepends on
the presenterror, Ion the accumulation ofpasterrors, and D is a prediction offuture errors, based on current
rate of change.[1] The weighted sum of these three actions is used to adjust the process via a control element
such as the position of a control valve or the power supply of a heating element.
In the absence of knowledge of the underlying process, a PID controller is the best controller.[2] By tuning the
three parameters in the PID controller algorithm, the controller can provide control action designed for specific
process requirements. The response of the controller can be described in terms of the responsiveness of the
http://en.wikipedia.org/wiki/PID_controllerhttp://en.wikipedia.org/wiki/Block_diagramhttp://en.wikipedia.org/wiki/Control_loophttp://en.wikipedia.org/wiki/Feedback_mechanismhttp://en.wikipedia.org/wiki/Feedback_mechanismhttp://en.wikipedia.org/wiki/Feedback_mechanismhttp://en.wikipedia.org/wiki/Controller_(control_theory)http://en.wikipedia.org/wiki/Control_systemhttp://en.wikipedia.org/wiki/Control_systemhttp://en.wikipedia.org/wiki/Process_variablehttp://en.wikipedia.org/wiki/Process_variablehttp://en.wikipedia.org/wiki/Setpoint_(control_system)http://en.wikipedia.org/wiki/Setpoint_(control_system)http://en.wikipedia.org/wiki/Setpoint_(control_system)http://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Proportionality_(mathematics)http://en.wikipedia.org/wiki/Proportionality_(mathematics)http://en.wikipedia.org/wiki/Integralhttp://en.wikipedia.org/wiki/Integralhttp://en.wikipedia.org/wiki/Derivativehttp://en.wikipedia.org/wiki/Heuristichttp://en.wikipedia.org/wiki/File:Pid-feedback-nct-int-correct.pnghttp://en.wikipedia.org/wiki/File:Pid-feedback-nct-int-correct.pnghttp://en.wikipedia.org/wiki/Block_diagramhttp://en.wikipedia.org/wiki/Control_loophttp://en.wikipedia.org/wiki/Feedback_mechanismhttp://en.wikipedia.org/wiki/Feedback_mechanismhttp://en.wikipedia.org/wiki/Controller_(control_theory)http://en.wikipedia.org/wiki/Control_systemhttp://en.wikipedia.org/wiki/Process_variablehttp://en.wikipedia.org/wiki/Process_variablehttp://en.wikipedia.org/wiki/Setpoint_(control_system)http://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Proportionality_(mathematics)http://en.wikipedia.org/wiki/Integralhttp://en.wikipedia.org/wiki/Derivativehttp://en.wikipedia.org/wiki/Heuristichttp://en.wikipedia.org/wiki/PID_controller -
8/7/2019 control systen
2/87
controller to an error, the degree to which the controllerovershoots the setpoint and the degree of system
oscillation. Note that the use of the PID algorithm for control does not guarantee optimal control of the system
or system stability.
Some applications may require using only one or two actions to provide the appropriate system control. This
is achieved by setting the other parameters to zero. A PID controller will be called a PI, PD, P or I controller in
the absence of the respective control actions. PI controllers are fairly common, since derivative action is
sensitive to measurement noise, whereas the absence of an integral term may prevent the system from
reaching its target value due to the control action.
Contents
[hide]
1 Control loop basics
2 PID controller theory 2.1 Proportional term
2.1.1 Droop
2.2 Integral term
2.3 Derivative term
2.4 Summary
3 Loop tuning
3.1 Stability
3.2 Optimum behavior
3.3 Overview of methods
3.4 Manual tuning
3.5 ZieglerNichols method
3.6 PID tuning software
4 Modifications to the PID algorithm
5 History
6 Limitations of PID control
6.1 Linearity
6.2 Noise in derivative
http://en.wikipedia.org/wiki/Overshoot_(signal)http://en.wikipedia.org/wiki/Optimal_controlhttp://en.wikipedia.org/wiki/PID_controllerhttp://en.wikipedia.org/wiki/Overshoot_(signal)http://en.wikipedia.org/wiki/Optimal_controlhttp://en.wikipedia.org/wiki/PID_controller -
8/7/2019 control systen
3/87
7 Improvements
7.1 Feed-forward
7.2 Other improvements
8 Cascade control
9 Physical implementation of PID control
10 Alternative nomenclature and PID forms
10.1 Ideal versus standard PID form
10.2 Basing derivative action on PV
10.3 Basing proportional action on
PV
10.4 Laplace form of the PID
controller
10.5 PID Pole Zero Cancellation
10.6 Series/interacting form
10.7 Discrete implementation
10.8 Pseudocode
11 PI controller
12 See also
13 References
14 External links
14.1 PID tutorials
14.2 Special topics and PID control
applications
[edit]Control loop basics
Further information: Control loop
A familiar example of a control loop is the action taken when adjusting hot and cold faucet valves to maintain
the faucet water at the desired temperature. This typically involves the mixing of two process streams, the hot
and cold water. The person touches the water to sense or measure its temperature. Based on this feedback
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=1http://en.wikipedia.org/wiki/Control_loophttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=1http://en.wikipedia.org/wiki/Control_loop -
8/7/2019 control systen
4/87
they perform a control action to adjust the hot and cold water valves until the process temperature stabilizes
at the desired value.
Sensing water temperature is analogous to taking a measurement of the process value or process variable
(PV). The desired temperature is called the setpoint (SP). The input to the process (the water valve position)
is called the manipulated variable (MV). The difference between the temperature measurement and the
setpoint is the error (e) and quantifies whether the water is too hot or too cold and by how much.
After measuring the temperature (PV), and then calculating the error, the controller decides when to change
the tap position (MV) and by how much. When the controller first turns the valve on, it may turn the hot valve
only slightly if warm water is desired, or it may open the valve all the way if very hot water is desired. This is
an example of a simple proportional control. In the event that hot water does not arrive quickly, the controller
may try to speed-up the process by opening up the hot water valve more-and-more as time goes by. This is
an example of anintegral control.
Making a change that is too large when the error is small is equivalent to a high gain controller and will lead to
overshoot. If the controller were to repeatedly make changes that were too large and repeatedly overshoot
the target, the output would oscillate around the setpoint in either a constant, growing, or decaying sinusoid. If
the oscillations increase with time then the system is unstable, whereas if they decrease the system is stable.
If the oscillations remain at a constant magnitude the system ismarginally stable.
In the interest of achieving a gradual convergence at the desired temperature (SP), the controller may wish
to dampthe anticipated future oscillations. So in order to compensate for this effect, the controller may elect
to temper their adjustments. This can be thought of as aderivative control method.
If a controller starts from a stable state at zero error (PV = SP), then further changes by the controller will be
in response to changes in other measured or unmeasured inputs to the process that impact on the process,
and hence on the PV. Variables that impact on the process other than the MV are known as disturbances.
Generally controllers are used to reject disturbances and/or implement setpoint changes. Changes in
feedwater temperature constitute a disturbance to the faucet temperature control process.
In theory, a controller can be used to control any process which has a measurable output (PV), a known ideal
value for that output (SP) and an input to the process (MV) that will affect the relevant PV. Controllers are
used in industry to regulate temperature,pressure,flow rate,chemical composition, speed and practicallyevery other variable for which a measurement exists.
[edit]PID controller theory
This section describes the parallel or non-interacting form of the PID controller. For other forms please see
the section "Alternative nomenclature and PID forms".
http://en.wikipedia.org/wiki/Oscillatehttp://en.wikipedia.org/wiki/Sinusoidhttp://en.wikipedia.org/wiki/Marginal_stabilityhttp://en.wikipedia.org/wiki/Marginal_stabilityhttp://en.wikipedia.org/wiki/Dampinghttp://en.wikipedia.org/wiki/Dampinghttp://en.wikipedia.org/wiki/Temperaturehttp://en.wikipedia.org/wiki/Pressurehttp://en.wikipedia.org/wiki/Pressurehttp://en.wikipedia.org/wiki/Pressurehttp://en.wikipedia.org/wiki/Flow_ratehttp://en.wikipedia.org/wiki/Chemicalhttp://en.wikipedia.org/wiki/Chemicalhttp://en.wikipedia.org/wiki/Speedhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=2http://en.wikipedia.org/wiki/Oscillatehttp://en.wikipedia.org/wiki/Sinusoidhttp://en.wikipedia.org/wiki/Marginal_stabilityhttp://en.wikipedia.org/wiki/Dampinghttp://en.wikipedia.org/wiki/Temperaturehttp://en.wikipedia.org/wiki/Pressurehttp://en.wikipedia.org/wiki/Flow_ratehttp://en.wikipedia.org/wiki/Chemicalhttp://en.wikipedia.org/wiki/Speedhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=2 -
8/7/2019 control systen
5/87
The PID control scheme is named after its three correcting terms, whose sum constitutes the manipulated
variable (MV). Hence:
where
Pout, Iout, and Dout are the contributions to the output from the PID controller from each of the three
terms, as defined below.
[edit]Proportional term
Plot of PV vs time, for three values of Kp (Ki and Kd held constant)
The proportional term (sometimes called gain) makes a change to the output that is proportional to
the current error value. The proportional response can be adjusted by multiplying the error by a
constant Kp, called the proportional gain.
The proportional term is given by:
where
Pout: Proportional term of output
Kp: Proportional gain, a tuning parameter
SP: Setpoint, the desired value
PV: Process value (or process variable), the measured value
e: Error= SP PV
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=3http://en.wikipedia.org/wiki/File:Change_with_Kp.pnghttp://en.wikipedia.org/wiki/File:Change_with_Kp.pnghttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=3 -
8/7/2019 control systen
6/87
t: Time or instantaneous time (the present)
A high proportional gain results in a large change in the
output for a given change in the error. If the proportional gain
is too high, the system can become unstable (see the
section onloop tuning). In contrast, a small gain results in a
small output response to a large input error, and a less
responsive (or sensitive) controller. If the proportional gain is
too low, the control action may be too small when
responding to system disturbances.
[edit]Droop
A pure proportional controller will not always settle at its
target value, but may retain a steady-state error. Specifically,
the process gain - drift in the absence of control, such as
cooling of a furnace towards room temperature, biases a
pure proportional controller. If the process gain is down, as
in cooling, then the bias will be belowthe set point, hence
the term "droop".
Droop is proportional to process gain and inversely
proportional to proportional gain. Specifically the steady-
state error is given by:
e = G / Kp
Droop is an inherent defect of purely proportional
control. Droop may be mitigated by adding a
compensating bias term (setting the setpoint above the
true desired value), or corrected by adding an
integration term (in a PI or PID controller), which
effectively computes a bias adaptively.
Despite droop, both tuning theory and industrialpractice indicate that it is the proportional term that
should contribute the bulk of the output change.
[edit]Integral term
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=4http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=5http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=4http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=5 -
8/7/2019 control systen
7/87
-
8/7/2019 control systen
8/87
t: Time or instantaneous time (the present)
: a dummy integration variable
The integral term
(when added to
the proportional
term) accelerates
the movement of
the process
towards setpoint
and eliminates
the residual
steady-state
error that occurs
with a
proportional only
controller.
However, since
the integral term
is responding to
accumulated
errors from the
past, it can cause
the present value
to overshoot the
setpoint value
(cross over the
setpoint and then
create a
deviation in the
other direction).
For further notes
regarding integral
gain tuning and
controller
stability, see the
-
8/7/2019 control systen
9/87
section onloop
tuning.
[edit]Derivati
ve term
Plot of PV vs
time, for three
values of
Kd (Kp and
Ki held
constant)
The rate of
change of the
process error is
calculated by
determining the
slope of the error
over time (i.e., its
first derivative
with respect to
time) and
multiplying this
rate of change by
the derivative
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=6http://en.wikipedia.org/wiki/File:Change_with_Kd.pnghttp://en.wikipedia.org/wiki/File:Change_with_Kd.pnghttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=6 -
8/7/2019 control systen
10/87
gain Kd. The
magnitude of the
contribution of
the derivative
term (sometimes
called rate) to the
overall control
action is termed
the derivative
gain, Kd.
The derivative
term is given by:
where
Dout: Derivative term of output
Kd: Derivative gain, a tuning parameter
SP: Setpoint, the desired value
PV: Process value (or process variable), the measured value
e: Error= SP PVt: Time or instantaneous time (the present)
The
slow
cha
con
this
noti
the setp
deri
use
mag
ove
-
8/7/2019 control systen
11/87
by t
com
imp
com
proc
How
diffe
sign
nois
term
is h
nois
terma pr
bec
the
deri
suff
Hen
app
diffe
limit
mor
use
is kn
Pha
com
[edi
The
inte
deri
sum
the
con
Def
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=7http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=7 -
8/7/2019 control systen
12/87
con
fina
algo
whe
para
Pro
Larger values typically mean faster response since the larger the error, the larger the proportional
term compensation. An excessively large proportional gain will lead to process instability and
oscillation.
Inte
Larger values imply steady state errors are eliminated more quickly. The trade-off is larger overshoot:
any negative error integrated during transient response must be integrated away by positive error
before reaching steady state.
Der
Larger values decrease overshoot, but slow down transient response and may lead to instability due
to signal noise amplification in the differentiation of the error
[edi
Tun
its c
ban
gain
des
(bou
requ
syst
app
and
ano
Som
line
at fu
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=8http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=8 -
8/7/2019 control systen
13/87
proc
can
sch
diffe
con
con
perf
by c
be u
PID
thou
and
bec
with
are
tuni
are
des
met
[edi
If th
of th
term
con
i.e.
with
satu
Inst
part
lag.
Gen
reve
proc
com
http://en.wikipedia.org/wiki/Gain_schedulinghttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=9http://en.wikipedia.org/wiki/Gain_schedulinghttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=9 -
8/7/2019 control systen
14/87
setp
stab
acc
[edi
The
cha
dep
Two
are
stay
trac
th
vari
crite
time
mus
proc
exa
proc
exp
[edi
The
PID
gen
som
cho
dyn
tuni
inef
resp
long
The
on w
"offl
http://en.wikipedia.org/wiki/Marginal_stabilityhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=10http://en.wikipedia.org/wiki/Rise_timehttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=11http://en.wikipedia.org/wiki/Marginal_stabilityhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=10http://en.wikipedia.org/wiki/Rise_timehttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=11 -
8/7/2019 control systen
15/87
of th
offli
invo
cha
a fu
to d
-
8/7/2019 control systen
16/87
[edi
If thtuni
set K
the
osc
app
"qua
The
in s
How
inst
unti
its r
How
exc
PID
to re
howove
dam
whic
less
cau
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=12http://en.wikipedia.org/wiki/Overdampinghttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=12http://en.wikipedia.org/wiki/Overdamping -
8/7/2019 control systen
17/87
[edi
For
see
Ano
form
met
Zieg
194
the
The
the
of th
osc
gain
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=13http://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_methodhttp://en.wikipedia.org/w/index.php?title=John_G._Ziegler&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=13http://en.wikipedia.org/wiki/Ziegler%E2%80%93Nichols_methodhttp://en.wikipedia.org/w/index.php?title=John_G._Ziegler&action=edit&redlink=1 -
8/7/2019 control systen
18/87
The
form
to th
deri
only
peri
"Alte
[edi
Mos
tune
met
tuni
use
soft
dev
opti
can
data
Mat
imp
con
des
resp
mat
reco
can
set
hard
con
whic
sen
itse
Oth
loop
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=14http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=14 -
8/7/2019 control systen
19/87
crite
emb
hard
Adv
soft
PID
Stat
mod
a di
para
[edi
alg
The
cha
hav
mod
Inte
For
wind
One
idea
wind
occ
inte
than
regu
syst
incr
unw
by:
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=15http://en.wikipedia.org/wiki/Integral_winduphttp://en.wikipedia.org/wiki/Integral_winduphttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=15http://en.wikipedia.org/wiki/Integral_winduphttp://en.wikipedia.org/wiki/Integral_windup -
8/7/2019 control systen
20/87
Ove
dist
For example, a PID loop is used to control the temperature of an electric resistance furnace, the
system has stabilized. Now the door is opened and something cold is put into the furnace the
temperature drops below the setpoint. The integral function of the controller tends to compensate this
error by introducing another error in the positive direction. This overshoot can be avoided by freezing
of the integral function after the opening of the door for the time the control loop typically needs to
reheat the furnace.
Rep
bas
Often the time-response of the system is approximately known. Then it is an advantage to simulate
this time-response with a model and to calculate some unknown parameter from the actual response
of the system. If for instance the system is an electrical furnace the response of the difference
between furnace temperature and ambient temperature to changes of the electrical power will be
similar to that of a simple RC low-pass filter multiplied by an unknown proportional coefficient. The
actual electrical power supplied to the furnace is delayed by a low-pass filter to simulate the response
of the temperature of the furnace and then the actual temperature minus the ambient temperature is
divided by this low-pass filtered electrical power. Then, the result is stabilized by another low-pass
filter leading to an estimation of the proportional coefficient. With this estimation, it is possible to
calculate the required electrical power by dividing the set-point of the temperature minus the ambienttemperature by this coefficient. The result can then be used instead of the integral function. This also
achieves a control error of zero in the steady-state, but avoids integral windup and can give a
significantly improved control action compared to an optimized PID controller. This type of controller
does work properly in an open loop situation which causes integral windup with an integral function.
This is an advantage if, for example, the heating of a furnace has to be reduced for some time
-
8/7/2019 control systen
21/87
because of the failure of a heating element, or if the controller is used as an advisory system to a
human operator who may not switch it to closed-loop operation. It may also be useful if the controller
is inside a branch of a complex control system that may be temporarily inactive.
Man
exa
maj
the
mec
mec
dev
a sig
outp
of th
mod
cha
rang
dea
The
exc
subj
errothe
of th
inst
algo
Der
In this case the PID controller measures the derivative of the output quantity, rather than the
derivative of the error. The output is always continuous (i.e., never has a step change). For this to be
effective, the derivative of the output must have the same sign as the derivative of the error.Set
In this modification, the setpoint is gradually moved from its old value to a newly specified value using
a linear or first order differential ramp function. This avoids the discontinuitypresent in a simple step
change.
Set
http://en.wikipedia.org/wiki/Discontinuityhttp://en.wikipedia.org/wiki/Discontinuityhttp://en.wikipedia.org/wiki/Discontinuity -
8/7/2019 control systen
22/87
Setpoint weighting uses different multipliers for the error depending on which element of the controller
it is used in. The error in the integral term must be the true control error to avoid steady-state control
errors. This affects the controller's setpoint response. These parameters do not affect the response to
load disturbances and measurement noise.
[edi
PID
PID
wer
earl
Spe
con
(Min
for t
ahe
bas
cha
was
prob
distnota
term
Tria
con
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=16http://en.wikipedia.org/wiki/Helmsmanhttp://en.wikipedia.org/wiki/File:Scross_helmsman.jpghttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=16http://en.wikipedia.org/wiki/Helmsman -
8/7/2019 control systen
23/87
yield
yaw
The
pers
othe
[edi
Whi
ofte
they
prov
that
kno
and
mod
inco
The
con
con
suc
diffeperf
prec
cas
PID
the
not
also
regu
beh
hav
[edi
Ano
in p
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=17http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=18http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=17http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=18 -
8/7/2019 control systen
24/87
line
tem
hea
ove
dow
to p
incr
[edi
A pr
mea
in th
pas
How
othe
bett
whic
som
with
as a
[edi
[edi
The
the
forw
the
com
perf
maj
prim
the
Sinc
feed
imp
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=19http://en.wikipedia.org/wiki/Low-pass_filterhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=20http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=21http://en.wikipedia.org/wiki/Feedbackhttp://en.wikipedia.org/wiki/Feed-forwardhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=19http://en.wikipedia.org/wiki/Low-pass_filterhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=20http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=21http://en.wikipedia.org/wiki/Feedbackhttp://en.wikipedia.org/wiki/Feed-forward -
8/7/2019 control systen
25/87
For
mec
the
bein
or to
take
valu
con
dec
prim
situ
outp
setpope
prov
[edi
In a
thro
in d
logi
instrate
requ
[edi
One
con
This
PID
PID
phy
con
oute
cha
mat
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=22http://en.wikipedia.org/w/index.php?title=Computational_verb_logic&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=23http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=22http://en.wikipedia.org/w/index.php?title=Computational_verb_logic&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=23 -
8/7/2019 control systen
26/87
con
by u
[edi
In th
was
con
by c
indu
Elec
stat
ana
elec
the
dete
con
imp
Mos
inp
digi
theyimp
Var
ofP
vari
cycl
syst
sec
perc
for h
[edi
[edi
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=24http://en.wikipedia.org/wiki/Transistorhttp://en.wikipedia.org/wiki/Transistorhttp://en.wikipedia.org/wiki/Transistorhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Pulse-width_modulationhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=25http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=26http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=24http://en.wikipedia.org/wiki/Transistorhttp://en.wikipedia.org/wiki/Programmable_logic_controllerhttp://en.wikipedia.org/wiki/Pulse-width_modulationhttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=25http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=26 -
8/7/2019 control systen
27/87
The
and
In th
whe
Ti is the integral time
Td is the derivative time
In th
inne
and
effe
that
valu
elim
valu
In th
the
thro
trea
whe
theo
com
[edi
In m
This
whe
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=27http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=27 -
8/7/2019 control systen
28/87
cha
resp
[edi
Mos
This
see
con
mod
dist
of th
proc
algo
Tun
algo
[edi
Som
Hav
mak
[edi
The
Whe
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=28http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=29http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=30http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=28http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=29http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=30 -
8/7/2019 control systen
29/87
If
The
This
[edi
Ano
whe
, , and
with
.
This
digi
[edi
The
con
sam
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=31http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=32http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=31http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=32 -
8/7/2019 control systen
30/87
The
Thu
sec
[edi
Her
pre
int
sta
e
i
d
o
p
wg
[edi
Basi
A P
The
http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=33http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=34http://en.wikipedia.org/wiki/File:PI_controller.pnghttp://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=33http://en.wikipedia.org/w/index.php?title=PID_controller&action=edit§ion=34 -
8/7/2019 control systen
31/87
whe
= SP - PV.
A P
whe
G = KP= proportional gain
G / = KI= integral gain
Sett
The
With
pert
PID ControllerCIRCUIT
PID1.CIR Download the SPICE fileTuning the PID controller can be like learning to roller blade, ski or maybe riding a bull.Until you've done it a few times, the literature you've read really doesn't hit home. Butafter after few attempts (and falls), you find it wasn't so bad after all - in fact it was kindof fun!
The PID controller is every where - temperature, motion, flow controllers - and itsavailable in analog and digital forms. Why use it? It helps get your output (velocity,
http://www.ecircuitcenter.com/circuits/pid1/PID1.CIRhttp://www.ecircuitcenter.com/circuits/pid1/PID1.CIR -
8/7/2019 control systen
32/87
temperature, position) where you want it, in a short time, with minimal overshoot, andwith little error. In many applications the PID controller can do the job - but as usual,with compromises. After a short intro to the PID terms and an example control system,you'll get a chance tune a PID controller.
THE PID CONTROLLER
You've probably seen the terms defined before: P -Proportional, I - Integral, D -Derivative. These terms describe three basic mathematical functions applied to the errorsignal , Verror = Vset - Vsensor. This error represents the difference between where youwant to go (Vset), and where you're actually at (Vsensor). The controller performs thePID mathematical functions on the error and applies the their sum to a process (motor,heater, etc.) So simple, yet so powerful! If tuned correctly, the signal Vsensor shouldmove closer to Vset.
Tuning a system means adjusting three multipliers Kp, Ki and Kd adding in various
amounts of these functions to get the system to behave the way you want. The tablebelow summarizes the PID terms and their effect on a control system.
Term Math Function Effect on Control System
PProportional
KP x VerrorTypically the main drive in a control loop, KP reduces alarge part of the overall error.
IIntegral
KI x Verror dtReduces the final error in a system. Summing even asmall error over time produces a drive signal large enoughto move the system toward a smaller error.
DDerivative
KD x dVerror / dtCounteracts the KP and KI terms when the outputchanges quickly. This helps reduce overshoot and ringing.It has no effect on final error.
THE CONTROL SYSTEM
The SPICE circuit for the Control System looks pretty much like the block diagram.
-
8/7/2019 control systen
33/87
PID CONTROLLER. How do we create the PID terms? To get the Proportionalterm,EP multiples Verror at V(2) by a fixed gain of 1 - easy enough! To get the Integralterm,
current source GI converts V(2) to a current and integrates it on C1=1F. Finally,the Derivative term is created by GD converting V(2) to a current and forcing it throughL1. The resulting voltage becomes V(5) = L1 di / dt. A quick substitution of L1 = 1 Hand i = Verror gets you V(5) = d Verror / dt.
OUTPUT PROCESS. EOUT represents a very simplified model of a process to becontrolled like motor velocity or heater temperature. The gain of 100 could represent anoutput transfer function of 100 RPM / V or 100 C / V. To include the effects of themotor's inertia or heater's thermal mass, we've added some time delay into the outputusing two cascaded RC filters. Although Vout is simulated in volts, we know it reallyrepresents other variables like velocity in RPM or temperature in C.
SENSOR. The sensor tells you, typically by a voltage, what's happening at the controlsystem output. For motor velocity, a tachometer could generate 1 V / 100 RPM; fortemperature, a thermistor circuit could produce 0.01 V / deg C. ESENSOR models thisfeedback device. Because a sensor does not respond instantly, an RC filter is also addedhere to model its finite response time.
TUNING THE PID CONTROLLER
-
8/7/2019 control systen
34/87
Although you'll find many methods and theories on tuning a PID, here's a straightforward approach to get you up and soloing quickly.
1. SET KP. Starting with KP=0, KI=0 and KD=0, increase KP until the output startsovershooting and ringing significantly.
2. SET KD. Increase KD until the overshoot is reduced to an acceptable level.3. SET KI. Increase KI until the final error is equal to zero.
HANDS-ON DESIGN Run a simulation of the circuit file PID1.CIR. VSET generates a10V step input voltage to the control system. You can adjust the PID terms at the EPIDsource that adds the P, I and D terms at V(3), V(4) and V(5). Initially, the PID multipliersare set to KP=1, KI=0 and KD=0.EPID 6 0 POLY(3) (3,0) (4,0) (5,0) 0 1 0 0
SET KP. Plot the system input V(1) and the sensor output (12). Although the response
looks smooth, what is the sensor voltage compared to the desired 10V? The output fallsshort by 5V! To reduce this error, increase KP to 10 (Change EPID to look like ... 10 00 ). Wow, the output now reaches 9V, reducing the error to 1V. But as you can see, theoutput is getting wild with overshoot and ringing. Push KP up higher to 20 or 30. Yes, theerror reduces, but the overshoot gets worse. Eventually, your system will becomeunstable and break out into song (oscillate). Back off KP to 20 or so.
SET KD. The derivative term can rescue the response by counteracting the KP drivewhen the output is changing. Start with a small value like KD=0.2 and rerun thesimulation (Change EPID to look like ...20 0 0.2 ). Now you're wrestling control back into the system - the ringing and
overshoot are reduced! Crank up KD some more. Improvement should continue to a pointwhere the system becomes less stable and overshoot increases again. Return KD toaround 0.5.
SET KI. With KP=20, KI=0 and KD=0.5 the response looks respectable, but the finalerror is a disappointing 0.5V (or 5%)! Now, try the KI term. This will integrate theremaining error into a drive signal big enough to reduce the error further. Start with KI =10 ( EPID should look like ... 20 10 0.5 ). Check out the last half of the V(12) - thesensor output moves slowly toward 10V! You might want to put up a cursor on the plotto monitor the exact value of V(12). The bigger you make KI, the faster it will movetoward 10V. Like the other terms, a value is reached where the KI does more harm thangood as the system becomes less stable.
DIVING DEEPER
Diving a little deeper you can get a clearer view of the PID components. Before we gobeneath the surface, set KP=10, KI=0 and KD=0.
-
8/7/2019 control systen
35/87
INSIDE P Run a couple of simulations with KP=10 and KP 20. Plot V(1) and V(12).What is the final error for each case? You may have noticed the errors of 1 and 0.5V areproportional to the gains of 10 and 20. You can estimate the error by
Verror Vset / KP
for large KP. What kind of gain do you need for a 1% error? You can easily calculate itas a gain of 100. However, we've already seen how large gain cause overshoot, ringingand oscillations! KP can't do it alone.
INSIDE D KD counteracts KP - let's see how. Set KP back to 10 and run a simulation.Plot the P function V(3) which is really Verror. Now plot the D term V(5) which weknow is dVerror / dt. To get a good view of D, set the Y-Axis limits to +100 /-200V.Notice how dVerror / dt swings negative when Verror is initially positive. How does thishelp? Essentially D counteracts the P term potentially reducing ringing and oscillations.The nice thing about the D term is that it goes to zero as the output settles. This makessense - no change in output, no derivative term. Add in some of the D function by setting
the multipliers to KP=10, KI=0 and KD=0.5. The initial overshoot should be significantlyreduced.
INSIDE I We've seen how a large gain produces a small error. However, big KP getsyou into big trouble with overshoot and ringing. Alternatively, an integrator can also giveyou a big gain by accumulating even a small error over time. Run a simulation withKP=10, KI=0 and KD=0.5 and plot the I term at V(4). What does it look like? Notice, aramp function, representing Verror integrated over over time, builds up to a significantdrive voltage. Add in the I function by setting KP=10, KI=40 and KD=0.5. The I termcompletes the controller's job by moving the output toward an error of zero.
SIMULATION NOTE
Need a handy way to combine multiple signals such as the PID sum? A controlled sourcecan be a function of multiple inputs described by a polynomial. What is this polynomial?The equation is defined by a coefficient list at the end of the statement. The examplebelowEPID 6 0 POLY(3) (3,0) (4,0) (5,0) 0 10 2 1
creates a polynomial of the form
V(6,0) = 0 + 10 V(3,0) + 2 V(4,0) + 1 V(5,0)
or more generally,VO = k0 + k1V1 + k2V2 + k3V3
In fact, you can get higher order terms and cross terms by extending the coefficient list
VO = ...+ k4V1V1 + k5V1V2 + k6V1V3 ++ k7V2V2 + k8V2V3 ++ k9V3V3
-
8/7/2019 control systen
36/87
If you're not using a term, you need to put a 0 in its place; you can't just leave it out. Thisfeature is great for simpler polynomials. Keeping track of the coefficient list for largepolynomials can get crazy fast.
SPICE FILEDownload the fileor copy this netlist into a text file with the *.cir extention.
PID1.CIR - THE PID CONTROLLER** SET POINTVSET 1 0 PWL(0MS 0MV 1MS 10V 2000MS 10V)RSET 1 0 1MEG** CALCULATE ERROREERROR 2 0 1 12 1RERROR 2 0 1MEG** P - PROPORTIONAL TERM
EP 3 0 2 0 1RP 3 0 1MEG** I - INTEGRAL TERMGI 0 4 2 0 1C1 4 0 1R1 4 0 1MEG** D - DERIVATIVE TERMGD 0 5 2 0 1L1 5 0 1** ADD PID TERMS, ADJUST PID MULTIPLIERS
EPID 6 0 POLY(3) (3,0) (4,0) (5,0) 0 1 0 0RPID 6 0 1MEG** AMPLIFIEREAMP 7 0 6 0 1RAMP 7 0 1MEG** PROCESS BLOCK WITH TIME LAG (PHASE SHIFT)EOUT 8 0 7 0 100RP1 8 9 100KCP1 9 0 1UFRP2 9 10 100KCP2 10 0 1UF** SENSOR BLOCK WITH TIME LAGESENSOR 11 0 10 0 0.01RP3 11 12 10KCP3 12 0 1UF** ANALYSIS.TRAN 10MS 2000MS** VIEW RESULTS
http://www.ecircuitcenter.com/circuits/pid1/PID1.CIRhttp://www.ecircuitcenter.com/circuits/pid1/PID1.CIRhttp://www.ecircuitcenter.com/circuits/pid1/PID1.CIR -
8/7/2019 control systen
37/87
.PRINT TRAN V(1) V(12)
.PROBE
.END
What Is PIDTutorial Overview
Get Tuning Tips Newsletter
PID stands for Proportional, Integral, Derivative. Controllers are designed to eliminate the need forcontinuous operator attention. Cruise control in a car and a house thermostat are common examples ofhow controllers are used to automatically adjust some variable to hold the measurement (or processvariable) at the set-point. The set-point is where you would like the measurement to be. Error is defined asthe difference between set-point and measurement.
(error) = (set-point) - (measurement) The variable being adjusted is called the manipulated variable whichusually is equal to the output of the controller. The output of PID controllers will change in response toa change in measurement or set-point. Manufacturers of PID controllers use different names to identifythe three modes. These equations show the relationships:
P Proportional Band = 100/gainI Integral = 1/reset (units of time)D Derivative = rate = pre-act (units of time)
Depending on the manufacturer, integral or reset action is set in either time/repeat or repeat/time. One isjust the reciprocal of the other. Note that manufacturers are not consistent and often use reset in units oftime/repeat or integral in units of repeats/time. Derivative and rate are the same.
Choosing the proper values for P, I, and D is called "PID Tuning". Find out about PID Tuning Software
Proportional Band
With proportional band, the controller output is proportional to the error or a change in measurement(depending on the controller).
(controller output) = (error)*100/(proportional band)
With a proportional controller offset (deviation from set-point) is present. Increasing the controller gain willmake the loop go unstable. Integral action was included in controllers to eliminate this offset.
IntegralWith integral action, the controller output is proportional to the amount of time the error is present.Integral action eliminates offset.
CONTROLLER OUTPUT = (1/INTEGRAL) (Integral of) e(t) d(t)
http://www.expertune.com/newsletter.htmlhttp://www.expertune.com/advanced.htmlhttp://www.expertune.com/newsletter.htmlhttp://www.expertune.com/advanced.html -
8/7/2019 control systen
38/87
Notice that the offset (deviation from set-point) in the time response plots is now gone. Integral action haseliminated the offset. The response is somewhat oscillatory and can be stabilized some by addingderivative action. (Graphic courtesy of ExperTune Loop Simulator.)
Integral action gives the controller a large gain at low frequencies that results in eliminating offset and"beating down" load disturbances. The controller phase starts out at 90 degrees and increases to near 0degrees at the break frequency. This additional phase lag is what you give up by adding integral action.Derivative action adds phase lead and is used to compensate for the lag introduced by integral action.
Derivative
With derivative action, the controller output is proportional to the rate of change of the measurement orerror. The controller output is calculated by the rate of change of the measurement with time.
dmCONTROLLER OUTPUT = DERIVATIVE ----
dt
Where m is the measurement at time t.
Some manufacturers use the term rate or pre-act instead of derivative. Derivative, rate, and pre-act arethe same thing.
DERIVATIVE = RATE = PRE ACT
Derivative action can compensate for a changing measurement. Thus derivative takes action to inhibitmore rapid changes of the measurement than proportional action. When a load or set-point change occurs,the derivative action causes the controller gain to move the "wrong" way when the measurement getsnear the set-point. Derivative is often used to avoid overshoot.
Derivative action can stabilize loops since it adds phase lead. Generally, if you use derivative action, morecontroller gain and reset can be used.
-
8/7/2019 control systen
39/87
With a PID controller the amplitude ratio now has a dip near the center of the frequency response. Integralaction gives the controller high gain at low frequencies, and derivative action causes the gain to startrising after the "dip". At higher frequencies the filter on derivative action limits the derivative action. Atvery high frequencies (above 314 radians/time; the Nyquist frequency) the controller phase and amplituderatio increase and decrease quite a bit because of discrete sampling. If the controller had no filter thecontroller amplitude ratio would steadily increase at high frequencies up to the Nyquist frequency (1/2 thesampling frequency). The controller phase now has a hump due to the derivative lead action and filtering.
(Graphic courtesy of ExperTune Loop Simulator.)
The time response is less oscillatory than with the PI controller. Derivative action has helped stabilize theloop.
Control Loop Tuning
It is important to keep in mind that understanding the process is fundamental to getting a well designedcontrol loop. Sensors must be in appropriate locations and valves must be sized correctly with appropriatetrim.
In general, for the tightest loop control, the dynamic controller gain should be as high as possible withoutcausing the loop to be unstable. Choosing a controller gain is accomplished easily with PID TuningSoftware
PID Optimization Articles
Fine Tuning "Rules"This picture (from the Loop Simulator) shows the effects of a PI controller with too much or too little P or Iaction. The process is typical with a dead time of 4 and lag time of 10. Optimal is red.
You can use the picture to recognize the shape of an optimally tuned loop. Also see the response shape ofloops with I or P too high or low. To get your process response to compare, put the controller in manualchange the output 5 or 10%, then put the controller back in auto.
P is in units of proportional band. I is in units of time/repeat. So increasing P or I, decreases their action inthe picture.
http://www.expertune.com/advanced.htmlhttp://www.expertune.com/advanced.htmlhttp://www.expertune.com/articles.htmlhttp://www.expertune.com/LoopSimulator.htmlhttp://www.expertune.com/advanced.htmlhttp://www.expertune.com/advanced.htmlhttp://www.expertune.com/articles.htmlhttp://www.expertune.com/LoopSimulator.html -
8/7/2019 control systen
40/87
View graphic inhi-resolution
Starting
PIDSettingsForCommonControlLoops
Loop Type
Flow
Liquid Pressure Gas Pressure
Liquid Level
Temperature
Chromatograph
These settingsare rough,assume propercontrol loopdesign, ideal or
series algorithm and do not apply to all controllers. Use ExperTune's PID Loop Optimizerto find the proper
PID settings for your process and controller. (From Process Control Systems (Shinskey) p.99 and Tuningand Control Loop Performance (McMillan) p 39)
Get Tuning Tips Newsletter
PID TutorialIntroductionThe three-term controllerThe characteristics of P, I, and D controllers
Example ProblemOpen-loop step responseProportional controlProportional-Derivative controlProportional-Integral controlProportional-Integral-Derivative control
General tips for designing a PID controller
http://www.expertune.com/images/finetune.gifhttp://www.expertune.com/images/finetune.gifhttp://www.expertune.com/PIDLoopOpt.htmlhttp://www.expertune.com/PIDLoopOpt.htmlhttp://www.expertune.com/newsletter.htmlhttp://www.expertune.com/images/finetune.gifhttp://www.expertune.com/images/finetune.gifhttp://www.expertune.com/PIDLoopOpt.htmlhttp://www.expertune.com/newsletter.html -
8/7/2019 control systen
41/87
Key Matlab Commands used in this tutorial are: stepcloopNote: Matlab commands from the control system toolbox are highlighted in red.
Introduction
This tutorial will show you the characteristics of the each of proportional (P), the integral(I), and the derivative (D) controls, and how to use them to obtain a desired response. Inthis tutorial, we will consider the following unity feedback system:
Plant: A system to be controlledController: Provides the excitation for the plant; Designed to control the overallsystem behavior
The three-term controller
The transfer function of the PID controller looks like the following:
Kp = Proportional gain
KI = Integral gain
Kd = Derivative gain
First, let's take a look at how the PID controller works in a closed-loop system using theschematic shown above. The variable (e) represents the tracking error, the differencebetween the desired input value (R) and the actual output (Y). This error signal (e) will besent to the PID controller, and the controller computes both the derivative and the integral
of this error signal. The signal (u) just past the controller is now equal to the proportionalgain (Kp) times the magnitude of the error plus the integral gain (Ki) times the integral ofthe error plus the derivative gain (Kd) times the derivative of the error.
-
8/7/2019 control systen
42/87
This signal (u) will be sent to the plant, and the new output (Y) will be obtained. Thisnew output (Y) will be sent back to the sensor again to find the new error signal (e). Thecontroller takes this new error signal and computes its derivative and its integral again.This process goes on and on.
The characteristics of P, I, and D controllersA proportional controller (Kp) will have the effect of reducing the rise time and willreduce ,but never eliminate, the steady-state error. An integral control (Ki) will have theeffect of eliminating the steady-state error, but it may make the transient response worse.A derivative control (Kd) will have the effect of increasing the stability of the system,reducing the overshoot, and improving the transient response. Effects of each ofcontrollers Kp, Kd, and Ki on a closed-loop system are summarized in the table shownbelow.
CL RESPONSE RISE TIME OVERSHOOT SETTLING TIME S-S ERROR
Kp Decrease Increase Small Change DecreaseKi Decrease Increase Increase EliminateKd Small Change Decrease Decrease Small Change
Note that these correlations may not be exactly accurate, because Kp, Ki, and Kd aredependent of each other. In fact, changing one of these variables can change the effect ofthe other two. For this reason, the table should only be used as a reference when you aredetermining the values for Ki, Kp and Kd.
Example Problem
Suppose we have a simple mass, spring, and damper problem.
The modeling equation of this system is
(1)
Taking the Laplace transform of the modeling equation (1)
http://www.engin.umich.edu/group/ctm/extras/ess/ess.htmlhttp://www.engin.umich.edu/group/ctm/extras/ess/ess.html -
8/7/2019 control systen
43/87
The transfer function between the displacement X(s) and the input F(s) then becomes
Let M = 1kg
b = 10 N.s/m
k = 20 N/m
F(s) = 1
Plug these values into the above transfer function
The goal of this problem is to show you how each of Kp, Ki and Kd contributes to obtain
Fast rise time
Minimum overshoot
No steady-state error
Open-loop step response
Let's first view the open-loop step response. Create a new m-file and add in the followingcode:
num=1;den=[1 10 20];
step(num,den)
Running this m-file in the Matlab command window should give you the plot shownbelow.
http://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.html -
8/7/2019 control systen
44/87
The DC gain of the plant transfer function is 1/20, so 0.05 is the final value of the outputto an unit step input. This corresponds to the steady-state error of 0.95, quite large indeed.Furthermore, the rise time is about one second, and the settling time is about 1.5 seconds.Let's design a controller that will reduce the rise time, reduce the settling time, andeliminates the steady-state error.
Proportional control
From the table shown above, we see that the proportional controller (Kp) reduces the risetime, increases the overshoot, and reduces the steady-state error. The closed-loop transferfunction of the above system with a proportional controller is:
Let the proportional gain (Kp) equals 300 and change the m-file to the following:
Kp=300;num=[Kp];den=[1 10 20+Kp];
t=0:0.01:2;
step(num,den,t)
Running this m-file in the Matlab command window should gives you the following plot.
http://www.engin.umich.edu/group/ctm/extras/step.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.html -
8/7/2019 control systen
45/87
Note: The Matlab function called cloop can be used to obtain a closed-loop transferfunction directly from the open-loop transfer function (instead of obtaining closed-looptransfer function by hand). The following m-file uses the cloop command that shouldgive you the identical plot as the one shown above.
num=1;den=[1 10 20];Kp=300;
[numCL,denCL]=cloop(Kp*num,den);t=0:0.01:2;
step(numCL, denCL,t)
The above plot shows that the proportional controller reduced both the rise timeand the steady-state error, increased the overshoot, and decreased the settlingtime by small amount.
Proportional-Derivative controlNow, let's take a look at a PD control. From the table shown above, we see thatthe derivative controller (Kd) reduces both the overshoot and the settling time.The closed-loop transfer function of the given system with a PD controller is:
Let Kp equals to 300 as before and let Kd equals 10. Enter the followingcommands into an m-file and run it in the Matlab command window.
Kp=300;Kd=10;num=[Kd Kp];den=[1 10+Kd 20+Kp];
http://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.html -
8/7/2019 control systen
46/87
-
8/7/2019 control systen
47/87
We have reduced the proportional gain (Kp) because the integral controller alsoreduces the rise time and increases the overshoot as the proportional controllerdoes (double effect). The above response shows that the integral controllereliminated the steady-state error.
Proportional-Integral-Derivative controlNow, let's take a look at a PID controller. The closed-loop transfer function ofthe given system with a PID controller is:
After several trial and error runs, the gains Kp=350, Ki=300, and Kd=50 providedthe desired response. To confirm, enter the following commands to an m-file andrun it in the command window. You should get the following step response.
Kp=350;Ki=300;Kd=50;
num=[Kd Kp Ki];den=[1 10+Kd 20+Kp Ki];
t=0:0.01:2;
step(num,den,t)
-
8/7/2019 control systen
48/87
Now, we have obtained the system with no overshoot, fast rise time, and nosteady-state error.
General tips for designing a PID controllerWhen you are designing a PID controller for a given system, follow the stepsshown below to obtain a desired response.
1. Obtain an open-loop response and determine what needs to be improved
2. Add a proportional control to improve the rise time
3. Add a derivative control to improve the overshoot
4. Add an integral control to eliminate the steady-state error
5. Adjust each of Kp, Ki, and Kd until you obtain a desired overall response.You can always refer to the table shown in this "PID Tutorial" page tofind out which controller controls what characteristics.
Lastly, please keep in mind that you do not need to implement all threecontrollers (proportional, derivative, and integral) into a single system, ifnot necessary. For example, if a PI controller gives a good enough response(like the above example), then you don't need to implement derivative controllerto the system. Keep the controller as simple as possible.
User FeedbackTop of Form
We would like to hear about difficulties you had with the tutorials, suggestionsyou have for improvement, errors that you found, or any other comments that youhave. This feedback is anonymous; include your email address if you want a
-
8/7/2019 control systen
49/87
reply.
Submit Feedback
Reset
PID ExamplesCruise Control | Motor Speed | Motor Position | Bus Suspension | InvertedPendulum | Pitch Controller | Ball and Beam
TutorialsBasics | Modeling | PID | Root Locus | Frequency Response | StateSpace | Digital Control | Examples
Bottom of Form
Example: Solution to the Cruise Control ProblemUsing PID control
Proportional controlPI controlPID control
The transfer function for this cruise control problem is the following,
m = 1000
b = 50
U(s) = 10
Y(s) = velocity output
and the block diagram of an typical unity feedback system is shown below.
The design criteria for this problem are:
http://www.engin.umich.edu/group/ctm/examples/cruise/ccPID.htmlhttp://www.engin.umich.edu/group/ctm/examples/motor/PID2.htmlhttp://www.engin.umich.edu/group/ctm/examples/motor2/PID2.htmlhttp://www.engin.umich.edu/group/ctm/examples/susp/PID1.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invPID.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invPID.htmlhttp://www.engin.umich.edu/group/ctm/examples/pitch/PIDpitch.htmlhttp://www.engin.umich.edu/group/ctm/examples/ball/bbPID.htmlhttp://www.engin.umich.edu/group/ctm/basic/basic.htmlhttp://www.engin.umich.edu/group/ctm/model/model.htmlhttp://www.engin.umich.edu/group/ctm/rlocus/rlocus.htmlhttp://www.engin.umich.edu/group/ctm/freq/freq.htmlhttp://www.engin.umich.edu/group/ctm/state/state.htmlhttp://www.engin.umich.edu/group/ctm/state/state.htmlhttp://www.engin.umich.edu/group/ctm/digital/digital.htmlhttp://www.engin.umich.edu/group/ctm/examples/examples.htmlhttp://www.engin.umich.edu/group/ctm/examples/cruise/ccPID.htmlhttp://www.engin.umich.edu/group/ctm/examples/motor/PID2.htmlhttp://www.engin.umich.edu/group/ctm/examples/motor2/PID2.htmlhttp://www.engin.umich.edu/group/ctm/examples/susp/PID1.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invPID.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invPID.htmlhttp://www.engin.umich.edu/group/ctm/examples/pitch/PIDpitch.htmlhttp://www.engin.umich.edu/group/ctm/examples/ball/bbPID.htmlhttp://www.engin.umich.edu/group/ctm/basic/basic.htmlhttp://www.engin.umich.edu/group/ctm/model/model.htmlhttp://www.engin.umich.edu/group/ctm/rlocus/rlocus.htmlhttp://www.engin.umich.edu/group/ctm/freq/freq.htmlhttp://www.engin.umich.edu/group/ctm/state/state.htmlhttp://www.engin.umich.edu/group/ctm/state/state.htmlhttp://www.engin.umich.edu/group/ctm/digital/digital.htmlhttp://www.engin.umich.edu/group/ctm/examples/examples.html -
8/7/2019 control systen
50/87
Rise time < 5 secOvershoot < 10%
Steady state error < 2%
To see the original problem setup, see Cruise Control Modeling page.
Recall from the PID tutorial page, the transfer function of a PID controller is
Let's first take a look at the proportional control.
Proportional control
The first thing to do in this problem is to find a closed-loop transfer function with aproportional control (Kp) added. By reducing the block diagram, the closed-loop transferfunction with a proportional controller becomes:
Recall from the PID tutorial page, a proportional controller (Kp) decreases the rise time.This is what we need, if you refer to the Cruise Control Modeling page.
For now, let Kp equals 100 and see what happens to the response. Create an new m-file and enter the following commands.
kp=100;
m=1000;b=50;u=10;num=[kp];den=[m b+kp];t=0:0.1:20;
step(u*num,den,t)axis([0 20 0 10])
Running this m-file in the Matlab command window should give you the following stepresponse.
http://www.engin.umich.edu/group/ctm/examples/cruise/cc.htmlhttp://www.engin.umich.edu/group/ctm/examples/cruise/cc.htmlhttp://www.engin.umich.edu/group/ctm/PID/PID.htmlhttp://www.engin.umich.edu/group/ctm/examples/cruise/cc.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.htmlhttp://www.engin.umich.edu/group/ctm/examples/cruise/cc.htmlhttp://www.engin.umich.edu/group/ctm/PID/PID.htmlhttp://www.engin.umich.edu/group/ctm/examples/cruise/cc.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.html -
8/7/2019 control systen
51/87
Note: You can use the Matlab command cloopto find the closed-loop response directly
from the open-loop transfer function. If you choose to do so, change the m-file to thefollowing and run it in the command window. You should get the same plot as the oneshown above.
kp=100;m=1000;b=50;u=10;num=[1];den=[m b];
[numc,denc]=cloop(kp*num,den,-1);t = 0:0.1:20;
step (u*numc,denc,t)axis([0 20 0 10])
As you can see from the plot, both the steady-state error and the rise time do not satisfyour design criteria. You can increase the proportional gain (Kp) to improve the systemoutput. Change the existing m-file so that Kp equal 10000 and rerun it in the Matlabcommand window. You should see the following plot.
-
8/7/2019 control systen
52/87
The steady-state error has dropped to near zero and the rise time has decreased to less
than 0.5 second. However, this response is unrealistic because a real cruise controlsystem generally can not change the speed of the vehicle from 0 to 10 m/s in less than 0.5second.
The solution to this problem is to choose a proportional gain (Kp) that will give areasonable rise time, and add an integral controller to eliminate the steady-state error.
PI control
The closed-loop transfer function of this cruise control system with a PI controller is:
Recall from the PID tutrial page, an addition of an integral controller to the systemeliminates the steady-state error. For now, let Kp equals 600 and Ki equals 1 and seewhat happens to the response. Change yourm-file to the following.
kp = 600;ki = 1;m=1000;b=50;u=10;num=[kp ki];
den=[m b+kp ki];t=0:0.1:20;
step(u*num,den,t)axis([0 20 0 10])
Note: If you choose to obtain the closed-loop response directly from the open-looptransfer function, enter the following commands instead of the ones shown above:
kp=600;
http://www.engin.umich.edu/group/ctm/PID/PID.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.htmlhttp://www.engin.umich.edu/group/ctm/PID/PID.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.html -
8/7/2019 control systen
53/87
ki=1;m=1000;b=50;u=10;num=[1];den=[m b];num1=[kp ki];den1=[1 0];num2=conv(num,num1);den2=conv(den,den1);
[numc,denc]=cloop(num2,den2,-1);t=0:0.1:20;
step(u*numc,denc,t)axis([0 20 0 10])
Whichever the m-file you run, you should get the following output:
Now adjust both the proportional gain (Kp) and the integral gain (Ki) to obtain thedesired response. When you adjust the integral gain (Ki), we suggest you to start with asmall value since large (Ki) most likely unstabilize the response.
With Kp equals 800 and Ki equals 40, the step response will look like the following:
-
8/7/2019 control systen
54/87
-
8/7/2019 control systen
55/87
observe how changing one variable influences the system output. The characteristics ofKp, Kd, and Ki are summarized in the PID Tutorial page.
Example: PID Design Method for DC Motor
Speed ControlProportional controlPID controlTuning the gains
From the main problem, the dynamic equations and the open-loop transfer function of theDC Motor are:
and the system schematic looks like:
For the original problem setup and the derivation of the above equations, please refer tothe Modeling a DC Motorpage.
With a 1 rad/sec step input, the design criteria are:
Settling time less than 2 seconds
Overshoot less than 5%
Steady-stage error less than 1%Now let's design a PID controller and add it into the system. First create a new m-file andtype in the following commands (refer to the Modeling page for the details of gettingthese commands).
J=0.01;b=0.1;K=0.01;R=1;
http://www.engin.umich.edu/group/ctm/examples/motor/motor.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/examples/motor/motor.htmlhttp://www.engin.umich.edu/group/ctm/examples/motor/motor.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/examples/motor/motor.html -
8/7/2019 control systen
56/87
L=0.5;num=K;den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)];
Recall that the transfer function for a PID controller is:
Proportional control
Let's first try using a proportional controller with a gain of 100. Add the following codeto the end of your m-file:
Kp=100;numa=Kp*num;dena=den;
To determine the closed-loop transfer function, we use the cloop command. Add thefollowing line to your m-file:
[numac,denac]=cloop(numa,dena);Note that numac and denac are the numerator and the denominator of the overall closed-loop transfer function.
Now let's see how the step response looks, add the following to the end of your m-file,and run it in the command window:
t=0:0.01:5;step(numac,denac,t)title('Step response with Proportion Control')
You should get the following plot:
PID control
http://www.engin.umich.edu/group/ctm/extras/step.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.html -
8/7/2019 control systen
57/87
From the plot above we see that both the steady-state error and the overshoot are toolarge. Recall from the PID tutorialpage that adding an integral term will eliminate thesteady-state error and a derivative term will reduce the overshoot. Let's try a PIDcontroller with small Ki and Kd. Change your m-file so it looks like the following.Running this new m-file gives you the following plot.
J=0.01;b=0.1;K=0.01;R=1;L=0.5;num=K;den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2)];
Kp=100;Ki=1;Kd=1;numc=[Kd, Kp, Ki];
denc=[1 0];numa=conv(num,numc);dena=conv(den,denc);[numac,denac]=cloop(numa,dena);step(numac,denac)title('PID Control with small Ki and Kd')
Tuning the gains
Now the settling time is too long. Let's increase Ki to reduce the settling time. Go back toyour m-file and change Ki to 200. Rerun the file and you should get the plot like this:
http://www.engin.umich.edu/group/ctm/PID/PID.htmlhttp://www.engin.umich.edu/group/ctm/PID/PID.htmlhttp://www.engin.umich.edu/group/ctm/PID/PID.html -
8/7/2019 control systen
58/87
Now we see that the response is much faster than before, but the large Ki has worsenedthe transient response (big overshoot). Let's increase Kd to reduce the overshoot. Go backto the m-file and change Kd to 10. Rerun it and you should get this plot:
So now we know that if we use a PID controller with
-
8/7/2019 control systen
59/87
-
8/7/2019 control systen
60/87
L=2.75E-6;num=K;den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0];
Recall that the transfer function for a PID controller is:
Proportional control
Let's first try using a proportional controller with a gain of 1.7. Add the following code tothe end of your m-file:
Kp=1.7;numcf=[Kp];dencf=[1];numf=conv(numcf,num);denf=conv(dencf,den);
To determine the closed-loop transfer function, we use the cloop command. Add thefollowing line to your m-file:
[numc,denc]=cloop(numf,denf);
Note that numc and denc are the numerator and the denominator of the overall closed-looptransfer function.
Now let's see how the step response looks. Add the following to the end of your m-file,and run it in the command window:
t=0:0.001:0.2;step(numc,denc,t)
You should get the following plot:
Now lets take a look at the step disturbance response. Add the following to the end ofyour m-file, and run it in the command window:
http://www.engin.umich.edu/group/ctm/extras/step.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.html -
8/7/2019 control systen
61/87
numdcl=conv(numc,1);dendcl=conv(denc,Kp);step(numdcl,dendcl,t);
You should get the following plot:
PID control
From the plots above we see that although the steady-state error looks good the settlingtime is too large, as is the overshoot. We also see that the steady-state error to adisturbance is large. Recall from PID tutorial page that adding an integral term willeliminate the steady-state error and a derivative term will reduce the overshoot. Let's first
try a PI controller to get rid of the disturbance steady state error. Change your m-file so itlooks like:
J=3.2284E-6;b=3.5077E-6;K=0.0274;R=4;L=2.75E-6;num=K;den=[(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0];
Kp=1.7;Ki=20;
numcf=[Kp Ki];dencf=[1 0];numf=conv(numcf,num);denf=conv(dencf,den);[numc,denc]=cloop(numf,denf,-1);t=0:0.001:0.4;step(numc,denc,t)
You should get the following step response:
http://www.engin.umich.edu/group/ctm/PID/PID.htmlhttp://www.engin.umich.edu/group/ctm/PID/PID.html -
8/7/2019 control systen
62/87
Lets see what happened to the step disturbance response, add the following to your m-file:
figurenumdcl=conv(numc,dencf);dendcl=conv(denc,numcf);step(numdcl,dendcl,t);
You should get the following plot:
Tuning the gains
The settling time is still too long. Let's increase the gains in order to speed up theresponse. Go back to your m-file and change Ki to 200 and Kp to 17. Rerun the file andyou should get plots like these:
-
8/7/2019 control systen
63/87
Now we see that the response is faster than before, but the large Ki has worsened thetransient response (big overshoot). Let's now try a PID controller to reduce the overshoot.Go back to the m-file and make the following changes to look at the step response.
Kp=17;
Ki=200;Kd=0.15;numcf=[Kd Kp Ki];dencf=[1 0];numf=conv(numcf,num);denf=conv(dencf,den);[numc,denc]=cloop(numf,denf,-1);t=0:0.001:0.1;step(numc,denc,t)
-
8/7/2019 control systen
64/87
Rerun it and you should get this plot:
Your step disturbance plot should look like this:
We now see that our step response looks really good, it has less than 16% overshoot and
the settling time is roughly 40ms, and there is no steady-state error. However the stepdisturbance response is now really slow. Lets increase Ki to speed up the disturbanceresponse. Change Ki to 600 in your m-file and rerun the file. You should get thefollowing plots:
-
8/7/2019 control systen
65/87
We now can see that the step response has a settling time of roughly 40ms, it has lessthan 16% overshoot, and it has no steady state error. The step disturbance response alsohas no steady state error. So now we know that if we use a PID controller with
Kp=17,Ki=600,Kd=.15,
all of our design requirements will be satisfied.
-
8/7/2019 control systen
66/87
Example:PID Design Method for the BusSuspension System
Adding a PID controller
Plotting the closed-loop responseChoosing the gains for the PID controller
From the main problem, the dynamic equations in transfer function form are thefollowing:
and the system schematic looks like:
For the original problem setup and the derivation of the above equations and schematic,please refer to the bus modeling page.
We want to design a feedback controller so that when the road disturbance (W) issimulated by a unit step input, the output (X1-X2) has a settling time less than 5 secondsand an overshoot less than 5%. For example, when the bus runs onto a 10 cm high step,the bus body will oscillate within a range of +/- 5 mm and will stop oscillating within 5seconds.
The system model can be represented in Matlab by creating a new m-file and entering thefollowing commands (refer to main problem for the details of getting those commands).
m1=2500;m2=320;
http://www.engin.umich.edu/group/ctm/examples/susp/susp.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/examples/susp/susp.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.html -
8/7/2019 control systen
67/87
k1 = 80000;k2 = 500000;b1 = 350;b2 = 15020;
nump=[(m1+m2) b2 k2]denp=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2) (b1*k2)+(b2*k1) k1*k2]
num1=[-(m1*b2) -(m1*k2) 0 0]den1=[(m1*m2) (m1*(b1+b2))+(m2*b1) (m1*(k1+k2))+(m2*k1)+(b1*b2) (b1*k2)+(b2*k1) k1*k2]
numf=num1;denf=nump;
Adding a PID controller
Recall that the transfer function for a PID controller is:
where KP is the proportional gain, KI is the integral gain, and KD is the derivative gain.Let's assume that we will need all three of these gains in our controller. To begin, wemight start with guessing a gain for each: KP=208025, KI=832100 and KD=624075.This can be implemented into Matlab by adding the following code into your m-file:
KD=208025;KP=832100;KI=624075;numc=[KD,KP,KI];
denc=[1 0];Now let's simulate the response of the system (the distanceX1-X2) to a step disturbance on the road.From the schematic above we can find the transfer function from the road disturbanceWto theoutput(X1-X2):
This transfer function can be modeled in Matlab by adding the following code into your m-file:numa=conv(conv(numf,nump),denc);dena=conv(denf,polyadd(conv(denp,denc),conv(nump,numc)));
http://www.engin.umich.edu/group/ctm/extras/polyadd.htmlhttp://www.engin.umich.edu/group/ctm/extras/polyadd.html -
8/7/2019 control systen
68/87
Note that the function "polyadd" is not a standard function in Matlab; you will need to copy it to anew m-file to use it. Clickherefor more information on defining new functions in Matlab.
Refer to the bus modeling page, nump = denf as we can see in the matlab commandabove. Thus we can simplified this transfer function to be the following:
numa=conv(numf,denc);dena=polyadd(conv(denp,denc),conv(nump,numc));
Plotting the closed-loop response
Now we have created the closed-loop transfer function in Matlab that will represent theplant, the disturbance, as well as the controller. Let's see what the closed-loop stepresponse for this system looks like before we begin the control process. Keep in mind thatwe are going to use a 0.1 m high step as our disturbance, to simulate this, all we need todo is to multiply numa by 0.1. Add the following code into your m-file:
t=0:0.05:5;step(0.1*numa,dena,t)title('closed-loop response to 0.1m high step w/ pid controller')
you should see the response (X1-X2) to a step W like this:
From the graph, the percent overshoot = 9%, which is 4% larger than the requirement, but thesettling time is satisfied, less than 5 seconds. To choose the proper gain that yields reasonable outputfrom the beginning, we start with choosing a pole and two zeros for PID controller. A pole of thiscontroller must be at zero and one of the zeros has to be very close to the pole at the origin, at 1. Theother zero, we will put further from the first zero, at 3, actually we can adjust the second-zero'sposition to get the system to fulfill the requirement. Add the following command in the m-file, so
http://www.engin.umich.edu/group/ctm/extras/polyadd.htmlhttp://www.engin.umich.edu/group/ctm/extras/function.htmlhttp://www.engin.umich.edu/group/ctm/extras/polyadd.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.htmlhttp://www.engin.umich.edu/group/ctm/extras/polyadd.htmlhttp://www.engin.umich.edu/group/ctm/extras/function.htmlhttp://www.engin.umich.edu/group/ctm/extras/polyadd.htmlhttp://www.engin.umich.edu/group/ctm/extras/step.html -
8/7/2019 control systen
69/87
-
8/7/2019 control systen
70/87
To compare this graph with the graph of low-gain PID controller, you can change theaxis:
axis([0 5 -.01 .01])
Now we see that the percent overshoot and settling time meet the requirements of the system. The
http://www.engin.umich.edu/group/ctm/extras/axishttp://www.engin.umich.edu/group/ctm/extras/axis -
8/7/2019 control systen
71/87
percent overshoot is about 5% of the input's amplitude and settling time is 2 seconds less than 5seconds from requirement.
For this problem, it turns out that the PID design method adequately controls the system.This can been seen by looking at the root locus plot. Such a task can be achieved bysimply changing only the gains of a PID controller. Feel free to play around with all three
of the parameters,KD,KP and KI, as we suggested, but you will most likely get theresponse to have either large percent overshoot or very long settling time. But if you dofind a good PID design, please email us with your results! We are always interested indifferent ways to solve our examples; we may include your solution in a future version ofthese tutorials.
Example: Solution to the Inverted PendulumProblem Using PID Control
Open-loop Representation
Closed-loop transfer functionAdding the PID controllerWhat happens to the cart's position?
The transfer function of the plant for this problem is given below:
where,
The design criteria (with the pendulum receiving a 1N impulse force from the cart) are:
Settling time of less than 5 seconds.
Pendulum should not move more than 0.05 radians away from the vertical.
To see how this problem was originally set up, consult the inverted pendulummodeling page.
Open-loop Representation
mailto:[email protected]://www.engin.umich.edu/group/ctm/examples/pend/invpen.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invpen.htmlmailto:[email protected]://www.engin.umich.edu/group/ctm/examples/pend/invpen.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invpen.html -
8/7/2019 control systen
72/87
The first thing to do when using PID control in Matlab is to find the transfer function ofthe system and to check to see if it makes sense. The transfer function found from theLaplace transforms for the output Phi (the pendulum's angle) can be set up using Matlabby inputting the numerator and denominator as vectors. Create anm-file (or a '.m' filelocated in the same directory as Matlab) and copy the following text to model the transfer
function:
M = .5;m = 0.2;b = 0.1;i = 0.006;g = 9.8;l = 0.3;
q = (M+m)*(i+m*l^2)-(m*l)^2; %simplifies input
num = [m*l/q 0]den = [1 b*(i+m*l^2)/q -(M+m)*m*g*l/q -b*m*g*l/q]
Your output should be:
num =
4.5455 0
den =
1.0000 0.1818 -31.1818 -4.4545
Closed-loop transfer function
The control of this problem is a little different than the standard control problems youmay be used to. Since we are trying to control the pendulum's position, which shouldreturn to the vertical after the initial disturbance, the reference signal we are trackingshould be zero. The force applied to the cart can be added as an impulse disturbance. Theschematic for this problem should look like the following.
It will be easier to determine the appropriate transfer function to enter into Matlab if wefirst rearrange the schematic as follows:
http://www.engin.umich.edu/group/ctm/extras/mfile.htmlhttp://www.engin.umich.edu/group/ctm/extras/mfile.html -
8/7/2019 control systen
73/87
Now, we can find the closed-loop transfer function.
Adding the PID controller
This closed-loop transfer function can be modeled in Matlab by copying the followingcode to the end of your m-file (whether your using the transfer function from the Laplacetransforms or from the state-space representation):
kd = 1;k = 1;ki = 1;numPID = [kd k ki];denPID = [1 0];numc = conv(num,denPID)denc = polyadd(conv(denPID,den),conv(numPID,num))
Note: Non-standard Matlab commands used in this example are highlighted in green.
The function polyadd is not in the Matlab toolbox. You will have to copy it to a new m-file to use it. This transfer function assumes that both derivative and integral control willbe needed along with proportional control. This does not have to be the case. If youwanted to start with PI control, just remove the kd term fromnumPID. If you wanted to startwith PD control, just remove the ki term from numPID and change denPID to equal [1].Assuming you do not change the PID control, you should get the following closed-loopnumerator and denominator in the Matlab command window:
numc =4.5455 0 0
denc =
1.0000 4.7273 -26.6363 0.0910 0
Now we can begin the actual control of this system. First let's see what the impulseresponse looks like with the numbers we already have. Enter the following code to theend of your m-file:
http://www.engin.umich.edu/group/ctm/extras/function.htmlhttp://www.engin.umich.edu/group/ctm/extras/polyadd.htmlhttp://www.engin.umich.edu/group/ctm/extras/function.htmlhttp://www.engin.umich.edu/group/ctm/extras/polyadd.html -
8/7/2019 control systen
74/87
t=0:0.01:5;
impulse(numc,denc,t)axis([0 1.5 0 40])
You should get the following velocity response plot from the impulse disturbance:
This response is still not stable. Let's start by increasing the proportional control to thesystem. Increase the k variable to see what effect it has on the response. If you set k=100,and set the axis to axis([0, 2.5, -0.2, 0.2]), you should get the following velocityresponse plot:
-
8/7/2019 control systen
75/87
The settling time is acceptable at about 2 seconds. Since the steady-state error has alreadybeen reduced to zero, no more integral control is needed. You can remove the integralgain constant to see for yourself that the small integral control is needed. The overshoot istoo high, so that must be fixed. To alleviate this problem, increase the kd variable.With kd=20, you should get a satisfactory result. You should now see the followingvelocity response plot:
-
8/7/2019 control systen
76/87
As you can see, the overshoot has been reduced so that the pendulum does not movemore than 0.05 radians away from the vertical. All of the design criteria have been met,so no further iteration is needed.
What happens to the cart's position?
At the beginning on this solution page, the block diagram for this problem was given.The diagram was not entirely complete. The block representing the the position was leftout because that variable was not being controlled. It is interesting though, to see what ishappening to the cart's position when the controller for the pendulum's angle is in place.To see this we need to consider the actual system block diagram:
Rearranging a little bit, you get the following block diagram:
The feedback loop represents the controller we have designed for the pendulum's. Thetransfer function from the cart's position to the impulse force, with the PID feedbackcontroller which we designed, is given as follows:
Recall that den1=den2 if the pole/zero at the origin that was cancelled is added back in.So the transfer function from X to F can be simplified to:
-
8/7/2019 control systen
77/87
Now that we have the transfer function for the entire system, let's take a look at theresponse. First we need the transfer function for the cart's position. To get this we need togo back to the laplace transforms of the system equations and find the transfer functionfrom X(s) to U(s). Below is this transfer function:
where,
For more about the Laplace transform please refer to the inverted pendulummodeling page.
The pole/zero at the origin cancelled out of the transfer function for Phi, has been putback in. So that now den1 = den2, making calculations easier. Now, create a new m-fileand run it in the command window:
M = .5;m = 0.2;b = 0.1;i = 0.006;g = 9.8;l = 0.3;
q = (M+m)*(i+m*l^2)-(m*l)^2; %simplifies input
num1 = [m*l/q 0 0];den1 = [1 b*(i+m*l^2)/q -(M+m)*m*g*l/q -b*m*g*l/q 0];
num2 = [(i+m*l^2)/q 0 -m*g*l/q];den2 = den1
kd = 20;k = 100;ki = 1;numPID = [kd k ki];denPID = [1 0];
numc = conv(num2,denPID);
denc = polyadd(conv(denPID,den2),conv(numPID,num1));
http://www.engin.umich.edu/group/ctm/examples/pend/invpen.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invpen.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invpen.htmlhttp://www.engin.umich.edu/group/ctm/examples/pend/invpen.