Control Systems Lab Manual - With Challenging Experiments
Control Systems Lab Manual - With Challenging Experiments
Laboratory
Manual
B18EC4050
IV Semester
B18EC4050 L T P C
Control Systems Lab
Duration :14 Wks 2 1 1 4
Prerequisites:
Course Outcomes:
After completion of the course a student will be able to:
1. Apply the concept of modeling of systems for simple mechanical and electrical system. (a, b,
d, j)
2. Able to write the Transfer function using various techniques like using differential equations,
Block diagrams, signal flow graphs.(a, b, c, d,j)
3. Able to apply time domain and frequency domain analyses technique to determine stability of
system. (a, b, d, j)
4. Able to design the stable system. (a, b, c,d, j)
5. Able to model a system in state space and solve state space equation.(a, b, d, j).
CONTENTS
PART – A
PART – B
Introduction
In studying control system the reader must be able to model dynamic system and analyze dynamic
characteristics. A mathematical model of dynamic system is defined as set of equations that represents
the dynamics of the system accurately or fairly well. Mathematical model is not unique to a given
system. A system may be represented in many different ways and therefore may have many
mathematical models, depending on once prospective.
The dynamics of many systems whether they are mechanical, electrical, thermal economic, biological
and so on may be described in terms of differential equations. Such differential equations are obtained
by using physical laws governing a particular system. For example Newton’s law for mechanical
system and Kirchhoff’s law for electrical system.
Transfer Function
The transfer function Of a linear time invariant differential equation is defined as the ratio of the
Laplace transform of the output (response function) to the Laplace transform of the input (driving
function) under the assumption that all initial conditions are zero.
Question: Why Time domain equations (differentiation equations) are transformed to ‘S’ domain?
Block Diagram
A functional block or simply the block is a symbol for mathematical operation on input signal to the
block that produces output.
Transfer Function.
R(s) C(s)
G(s)
The transfer function of the components are usually entered in the corresponding block which are
connected by arrows to indicate direction of flow of signals .The signal can pass only in the direction
of the arrows.
Question: What are the advantages of writing the block diagram of system?
Control systems are generally called upon to perform both under transient (dynamic) and steady state
conditions. In order to analyze the transient and steady state behaviour(these together referred as of
the system time response) of control systems, the first step is to obtain mathematical model. For any
specific input signal complete time response can be obtained through Laplace transform inversion (or
through convolution integral in case the input is such that we cannot obtain its Laplace transform).
Usually the control signal to control system are not known fully ahead of time. In most cases the
signals may be random in nature, e.g, in radar tracking system, the position and speed of target to be
tracked may vary in random fashion. It is thus difficult to express the actual input signals
mathematically by simple equations. The characteristics of actual signals which severely strain a
control system are sudden shock, a sudden change, a constant velocity and a constant acceleration.
System dynamic behaviour for analysis and design is therefore judged and compared under
application of standard test signals-an impulse, a step, a constant velocity(a ramp input) and constant
acceleration(a parabolic input).
The nature of transient response is revelled by any one of these test signals as this nature dependent
upon system poles and not upon type of input signal.
It is therefore sufficient to analyze transient response to any one of the test signals-a step is generally
used for this purpose as this signal can be easily generated. Steady state response is then examined to
step as well as other test signals; the ramp and parabolic signal.
The time response performance of control system is measured by computing several response
performance indices as well as steady state accuracy for the standard input signals. These indices give
a quantitative method to compare the performance of alternative system configurations or to adjust
the parameter of a given system. As a given parameter is varied, various performance indices may
change in conflicting manner .The best parameter choice would thus be the best compromising
solution. Certain of the parameter indices may be specified as a upper and lower bounds in a design.
(Ref: Control Systems Engineering by I.J Nagarath M Gopal 5th edition: page 194 ,195,196,197)
Standard test signal r(t) Mathematical expression in time domain Laplace Transform
Step input r(t)=Au(t) 𝐴
u(t)=1;t>0 𝑅 (𝑆 ) =
𝑆
u(t)=0;t<0
Ramp Input R(t)=At;t>0 𝐴
=0;t<0 𝑅 (𝑆 ) =
𝑆2
Parabolic input 𝐴𝑡 2 𝐴
𝑅(𝑡) = 2 ;t>0 𝑅 (𝑆 ) =
𝑆3
=0 ; t<0
Impulse input δ(t) = 0; t≠0 𝑅 (𝑆 ) = 1
ℇ
∫ δ(t)dt = 1
−ℇ
𝐶(𝑠) 𝑝(𝑠) 𝜔𝑛 2
= =
𝑅(𝑠) 𝑞(𝑠) 𝑠 2 + 2𝜁𝜔𝑛 𝑠 + 𝜔𝑛 2
Note: The time response of any system is characterized by roots of denominator polynomial q(s),
which in fact poles of transfer function. The denominator polynomial is therefore called
characteristic equation.
ζ Roots Damping
values
ζ<1 −𝜁𝜔𝑛 ± 𝑗 𝜔𝑛 √(1 − 𝜁 2 Under damped 𝜔𝑑 = 𝜔𝑛 √(1 − 𝜁 2
=−𝜁𝜔𝑛 ± 𝑗𝜔𝑑 Is called damped natural
Roots are complex and frequency.Transient response
conjugate exhibits an oscillation which
amplitude decreases with time.
ζ>1 The roots are real Over damped Transient response exhibits no
oscillation when amplitude
decreases with time.
ζ=1 The roots are real and equal Critically damped Highest possible speed of
response and yet non
oscillatory.
(Robotic control system shall
be designed to have damping
factor of ζ=1(or close to it but
less than unity)
The step response of second order system is characterized by following performance indices.
(i) How fast the system moves to follow the input?
(ii) How oscillatory it is(indicative of damping)
(iii) How long does it take to practically reach the final value.
1. Delay time 𝑡𝑑 : It is the time required for the response to reach 50% of final value in first attempt.
2. Rise time𝑡𝑟 : It is the time required for the response to rise from 10% to 90% of the final value
for over damped system and 0 to 100% of final value for under damped systems.
3. Peak value 𝑡𝑝 : It is the time required for the response to reach the peak of time response or peak
overshoot.
4. Peak overshoot 𝑀𝑝 :It indicates the normalized difference between the time response peak and
it is defined as
𝐶(𝑡𝑝 )−𝐶(∞)
Peak percent overshoot= x100%
𝐶(∞)
In most control system (except type-0) the steady output for step input is same as input.For
example ,for second order system 𝐶 (∞) = 𝐶𝑠𝑠 = 1 i.e is same as input.
5. Settling time 𝑡𝑠 : It is the time required for the response to reach and stay within a specified
tolerance band(usually 2% or 5% of final value).
Settling time 𝟒
𝒕𝒔 =𝜻𝝎
𝒏
Steady state error 𝟐𝜻
𝒆𝒔𝒔 =𝝎
𝒏
Applications developed in LabVIEW are called VI's (VI stands for Virtual
Instrument )
Experiment-1
Time Response of First order
Introduction:
The dynamics of many systems of interest to engineers may be represented by a simple model
containing one independent energy storage element.
Exercise: To build mathematical modeling of Electrical system and to obtain time response.
Aim:
𝑑𝑖
𝑢(𝑡) = 𝐿 + 𝑅 𝑖 : u(t)=Unit step input
𝑑𝑡
Problem statement: Simulate unit step response of series RL circuit when output is taken across
Resistor using LabVIEW.
o
Right click at input terminal of CD construct transfer function model.VI Create Control
Create control for both numerator and denominator.
Right click on Block diagram window control and simulations control design model
construction CD draw transfer function model.VI connect with CD construct transfer function
model.VI
Right click on the equation terminal of the CD draw transfer function model.VI create Indicator
(rename label)
Right click on Block diagram window control and simulations control design Time
response CD step response.VI place the block on Block diagram window.
Wire from the CD construct transfer function model.VI to input terminal of CD step
response.VIChoose polymorphic instance to be automatic.
Right click on output terminal of CD step response.VI Create Indicator.
Right click on Block Diagram control and simulations control design Time response
CD parametric time response.VIPlace it on the Block Diagram window.
Wire the output data from CD construct transfer function.VI to CD parametric time response.VI
Right click on second output terminal of CD parametric time response.VI create Indicator.
Assign values for numerator and denominator as per the TF model.
Figure1: Block Diagram Panel Display of First Order System Time Response:
Where R=1 Ohm and L=1 Henry
Figure2: Front Panel Display of First Order System Time Response: Where R=1 Ohm and
L=1 Henry
Tabular Column:
Output is taken across Resistor (R)
Result:
Challenge level 1:
1. Plot unit step response of RL circuit if output is taken across inductor
(i) R=2 ohm, L= 1 henry
(ii) R=2 ohm, L= 2 henry
(i) R=1 ohm, L= 2 henry
2. Why decaying curve?
1. Comment on time constant and gain of RL series circuit.
2. Consider series RC circuit and plot step resp
Exercise Question:
Order of system
Identify poles, zeros and gain of RL circuit.
What is the relation between order of equation and number of roots of equation?
EXPERIMENT-2
Time response of Second order system
Aim:
Theory:
𝑋(𝑠) 1
= 2
𝐹(𝑠) 𝑠 + 𝑠 + 1
𝑑𝑖 1
𝑢 (𝑡 ) = 𝐿 + 𝑅𝑖+ ∫ 𝑖 𝑑𝑡.
𝑑𝑡 𝐶
u(t) = Unit step input
1 1
= 𝐿𝑠 𝐼 (𝑠) + 𝑅 𝐼(𝑠) + 𝐼 (𝑠)
𝑠 𝐶𝑠
1 𝐶 1/𝐿
𝐼 (𝑠) = = =
1 𝐿𝐶𝑠 2 + 𝑅𝐶𝑠 + 1 𝑠 2 + 𝑅 𝑠 + 1
𝐿𝑠 2 + 𝑅𝑠 +
𝐶 𝐿 𝐿𝐶
1 1 1/𝐿 1/𝐿𝐶𝑠
𝑉 𝑜 (𝑠) = 𝐼 (𝑠) = =
𝐶𝑠 (𝐶𝑠) 𝑠 2 + 𝑅 𝑠 + 1 𝑅
𝑠2 + 𝑠 +
1
𝐿 𝐿𝐶 𝐿 𝐿𝐶
Therefore Transfer function is:
𝟏/𝑳𝑪𝒔
𝟏 𝑹 𝟏
𝑽𝒐(𝒔) 𝑰(𝒔) 𝒔𝟐 + 𝑳 𝒔 + 𝑳𝑪 𝟏/𝑳𝑪
= 𝑪𝒔 = =
𝑽𝒊 (𝒔) 𝐔(𝐬) 𝟏 𝑹 𝟏
𝒔𝟐 + 𝒔 +
𝒔 𝑳 𝑳𝑪
Problem statement:
Simulate unit step response of series RLC circuit when output is taken across Capacitor
using LabVIEW for the following Parameter Values.
o
Right click at input terminal of CD construct transfer function model.VI Create Control
Create control for both numerator and denominator.
Right click on BD control and simulations control design model construction CD draw
transfer function model.VI connect with CD construct transfer function model.VI
Right click on the equation terminal of the CD draw transfer function model.VI create Indicator
(rename label)
Right click on BD control and simulations control design Time response CD step
response.VI place the block on BD.
Wire from the CD construct transfer function model.VI to input terminal of CD step
response.VIChoose polymorphic instance to be automatic.
Right click on Block Diagram control and simulations control design Time response
CD parametric time response.VIPlace it on the Block Diagram window.
Wire the output data from CD construct transfer function.VI to CD parametric time response.VI
Right click on second output terminal of CD parametric time response.VI create Indicator.
Figure1: Block Diagram Panel Display of Second Order System Time Response: Where R=1
Ohm, L=1 Henry and C=1Farad
Figure2: Front Panel Display of Second Order System Time Response: Where R=1 Ohm,
L=1 Henry and C=1 Farad.
Tabular Column:
Transfer function
R in L in C in O/P across R Rise Settling Response
ohms Henry Farad 𝑻𝑭 Time % Time (Draw Remarks
𝟏 (0-90% Overshoot ( 2% of the
𝑳𝑪 tp in
= of final Graph)
𝑹 𝟏 Sec
(𝒔𝟐 + 𝒔 + ) final value)
𝑳 𝑳𝑪
value)
Result:
Challenge: Level-1
EXPERIMENT-3
Stability Analysis Based on Pole Position
Aim:
To demonstrate relation between pole position on‘s’ plane and BIBO stability of system.
Introduction:
For our purposes, we will use the Bounded Input Bounded Output (BIBO) definition of
stability which states that a system is stable if the output remains bounded for all bounded (finite)
inputs. Practically, this means that the system will not “blow up” while in operation.
The transfer function representation is especially useful when analyzing system stability. If
all poles of the transfer function (values of s at which the denominator equals zero) have negative
real parts, then the system is stable. If any pole has a positive real part, then the system is unstable. If
we view the poles on the complex s-plane, then all poles must be in the left half plane (LHP) to ensure
stability. If any pair of poles is on the imaginary axis, then the system is marginally stable and the
system will oscillate.
DC Gain
The DC gain, , again is the ratio of the magnitude of the steady-state step response to the magnitude
of the step input, and for stable systems it is the value of the transfer function when . For second
order systems,
Damping Ratio
The damping ratio is a dimensionless quantity charaterizing the energy losses in the system due to
such effects as viscous friction or electrical resistance. From the above definitions,
Natural Frequency
The natural frequency is the frequency (in rad/s) that the system will oscillate at when there is no
damping, .
Poles/Zeros
The second order transfer function has two poles .
Procedure to Simulate Pole Zero map for underdamped systems ( zeta<1) using LabVIEW
The given transfer function has coefficients as variables, there for the TF model has to be
implemented in LabVIEW symbolically.
Open LabVIEW File New VI.
Right click on Block Diagram window control and simulations control design model
construction CD construct transfer function model.VI place the block on the Block
diagram window.
Choose from the polymorphic instance single-input single-output (symbolically).
Create controls for the CD construct transfer function model.VI Rclick on input terminals
of CD construct transfer function model.VI create control. (create controls for
numerator, denominator and variables)
Right click on Block Diagram window control and simulations control design model
construction CD draw transfer function model.VI wire to CD construct transfer function
model.VI
Right click on the output terminal of CD draw transfer function model.VI create
indicatorrename the indicator to be TF model
Right click on Block Diagram window control and simulations control design
dynamic response CD pole-zero map.VI place it on the block diagram
Right click on the output terminals of CD pole-zero map.VI create indicators for pole zero
map, poles and zeros.
Right click on Block Diagram window control and simulations control design Time
response CD step response.VI place the block on Block diagram window
Wire from the CD construct transfer function model.VI to input terminal of CD step
response.VIChoose polymorphic instance to be automatic.
Right click on output terminal of CD step response.VI Create Indicator.
Wire the error in and error out wires (optional)
Input the values in the FP as per the given TF model.
Assign the symbolic numerator and denominator with the given TF equation.
Resize the variables window so that it has three variable names and values to be entered.
Adjust the pole zero map by reentering the x-scale and y-scale.
Figure2: Front panel display to plot pole zero map of underdamped system
Figure3: Front panel display to plot pole zero map of Over damped system
Figure4: Front panel display to plot pole zero map of critically damped system
Undamped Systems
If , then the system is undamped. In this case, the poles are purely imaginary; therefore the
system is marginally stable and oscillates indefinitely.
Simulate Pole Zero map for undamped system( zeta=0)
Figure5: Front panel display to plot pole zero map of Undamped system
𝐾 𝑑𝑐 𝜔𝑛 2
Result: The transient response of TF G= 𝑠 2 +2𝜁𝜔 2 with step input and the following
𝑛 𝑠+𝜔𝑛
damping are
a) k_dc = 1;w_n = 10; zeta = 0.2 the
(i) The peak amplitude=
(ii) The rise time=
(iii) Settling time=
b) k_dc = 1;w_n = 10; zeta = 1.2 the
(i) The peak amplitude=
(ii) The rise time=
(iii) Settling time=
c) k_dc = 1;w_n = 10; zeta = 1 the
(i) The peak amplitude=
(ii) The rise time=
(iii) Settling time=
d) k_dc = 1;w_n = 10; zeta = 0 the
(i) The peak amplitude=
(ii) The rise time=
(iii) Settling time=
Experiment 4
Stability Analysis of system using Bode Plot
AIM: To obtain bode plot for a given transfer function of the system using LabVIEW and to find
stability of system.
Content:
Bode calculations
Terms used in bode plot
Slopes contributed by various factors in transfer function.
Stability conditions of bode plot.
THEORY:
Bode plots are used to analyze system properties such as the gain margin, phase margin, DC gain,
bandwidth and stability. A Bode diagram consists of two graphs: the magnitude plot and the phase
plot. The magnitude is plotted in decibels (dB), and the phase in degrees against the frequency on a
logarithmic scale.. The decibel calculation for mag is computed as 20log 10(|G(jw)|), where G(jw) is
the system's frequency response.
Bode Calculations :
The open loop transfer function of a closed loop control system can be expressed in the form
Substituting s = jω,
2. Phase Margin: Greater will the phase margin greater will be the stability of the system. It
refers to the phase which can be increased or decreased without making the system unstable. It
is usually expressed in phase.
3. Gain Cross Over Frequency: It refers to the frequency at which magnitude curve cuts the zero
dB axis in the bode plot.
4. Phase Cross Over Frequency: It refers to the frequency at which phase curve cuts the negative
times the 180 degree axis in this plot.
5. Corner Frequency: The frequency at which the two asymptotes cuts or meet each other is
known as break frequency or corner frequency.
6. Resonant Frequency: The value of frequency at which the modulus of G (jω) has a peak value
is known as resonant frequency.
7. Factors: Every loop transfer function (i.e. G(s) × H(s)) product of various factors like constant
term K, Integral factors (jω), first order factors ( 1 + jωT) (± n) where n is an integer, second order
or quadratic factors.
Slope contributed by constant term k, integral factor, first order factor, second order factor.
Constant term K: This factor has a slope of zero dB per decade. There is no corner
frequency corresponding to this constant term. The phase angle associated with this constant
term is also zero.
Integral factor 1/(jω)n: This factor has a slope of -20 × n (where n is any integer)dB per
decade. There is no corner frequency corresponding to this integral factor. The phase angle
associated with this integral factor is -90 × n here n is also an integer.
First order factor 1/ (1+jωT): This factor has a slope of -20 dB per decade. The corner
frequency corresponding to this factor is 1/T radian per second. The phase angle associated
with this first factor is -tan- 1(ωT).
First order factor (1+jωT): This factor has a slope of 20 dB per decade. The corner
frequency corresponding to this factor is 1/T radian per second. The phase angle associated
with this first factor is tan- 1(ωT) .
Second order or quadratic factor : [{1/(1+(2ζ/ω)} × (jω) + {(1/ω 2)} × (jω)2)]: This factor
has a slope of -40 dB per decade. The corner frequency corresponding to this factor is ωn
radian per second. The phase angle associated with this first factor is - tan-1{ (2ζω / ωn) / (1-
(ω / ωn)2)} .
Procedure To Create Block diagram for Stability Analysis of system using Bode Plot in
LabVIEW
Right click on block diagram and go to control and simulationcontrol designmodel
constructionSelect CD Construct transfer function model.vi
Right click on Left side of First terminal of CD construct Transfer Function
Model.viCreate control
Right click on Left side of Second terminal of CD construct Transfer Function
Model.viCreate control
Right click on block diagram and go to control and simulationcontrol designmodel
constructionSelect CD Draw transfer function Equation.vi
Connect wire from CD Construct transfer function model.vi to first terminal of CD Draw
transfer function Equation.vi
Right click on CD Draw transfer function Equation.viCreate indicator
Right click on block diagram and go to control and simulationcontrol designFrequency
ResponseCD Gain and phase margin.vi
Connect wire from CD Construct transfer function model.vi to left side of First terminal of
CD Gain and phase margin.vi
Right click on first terminal of Right side of CD Gain and phase margin.viCreate
indicator
Right click on Second terminal of Right side of CD Gain and phase margin.viCreate
indicator
Right click on Third terminal of Right side of CD Gain and phase margin.viCreate
indicator
Figure1: Block diagram of Stability Analysis of system using Bode Plot using LabVIEW
Figure2: Front panel display of Stability Analysis of system using Bode Plot using
LabVIEW
Results:
(i) corner frequencies are:
(ii) gain margin and phase margin:
(iii) Comment on the stability of the system.
Challenge: Level-1
(i) Change the value of K and observe change in bode plot. Comment on effect of changing k value
on gain margin and phase margin.
(ii) Observe the effect of adding a pole or zero or changing pole zero value on gain margin and
phase margin.
Conclusion:
Experiment 5
Steady-State Error
Aim:
To reduce steady state error of a system.
Key MATLAB commands used are: lsim, feedback
Theory:
Introduction:
Calculating steady state error
System type and steady state error
Example: Meeting steady state error requirement.
Introduction:
Steady-state error is defined as the difference between the input (command) and the output of a system
in the limit as time goes to infinity (i.e. when the response has reached steady state). The steady-state
error will depend on the type of input (step, ramp, etc.) as well as the system type (0, I, or II).
Note: Steady-state error analysis is only useful for stable systems. You should always check the
system for stability before performing a steady-state error analysis. Many of the techniques
that we present will give an answer even if the error does not reach a finite steady-state value.
This is equivalent to the following system, where T(s) is the closed-loop transfer function.
We can calculate the steady-state error for this system from either the open- or closed-loop transfer
function using the Final Value Theorem. Recall that this theorem can only be applied if the subject
of the limit (sE(s) in this case) has poles with negative real part.
Now, let's plug in the Laplace transforms for some standard inputs and determine equations to
calculate steady-state error from the open-loop transfer function in each case.
Step Input (R(s) = 1 / s):
When we design a controller, we usually also want to compensate for disturbances to a system. Let's
say that we have a system with a disturbance that enters in the manner shown below.
We can find the steady-state error due to a step disturbance input again employing the Final Value
Theorem (treat R(s) = 0).
When we have a non-unity feedback system we need to be careful since the signal entering G(s) is
no longer the actual error E(s). Error is the difference between the commanded reference and the
actual output, E(s) = R(s) - Y(s). When there is a transfer function H(s) in the feedback path, the signal
being substracted from R(s) is no longer the true output Y(s), it has been distorted by H(s). This
situation is depicted below.
Manipulating the blocks, we can transform the system into an equivalent unity-feedback structure as
shown below.
If you refer back to the equations for calculating steady-state errors for unity feedback systems, you
will find that we have defined certain constants (known as the static error constants). These constants
are the position constant (Kp), the velocity constant (Kv), and the acceleration constant (Ka).
Knowing the value of these constants, as well as the system type, we can predict if our system is
going to have a finite steady-state error.
First, let's talk about system type. The system type is defined as the number of pure integrators in
the forward path of a unity-feedback system. That is, the system type is equal to the value of n when
the system is represented as in the following figure. It does not matter if the integrators are part of the
controller or the plant.
Therefore, a system can be type 0, type 1, etc. The following tables summarize how steady-state error
varies with system type.
Since this system is type 1, there will be no steady-state error for a step input and there will be infinite
error for a parabolic input. The only input that will yield a finite steady-state error in this system is a
ramp input. We wish to choose K such that the closed-loop system has a steady-state error of 0.1 in
response to a ramp reference. Let's first examine the ramp input response for a gain of K = 1.
MATLAB code to plot response of system with transfer function
G=((s+3)*(s+5)/(s*(s+7)*(s+8)) for ramp input.
----------------------------------------------------------------------------------------------------------------
s = tf('s');
G = ((s+3)*(s+5))/(s*(s+7)*(s+8));
T = feedback(G,1);
t = 0:0.1:25;
u = t;
[y,t,x] = lsim(T,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
----------------------------------------------------------------------------------------------------------------
The steady-state error for this system is quite large, since we can see that at time 20 seconds the
output is approximately 16 as compared to an input of 20 (steady-state error is approximately equal
to 4). Let's examine this in further detail.
We know from our problem statement that the steady-state error must be 0.1. Therefore, we can solve
the problem following these steps:
Let's see the ramp input response for K = 37.33 by entering the following code in the MATLAB
command window.
----------------------------------------------------------------------------------------------------------------
K = 37.33 ;
s = tf('s');
G = (K*(s+3)*(s+5))/(s*(s+7)*(s+8));
sysCL = feedback(G,1);
t = 0:0.1:50;
u = t;
[y,t,x] = lsim(sysCL,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
----------------------------------------------------------------------------------------------------------------
In order to get a better view, we must zoom in on the response. We choose to zoom in between time
equals 39.9 and 40.1 seconds because that will ensure that the system has reached steady state.
axis([39.9,40.1,39.9,40.1])
Examination of the above shows that the steady-state error is indeed 0.1 as desired.
Now let's modify the problem a little bit and say that our system has the form shown below.
In essence we are no distinguishing between the controller and the plant in our feedback system. Now
we want to achieve zero steady-state error for a ramp input.
From our tables, we know that a system of type 2 gives us zero steady-state error for a ramp input.
Therefore, we can get zero steady-state error by simply adding an integrator (a pole at the origin).
Let's view the ramp input response for a step input if we add an integrator and employ a gain K = 1.
MATLAB code :
----------------------------------------------------------------------------------------------------------------
s = tf('s');
P = ((s+3)*(s+5))/(s*(s+7)*(s+8));
C = 1/s;
sysCL = feedback(C*P,1);
t = 0:0.1:250;
u = t;
[y,t,x] = lsim(sysCL,u,t);
plot(t,y,'y',t,u,'m')
xlabel('Time (sec)')
ylabel('Amplitude')
title('Input-purple, Output-yellow')
----------------------------------------------------------------------------------------------------------------
As you can see, there is initially some oscillation (you may need to zoom in). However, at steady
state we do have zero steady-state error as desired. Let's zoom in around 240 seconds (trust me, it
doesn't reach steady state until then).
axis([239.9,240.1,239.9,240.1])
As you can see, the steady-state error is zero. Feel free to zoom in on different areas of the graph to
observe how the response approaches steady state.
Result: For TF G=((s+3)*(s+5)/(s*(s+7)*(s+8)) with unity feed back and ramp input
Challenge Level-1.(i) Explain for TF G=((s+3)*(s+5)/(s*(s+7)*(s+8)) with unity feed back and ramp
input we have steady state error and how it is eliminated.
Conclusion:
EXPERIMENT 6
Root Locus Analysis
Aim:
Create root locus for a given transfer function using MATLAB
To demonstrate how to design feedback controller using root locus that satisfy certain performance
criteria.
Key MATLAB commands used in this tutorial are: feedback, rlocus, step,
Theory:
Closed-Loop Poles
Plotting the Root Locus of a Transfer Function
Choosing a Value of K from the Root Locus
Closed-Loop Response
Closed-Loop Poles
The root locus of an (open-loop) transfer function is a plot of the locations (locus) of all
possible closed-loop poles with proportional gain K and unity feedback.
and thus the poles of the closed-loop poles of the closed-loop system are values of such
that .
Let = order of and = order of (the order of a polynomial is the highest power
of that appears in it).
We will consider all positive values of K. In the limit as , the poles of the closed-loop
system are or the poles of . In the limit as , the poles of the closed-loop
system are or the zeros of .
No matter what we pick K to be, the closed-loop system must always have poles, where is the
number of poles of . The root locus must have branches, each branch starts at a pole
of and goes to a zero of . If has more poles than zeros (as is often the
case), and we say that has zeros at infinity. In this case, the limit of as is
zero. The number of zeros at infinity is , the number of poles minus the number of zeros, and
is the number of branches of the root locus that go to infinity (asymptotes).
Since the root locus is actually the locations of all possible closed-loop poles, from the root locus we
can select a gain such that our closed-loop system will perform the way we want. If any of the selected
poles are on the right half plane, the closed-loop system will be unstable. The poles that are closest
to the imaginary axis have the greatest influence on the closed-loop response, so even though the
system has three or four poles, it may still act like a second or even first order system depending on
the location(s) of the dominant pole(s).
Plotting the Root Locus of a Transfer Function
(4)
How do we design a feedback controller for the system by using the root locus method? Say our
design criteria are 5% overshoot and 1 second rise time. Make a MATLAB file called rl.m.
Enter the transfer function, and the command to plot the root locus:
Problem Statement: In our problem, we need an overshoot less than 5% (which means
a damping ratio of greater than 0.7) and a rise time of 1 second (which means a natural
frequency greater than 1.8).
Continuation of above MATLAB prog. The following instructions plot lines of constant
damping ratio and natural frequency 𝝎𝒏 on pole zero map or root locus.
----------------------------------------------------------------------------------------------------------------
Zeta = 0.7;
Wn = 1.8;
sgrid(Zeta,Wn)
On the plot above, the two dotted lines at about a 45 degree angle indicate pole locations with =
0.7; in between these lines, the poles will have > 0.7 and outside of the lines < 0.7. The semicircle
indicates pole locations with a natural frequency = 1.8; inside the circle, < 1.8 and outside the
circle > 1.8.
Going back to our problem, to make the overshoot less than 5%, the poles have to be in between the
two white dotted lines, and to make the rise time shorter than 1 second, the poles have to be outside
of the white dotted semicircle. So now we know only the part of the locus outside of the semicircle
and in betwen the two lines are acceptable. All the poles in this location are in the left-half plane, so
the closed-loop system will be stable.
From the plot above we see that there is part of the root locus inside the desired region. So in this
case, we need only a proportional controller to move the poles to the desired region. You can use
the rlocfind command in MATLAB to choose the desired poles on the locus:
[k,poles] = rlocfind(sys)
Click on the plot the point where you want the closed-loop pole to be. You may want to select the
points indicated in the plot below to satisfy the design criteria.
Note that since the root locus may have more than one branch, when you select a pole, you
may want to find out where the other pole (poles) are. Remember they will affect the response too.
From the plot above, we see that all the poles selected (all the "+" signs) are at reasonable positions.
We can go ahead and use the chosen K as our proportional controller.
Closed-Loop Response
In order to find the step response, you need to know the closed-loop transfer function. You could
compute this using the rules of block diagrams, or let MATLAB do it for you (there is no need to
enter a value for K if the rlocfind command was used):
K = 350;
sys_cl = feedback(K*sys,1)
----------------------------------------------------------------------------------------------------------------
sys_cl =
350 s + 2450
--------------------------------------
s^4 + 40 s^3 + 475 s^2 + 1850 s + 2450
Continuous-time transfer function.
The two arguments to the function feedback are the numerator and denominator of the open-
loop system. You need to include the proportional gain that you have chosen. Unity feedback is
assumed.
If you have a non-unity feedback situation, look at the help file for the MATLAB
function feedback, which can find the closed-loop transfer function with a gain in the feedback
loop.
To Check out the step response of your closed-loop system:
----------------------------------------------------------------------------------------------------------------
step(sys_cl)
As we expected, this response has an overshoot less than 5% and a rise time less than 1 second.
Results:
(i) The order of given transfer function=
(ii) Number of poles = : Number of zeros=
(iii) For over shoot = ; Zeta= ; 𝜔𝑛 = ; K=
(iv) From step response of closed loop system : Rise time= ; Peak over shoot=
;Settling time=
Challenge:level 1
Challenge level-1: A single loop negative feedback system has loop transfer function
𝑘(𝑠+2)2
𝐺𝑐 (𝑠)𝐺 (𝑠) = 𝑠(𝑠2+1)(𝑠+8) (a) Sketch the root locus for 0≤k≤∞ to indicate the significant feature of the
locus(b) Determine the range of the gain k for which system is stable.(c) For what value of k in the range
k≥0 do purely imaginary roots exists. What are the values of these roots.(d) Would the use of dominant
root approximation for an estimate of settling time be justified in this case for the large magnitude of gain
(k>50).
EXPERIMENT-7
Stability Analysis of a system using Nyquist Plot
AIM:
To obtain Nyquist Plot for a given transfer function of the system using MATLAB and
comment on the stability.
THEORY:
Introduction
Terminologies used in Nyquist plot:
Introduction:
The stability analysis of a feedback control system is based on identifying the location of the roots of
the characteristic equation on s-plane. The system is stable if the roots lie on left hand side of s-plane.
Relative stability of a system can be determined by using frequency response methods like Nyquist
plot and Bode plot. Nyquist criterion is used to identify the presence of roots of a characteristic
equation in a specified region of s-plane. To understand Nyquist plot we need to know about some
of the terminologies.
Terminologies used in Nyquist plot:
(i) Contour : Closed path in a complex plane is called contour
The Nyquist contour is a closed contour in the s-plane which completely encloses the entire right
hand half of s-plane. In order to enclose the complete RHS of s-plane a large semicircle path is drawn
with diameter along jω axis and centre at origin. The radius of the semicircle is treated as infinity.
The process by which a point in s-plane transformed into a point in F(s) plane is called mapping and
F(s) is called mapping function.
Nyquist criterion
𝑁(𝑠)
𝐺 (𝑠) 𝐻 (𝑠) = 𝑖𝑠 𝑡ℎ𝑒 𝑜𝑝𝑒𝑛 𝑙𝑜𝑜𝑝 𝑡𝑟𝑎𝑛𝑠𝑓𝑒𝑟 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 (𝑂. 𝐿. 𝑇. 𝐹)
𝐷(𝑠)
𝐺(𝑠)
𝑖𝑠 𝑡ℎ𝑒 𝑐𝑙𝑜𝑠𝑒𝑑 𝑙𝑜𝑜𝑝 𝑡𝑟𝑎𝑛𝑠𝑓𝑒𝑟 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 (𝐶. 𝐿. 𝑇. 𝐹)
1 + 𝐺 (𝑠)𝐻(𝑠)
N(s) = 0 is the open loop zero and D(s) is the open loop pole From stability point of view no closed
loop poles should lie in the RH side of s-plane . Characteristics equation 1 + G(s) H(s) = 0 denotes
closed loop poles
.
𝑁1 (𝑠)
𝐿𝑒𝑡, 𝑞(𝑠) = 1 + 𝐺 (𝑠)𝐻 (𝑠) =
𝐷1(𝑠)
Now as 1+ G(s) H(s) = 0 hence q(s) should also be zero.
𝑁1 (𝑠)
𝐼𝑓, 𝑞(𝑠) = 0, = 0 𝑖. 𝑒. 𝑁1 (𝑠) = 0
𝐷1(𝑠)
Therefore , from the stability point of view zeroes of q(s) should not lie in RHP of s-plane. To define
the stability entire RHP (Right Hand Plane) is considered. We assume a semicircle which encloses
all points in the RHP by considering the radius of the semicircle R tends to infinity. [R → ∞].
The first step to understand the application of Nyquist criterion in relation to determination of
stability of control systems is mapping from s-plane to G(s) H(s) - plane. s is considered as
independent complex variable and corresponding value of G(s) H(s) being the dependent variable
plotted in another complex plane called G(s) H(s) - plane. Thus for every point in s-plane there exists
a corresponding point in G(s) H(s) - plane. During the process of mapping the independent variable
s is varied along a specified path in s - plane and the corresponding points in G(s)H(s) plane are
joined. This completes the process of mapping from s-plane to G(s)H(s) - plane.
Nyquist stability criterion says that if the open loop transfer function has k poles in the right half
splane amd lim s-∞ G(s)H(s)= constant, then for stability G(jω)H(jω) locus must encircle the -1+j0
point k times in the counter clockwise direction. This criterion can be expressed as , Z=N+P. Where,
N is the total no. of clock wise encirclement about -1+j0, P is the total no. of poles and Z is the total
no. of zeroes of G(s)H(s) in the right half s-plane.
Case 1:- N = 0 (no encirclement), so Z = P = 0 & Z = P If N = 0, P must be zero therefore system is
stable.
Case 2:- N > 0 (clockwise encirclement), so P = 0 , Z ≠0 & Z > P For both cases system is unstable.
Case 3 :- N < 0 (counterclockwise encirclement), so Z = 0, P ≠0 & P > Z System is stable.
Note: Knowing the number of right-half plane (unstable) poles in open loop ( P), and the number of
encirclements of -1 made by the Nyquist diagram ( N), we can determine the closed-loop stability of
the system. If Z = P + N is a positive, nonzero number, the closed-loop system is unstable.
The objective of this experiment is to find the range of gains that will make this system
stable in the closed-loop.
Problem statement: Using Nyquist diagram find the range of gains for a closed-loop
unity feedback system to be stable. The system we will test looks as shown in fig: given
G(s) = s2+10s+24/s2-8s+15
The matlab code for the system for different value of gains K is as follows
%to find the number positive real poles in open loop tr fn
ans =
5
3
MATLAB code for nyquist plot of the given system with TF(s^2 + 10*s + 24)/(s^2 - 8*s + 15)
----------------------------------------------------------------------------------------------------------------
% for gain of K=1 observe the plot
sys = (s^2 + 10*s + 24)/(s^2 - 8*s + 15);
nyquist(sys)
----------------------------------------------------------------------------------------------------------------
Nyquist Diagram
1.5
0.5
Imaginary Axis
-0.5
-1
-1.5
-1.5 -1 -0.5 0 0.5 1 1.5 2
Real Axis
Nyquist Diagram
30
20
10
Imaginary Axis
-10
-20
-30
-30 -20 -10 0 10 20 30
Real Axis
Nyquist Diagram
0.8
0.6
0.4
0.2
Imaginary Axis
-0.2
-0.4
-0.6
-0.8
-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8
Real Axis
EXPERIMENT-8
Time response Analysis of PID Controller
AIM:
THEORY:
Introduction to PID controllers.
Second order system with PID controller:
PD control and PI control:
Drawback of PID controller:
An automatic control system is used to maintain its output within desirable limits by means of a
control action. Any deviation of the output from the reference input is detected by an error detector .
The error thus detected is used in actuating signal for control action through a controller.
PID control stands for proportional plus derivative plus integral control. PID control is a feedback
mechanism which is used in control system. This type of control is also termed as three term control.
By controlling the three parameters - proportional, integral and derivative we can achieve different
control actions for specific work. PID is considered to be the best controller in the control system
family. For PID control the actuating signal consists of proportional error signal added with derivative
and integral of the error signal. Therefore, the actuating signal for PID control is –
𝑑𝑒(𝑡)
𝑒𝑎 (𝑡) = 𝑒(𝑡) + 𝑇𝑑 + 𝐾𝑖 ∫ 𝑒(𝑡)𝑑𝑡
𝑑𝑡
Second order system with PID controller:
- D(s)
The block diagram of a second order control system incorporating PID control is as shown:
The controller used here is a PID controller represented by a block PID and the system or plant
is represented by G(s). R(s) and D(s) are reference signal and disturbance signal respectively.
Y(s),E(s) and Ea(s) are the output, error and controller output of the system respectively. For
thepurpose of good control, we require the system output Y(s) to track any reference signal R(s) and
at the same time reject or suppress deviation due to the disturbance signal D(s). Hence the PID
controller can realize this objective.
𝐾𝑖
𝐸𝑎 (𝑠) = 𝐸 (𝑠) + 𝑠𝑇𝑑 𝐸 (𝑠) + 𝐸(𝑠)
𝑠
OR
𝐾𝑖
𝐸𝑎 (𝑠) = 𝐸 (𝑠) [1 + 𝑠𝑇𝑑 + ]
𝑠
Many complex electronic systems are provided with PID control loop. In modern days PID
controllers are used in PLC (programmable logic controllers) in the industry. The proportional,
derivative and integral parameters can be expressed as - Kp, Kd and Ki. All these three parameters
have effect on the closed loop control system. It affects rise time, settling time and overshoot and
also the steady state error.
Table: effect of PID controller parameters (Kp, Kd and Ki.) on transient response performance and
Steady state error.
small
Kp decrease increase decrease
change
small
Kd decrease decrease no change
change
Ki decrease increase increase eliminate
PID control combines advantages of proportional, derivative and integral control actions. Let us
discuss these control actions in brief. Proportional control : here actuating signal for the control action
in a control system is proportional to the error signal. The error signal being the difference between
the reference input signal and the feedback signal obtained from input.
There are some control actions which can be achieved by using any of the two parameters of the
PID controller. Two parameters can work while keeping the third one to zero. So PID controller
becomes sometimes PI (Proportion integral), PD (proportional derivative) or even P or I. The
derivative term D is responsible for noise measurement while integral term is meant for reaching the
targeted value of the system.
Derivative Control : The actuating signal consists of proportional error signal added with
derivative of the error signal. Therefore, the actuating signal for derivative control action is given
by,
𝑑𝑒(𝑡)
𝑒𝑎 (𝑡) = 𝑒(𝑡) + 𝑇𝑑 𝑤ℎ𝑒𝑟𝑒, 𝑇𝑑 𝑖𝑠 𝑎 𝑐𝑜𝑛𝑠𝑡𝑎𝑛𝑡.
𝑑𝑡
Integral control: for integral control action the actuating signal consists of proportional error
signal added with integral of the error signal. Therefore, the actuating signal for integral control
action is given by
PID control is applicable to many control actions but it does not perform well in case of optimal
control. Main disadvantage is the feedback path. PID is not provided with any model of the process.
Other drawbacks are that PID is linear system and derivative part is noise sensitive. Small amount
of noise can cause great change in the output.
Problem statement:
Consider that the transfer function of a spring, mass and damper system is given by
𝑋(𝑠) 1
= 2
𝐹(𝑠) 𝑠 + 10𝑠 + 20
Using a PID controller, show how each of Kp,, Kd, and Ki contributes to obtain fast rise time,
minimum overshoot and no steady state error.
MATLAB code to plot step response of the system without PID controller.
----------------------------------------------------------------------------------------------------------------
𝑋(𝑠) 1
% step response of system with T F 𝐹(𝑠) = 𝑠2 +10𝑠+20 without PID controller
s = tf('s');
P = 1/(s^2 + 10*s + 20);
step(P)
--------------------------------------------------------------------------------------------------------------
System: P
Step Response (X(s))/(F(s))=1/(s2+10s+20) without PID controller Final Value: 0.05
0.05
System: P
Rise Time (sec): 1.01 System: P
0.045 Settling Time (sec): 1.59
0.04
0.035
0.03
Amplitude
0.025
0.02
0.015
0.01
0.005
0
0 0.5 1 1.5 2 2.5
Time (sec)
Observe that the response of the system without PID is not a desirable response. Hence we include
PID controller.
MATLAB code with PID controller added to the system. Step response for the Kp= 300,
Kd=70 and Ki= 300.
s = tf('s');
P = 1/(s^2 + 10*s + 20);
Kp = 300;
Kd = 70;
Ki = 300;
C = Kp+ Ki/s+ Kd*s;
T = feedback(C*P,1);
t=0:0.01:2;
step(T,t);
0.7
0.6
Amplitude
0.4
0.3
0.2
0.1
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time (sec)
Conclusion:
Challenge level-1: plot unit step response for following PID parameters
(i) 𝐾𝑝 = 300, 𝐾𝑑 = 0 𝑎𝑛𝑑 𝐾𝑎 = 0
(ii) 𝐾𝑝 = 300, 𝐾𝑑 = 0 𝑎𝑛𝑑 𝐾𝑎 = 0
EXPERIMENT-9
Contents
Modeling
Stability
Controllability and Observability
Control Design Using Pole Placement
Introducing the Reference Input
Observer Design
Modeling
There are several different ways to describe a system of linear differential equations. The state-space
representation was introduced in the Introduction: System Modeling section. For a SISO LTI
system, the state-space form is given below:
(1)
(2)
where is an n by 1 vector representing the system's state variables, is a scalar representing the
input, and is a scalar representing the output. The matrices (n by n), (n by 1), and (1 by n)
determine the relationships between the state variables and the input and output. Note that there are
n first-order differential equations. A state-space representation can also be used for systems with
multiple inputs and multiple outputs (MIMO), but we will primarily focus on single-input, single-
output (SISO) systems in these tutorials.
To introduce the state-space control design method, we will use the magnetically suspended ball as
an example. The current through the coils induces a magnetic force which can balance the force of
gravity and cause the ball (which is made of a magnetic material) to be suspended in mid-air. The
modeling of this system has been established in many control text books (including Automatic
Control Systems by B. C. Kuo, the seventh edition).
(3)
(4)
where is the vertical position of the ball, is the current through the electromagnet, is the applied
voltage, is the mass of the ball, is the acceleration due to gravity, is the inductance, is the
resistance, and is a coefficient that determines the magnetic force exerted on the ball. For
simplicity, we will choose values = 0.05 kg, = 0.0001, = 0.01 H, = 1 Ohm, = 9.81 m/s^2.
The system is at equilibrium (the ball is suspended in mid-air) whenever = (at which
point = 0). We linearize the equations about the point = 0.01 m (where the nominal current
is about 7 Amps) and obtain the linear state-space equations:
(5)
(6)
where:
(7)
is the set of state variables for the system (a 3x1 vector), is the deviation of the input voltage from
its equilibrium value ( ), and (the output) is the deviation of the height of the ball from its
equilibrium position ( ). Enter the system matrices into an m-file.
A=[0 1 0
980 0 -2.8
0 0 -100 ];
B=[0
100 ];
C = [ 1 0 0 ];
Stability
One of the first things we want to do is analyze whether the open-loop system (without any control)
is stable. As discussed in the Introduction: System Analysis section, the eigenvalues of the system
matrix, , (equal to the poles of the transfer function) determine stability. The eigenvalues of
the matrix are the values of that are solutions of .
poles = eig(A)
poles =
31.3050
-31.3050
-100.0000
From inspection, it can be seen that one of the poles is in the right-half plane (i.e. has positive real
part), which means that the open-loop system is unstable.
To observe what happens to this unstable system when there is a non-zero initial condition, add the
following lines to your m-file and run it again:
t = 0:0.01:2;
u = zeros(size(t));
x0 = [0.01 0 0];
sys = ss(A,B,C,0);
[y,t,x] = lsim(sys,u,t,x0);
plot(t,y)
It looks like the distance between the ball and the electromagnet will go to infinity, but probably the
ball hits the table or the floor first (and also probably goes out of the range where our linearization is
valid).
Controllability and Observability
A system is controllable if there always exists a control input, , that transfers any state of the
system to any other state in finite time. It can be shown that an LTI system is controllable if and only
if its controllabilty matrix, , has full rank (i.e. if rank( ) = n where n is the number of states
variables). The rank of the controllability matrix of an LTI model can be determined in MATLAB
using the commands rank(ctrb(A,B)) or rank(ctrb(sys)).
(8)
All of the state variables of a system may not be directly measurable, for instance, if the component
is in an inaccessible location. In these cases it is necessary to estimate the values of the unknown
internal state variables using only the available system outputs. A system is observable if the initial
state, , can be determined based on knowledge of the system input, , and the system
output, , over some finite time interval . For LTI systems, the system is observable if
and only if the observability matrix, , has full rank (i.e. if rank( ) = n where n is the number of
state variables). The observability of an LTI model can be determined in MATLAB using the
command rank(obsv(A,C)) or rank(obsv(sys)).
(9)
Controllability and observability are dual concepts. A system ( , ) is controllable if and only if a
system ( , ) is observable. This fact will be useful when designing an observer, as we shall see
below.
Control Design Using Pole Placement
Let's build a controller for this system using a pole placement approach. The schematic of a full-state
feedback system is shown below. By full-state, we mean that all state variables are known to the
controller at all times. For this system, we would need a sensor measuring the ball's position, another
measuring the ball's velocity, and a third measuring the current in the electromagnet.
For simplicity, let's assume the reference is zero, = 0. The input is then
(10)
The state-space equations for the closed-loop feedback system are, therefore,
(11)
(12)
The stability and time-domain performance of the closed-loop feedback system are determined
primarily by the location of the eigenvalues of the matrix ( ), which are equal to the closed-
loop poles. Since the matrices and are both 3x3, there will be 3 poles for the system. By
choosing an appropriate state-feedback gain matrix , we can place these closed-loop poles
anywhere we'd like (because the system is controllable). We can use the MATLAB function place to
find the state-feedback gain, , which will provide the desired closed-loop poles.
Before attempting this method, we have to decide where we want to place the closed-loop poles.
Suppose the criteria for the controller were settling time < 0.5 sec and overshoot < 5%, then we might
try to place the two dominant poles at -10 +/- 10i (at = 0.7 or 45 degrees with = 10 > 4.6*2). The
third pole we might place at -50 to start (so that it is sufficiently fast that it won't have much effect
on the response), and we can change it later depending on what closed-loop behavior results. Remove
the lsim command from your m-file and everything after it, then add the following lines to your m-
file:
p1 = -10 + 10i;
p2 = -10 - 10i;
p3 = -50;
K = place(A,B,[p1 p2 p3]);
sys_cl = ss(A-B*K,B,C,0);
lsim(sys_cl,u,t,x0);
xlabel('Time (sec)')
ylabel('Ball Position (m)')
From inspection, we can see the overshoot is too large (there are also zeros in the transfer function
which can increase the overshoot; you do not explicitly see the zeros in the state-space formulation).
Try placing the poles further to the left to see if the transient response improves (this should also
make the response faster).
p1 = -20 + 20i;
p2 = -20 - 20i;
p3 = -100;
K = place(A,B,[p1 p2 p3]);
sys_cl = ss(A-B*K,B,C,0);
lsim(sys_cl,u,t,x0);
xlabel('Time (sec)')
ylabel('Ball Position (m)')
This time the overshoot is smaller. Consult your textbook for further suggestions on choosing the
desired closed-loop poles.
Compare the control effort required ( ) in both cases. In general, the farther you move the poles to
the left, the more control effort is required.
Note: If you want to place two or more poles at the same position, place will not work. You can use
a function called acker which achieves the same goal (but can be less numerically well-conditioned):
K = acker(A,B,[p1 p2 p3])
Introducing the Reference Input
Now, we will take the control system as defined above and apply a step input (we choose a small
value for the step, so we remain in the region where our linearization is valid). Replace t, u ,
and lsim in your m-file with the following:
t = 0:0.01:2;
u = 0.001*ones(size(t));
sys_cl = ss(A-B*K,B,C,0);
lsim(sys_cl,u,t);
xlabel('Time (sec)')
ylabel('Ball Position (m)')
axis([0 2 -4E-6 0])
The system does not track the step well at all; not only is the magnitude not one, but it is negative
instead of positive!
Recall the schematic above, we don't compare the output to the reference; instead we measure all the
states, multiply by the gain vector , and then subtract this result from the reference. There is no
reason to expect that will be equal to the desired output. To eliminate this problem, we can scale
the reference input to make it equal to in steady-state. The scale factor, , is shown in the
following schematic:
We can calcuate within MATLAB employing the function rscale (place the following line of code
after K = ...).
Nbar = rscale(sys,K)
Nbar =
-285.7143
Note that this function is not standard in MATLAB. You will need to download it here, rscale.m, and
save it to your current workspace. Now, if we want to find the response of the system under state
feedback with this scaling of the reference, we simply note the fact that the input is multiplied by this
new factor, :
lsim(sys_cl,Nbar*u,t)
and now a step can be tracked reasonably well. Note, our calculation of the scaling factor requires
good knowledge of the system. If our model is in error, then we will scale the input an incorrect
amount. An alternative, similar to what was introduced with PID control, is to add a state variable for
the integral of the output error. This has the effect of adding an integral term to our controller which
is known to reduce steady-state error.
Observer Design
When we can't measure all state variables (often the case in practice), we can build an observer to
estimate them, while measuring only the output . For the magnetic ball example, we will add
three new, estimated state variables ( ) to the system. The schematic is as follows:
The observer is basically a copy of the plant; it has the same input and almost the same differential
equation. An extra term compares the actual measured output to the estimated output ; this
will help to correct the estimated state and cause it to approach the values of the actual state (if
the measurement has minimal error).
(13)
(14)
The error dynamics of the observer are given by the poles of .
(15)
First, we need to choose the observer gain . Since we want the dynamics of the observer to be much
faster than the system itself, we need to place the poles at least five times farther to the left than the
dominant poles of the system. If we want to use place, we need to put the three observer poles at
different locations.
op1 = -100;
op2 = -101;
op3 = -102;
Because of the duality between controllability and observability, we can use the same technique used
to find the control matrix by replacing the matrix by the matrix and taking the transposes of each
matrix:
The equations in the block diagram above are given for the estimate . It is conventional to write the
combined equations for the system plus observer using the original state equations plus the estimation
error: . We use the estimated state for feedback, , since not all state variables are
necessarily measured. After a little bit of algebra (consult your textbook for more details), we arrive
at the combined state and error equations for full-state feedback with an observer.
At = [ A-B*K B*K
zeros(size(A)) A-L*C ];
Bt = [ B*Nbar
zeros(size(B)) ];
Ct = [ C zeros(size(C)) ];
To see how the response to a non-zero initial condition with no reference input appears, add the
following lines into your m-file. Here we will assume that the observer begins with an initial estimate
equal to zero, such that the initial estimation error is equal to the initial state vector, .
sys = ss(At,Bt,Ct,0);
lsim(sys,zeros(size(t)),t,[x0 x0]);
Responses of all the state variables are plotted below. Recall that lsim gives us and ; to get , we
need to compute .
t = 0:1E-6:0.1;
n = 3;
e = x(:,n+1:end);
x = x(:,1:n);
x_est = x - e;
plot(t,h,'-r',t,h_est,':r',t,h_dot,'-b',t,h_dot_est,':b',t,i,'-g',t,i_est,':g')
legend('h','h_{est}','hdot','hdot_{est}','i','i_{est}')
xlabel('Time (sec)')
From the above, we can see that the observer estimates converge to the actual state variables quickly
and track the state variables well in steady-state.
Result:
Conclusion: