Ee3512 - Control and Instrumentation Laboratory Manual
Ee3512 - Control and Instrumentation Laboratory Manual
BONAFIDE CERTIFICATE
Reg. No.
Department :………………………………………………………………………………………………………..
of………………………………………………………Department……… …………..Semester
………………………………………………………………….. Laboratory during the year
20 - 20 .
LIST OF EXPERIMENTS:
1. Analog (op amp based) simulation of linear differential equations.
2. Numerical Simulation of given nonlinear differential equations.
3. Real time simulation of differential equations.
4. Mathematical modeling and simulation of physical systems in at least two fields.
Mechanical
Electrical
Chemical process
5. System Identification through process reaction curve.
6. Stability analysis using Pole zero maps and Routh Hurwitz Criterion in simulation
platform.
7. Root Locus based analysis in simulation platform.
8. Determination of transfer function of a physical system using frequency response and
Bode’s asymptotes.
9. Design of Lag, lead compensators and evaluation of closed loop performance.
10. Design of PID controllers and evaluation of closed loop performance.
11. Discretization of continuous system and effect of sampling.
12. Test of controllability and observability in continuous and discrete domain in simulation
platform.
13. State feedback and state observer design and evaluation of closed loop performance.
14. Mini Project 1: Simulation of complete closed loop control systems including sensor and
actuator dynamics.
15. Mini Project 2: Demonstration of a closed loop system in hardware.
TOTAL: 60 PERIODS
COURSE OUTCOMES:
At the end of this course, the students will demonstrate the ability
CO1: To model and analyze simple physical systems and simulate the performance in
analog and digital platform.
CO2: To design and implement simple controllers in standard forms.
CO3: To design compensators based on time and frequency domain specifications.
CO4: To design a complete closed control loop and evaluate its performance for simple
physical systems.
CO5: To analyze the stability of a physical system in both continuous and discrete domains.
LIST OF EXPERIMENTS
2
Ex. No. 1 Date
EQUATIONS
AIM
To Study the analog (op amp based) simulation of linear differential equations using
Mat lab-Simulink.
APPARATUS REQUIRED
PROCEDURE
3. From the continuous block in the library drag the transfer function block.
4. From the source block in the library drag the step input.
6. From the math operations block in the library drag the summing point.
8. Connect all to form a system and give unity feedback to the system.
9. For changing the parameters of the blocks connected double click the respective block.
3
PROGRAMME
A.OPEN LOOP RESPONSE (FIRST ORDER SYSTEM)
T.F=4/(s+2)
1. Response of system to Step input
n=[4];
d=[1 2];
sys=tf(n,d);
step(sys)
2. Response of system to Impulse input
n=[4];
d=[1 2];
sys=tf(n,d);
step(sys)
impulse(sys)
RESULT:
Thus experiment on ANALOG (OP AMP BASED) circuit was performed
successfully to view real time simulation of Linear differential equations and
verified the same using MATLAB/Simulink Toolbox: Control System Toolbox.
4
Ex. No. 2 Date
EQUATIONS.
AIM
To digitally simulate the characteristics of Linear SISO systems using Numerical Simulation
of given nonlinear differential equations.
APPARATU REQUIRED
1. A PC with MATLAB package.
THEORY
State Variable approach is a more general mathematical representation of a system, which,
along with the output, yields information about the state of the system variables at some
predetermined points along the flow of signals. It is a direct time-domain approach, which
provides a basis for modern control theory and system optimization. SISO (single input single
output) linear systems can be easily defined with transfer function analysis. The transfer
function approach can be linked easily with the state variable approach.
The state model of a linear-time invariant system is given by the following equations:
5
PROGRAM:
B. Close Loop Response
1. Response of Step input
n=[4];
d=[1 2];
sys=tf(n,d);
sys=feedback(sys,1,-1)
step(sys)
2. Response of Impulse input
n=[4];
d=[1 2];
sys=tf(n,d);
sys=feedback(sys,1,-1)
impulse(sys)
6
2. pen Loop Response of impulse Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
impulse(sys)
7
2. Impulse Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
impulse(sys)
8
PROGRAM
% Simulation of discrete model
clear,
clc
% Model Parameters
a=0.25;b=2;
% Simulation Parameters
Ts=0.1; %s
Tstop=30; %s
uk=1; % Step Response
x(1)=0;
% Simulation
for k=1:(Tstop/Ts)
x(k+1)=(1-a*Ts).*x(k) + Ts*b*uk;
end
% Plot the Simulation Results
k=0:Ts:Tstop;
plot(k,x)
grid on
OUTPUT:
RESULT:
Thus experiment on Numerical circuit was performed successfully to
view real time simulation of given Non Linear differential equations and verified the
same using MATLAB/Simulink Toolbox: Control System Toolbox .
9
Ex. No. 3 Date
AIM
By a suitable experiment perform a real time simulation of differential equations and
verify the same by MATLAB/Simulink Toolbox: Control System Toolbox.
Software Requirement:
1. Computer system with MATLAB
2. MATLAB/Simulink Toolbox: Control System Toolbox
Differential equation
In mathematics, a differential equation is an equation that relates one or more
unknown functions and their derivatives. In applications, the functions generally
represent physical quantities, the derivatives represent their rates of change, and the
differential equation defines a relationship between the two. Such relations are common;
therefore, differential equations play a prominent role in many disciplines
including engineering, physics, economics, and biology.
The study of differential equations consists mainly of the study of their solutions (the set
of functions that satisfy each equation), and of the properties of their solutions. Only the
simplest differential equations are soluble by explicit formulas; however, many
properties of solutions of a given differential equation may be determined without
computing them exactly.
Often when a closed-form expression for the solutions is not available, solutions may be
approximated numerically using computers. The theory of dynamical systems puts
emphasis on qualitative analysis of systems described by differential equations, while
many numerical methods have been developed to determine solutions with a given
degree of accuracy.
Types
Differential equations can be divided into several types. Apart from describing the
properties of the equation itself, these classes of differential equations can help inform the
choice of approach to a solution. Commonly used distinctions include whether the
equation is ordinary or partial, linear or non-linear, and homogeneous or heterogeneous.
This list is far from exhaustive; there are many other properties and subclasses of
differential equations which can be very useful in specific contexts.
Problem
The first order ordinary differential equation that describes a simple series electrical
circuit witha resistor, inductor, and sinusoidal voltage source is as follows:
Procedure
1. Connections are made as per the circuit diagram.
2. Connect the function generator and CRO
3. Tabulate the reading and draw the graph.
Time Current
di
L 10 sin( 150 t ) i R
dt
For this example, the inductance (L) is 1 henry and the resistance (R) is 10 Ω. The voltage
source is sinusoidal with a peak voltage equal to 10 volts and an angular velocity of 150
radians/second. The MATLAB statement written to solve the above ODE is as follows:
solution_1 = dsolve(‘DI=10*sin(150*t)–10*I’,’I(0)=0’,’t’);
The dsolve function symbolically solves the ordinary differential equation specified above.
The first argument is the actual ODE to be solved. D denotes differentiation with respect to
the independent variable which in this case is time or t. A repeated differentiation process
would be required if a digit other than 1 were to follow D. The character following the D (I
in this case, which is the circuit current), is the dependent variable. The remaining terms of
the equation are coded as usual. The second argument is used to specify the initial
conditions of the circuit. The initial current in this circuit at t = 0 is 0. The final argument is
used to specify the independent variable. Note that all arguments must be contained within
single quotation marks as shown.
The output from the dsolve function is the symbolic solution to the differential equation.
To get a quick visual understanding of the solution, the student should use the MATLAB
ezplot function in conjunction with the xlabel, ylabel, and grid commands. The result is a
simple graph which displays the numerical solution to the differential equation, the
symbolic solution to the differential equation, and appropriate units for the x and y axes.
The MATLAB statements written to provide the output to the graphical environment are
as follows:
grid
The electrical circuit defined above may be solved quickly using the symbolic solving
capabilities of MATLAB. Only 1 statement was needed to define the engineering
application. For plotting purposes and proper documentation of the solution, 3 more
statements are required. This short program was run on the Student Version of the
MATLAB software distributed to the class. The results of the program are presented in
Figure 1.
Program
clc
clear all
close all
solution_1 = dsolve(‘DI=10*sin(150*t)–10*I’,’I(0)=0’,’t’);
ezplot(solution_1,[0 0.5]),… xlabel(‘Time,Seconds’),ylabel(‘Current,Amperes’),…
grid
Next, the differential equation describing the RL electrical circuit is modeled using
Simulink. Simulink is a block diagram programming language that is packaged with the
Student Version of MATLAB. With Simulink, the differential equation is described using
blocks from the Simulink library. The blocks include an integrator, gain, summer, sine
wave source, and scope. The blocks are then “wired” together to generate the differential
equation. The complete Simulink model for the electrical circuit is depicted in Figure 2
The scope block in Simulink allows the student to generate a quick “picture” of the
current flowing in the electrical circuit. For this example, the x and y axes were scaled to
resemble the MATLAB graph produced for Figure 1. The results of the solution to the
equation using Simulink are shown in Figure 3.
Next, the Simulink model is modified to provide simulation data (time, current) to the
MATLAB workspace using the To Workspace block. All Simulink variables are now
defined in the MATLAB script file and the Simulink model remains unedited. The script
file calls the Simulink model and the resulting simulation data is presented using the
MATLAB plot command. The script file allows the student to quickly change the
parameters of the model to simulate multiple cases. The modified Simulink model is
shown in Figure 4.
The actual MATLAB m file used for this example is shown in Figure 5 and the results of the
simulation are shown in Figure 6.
FIGURE 5 MATLAB script file used to call Simulink model and plot results
FIGURE 6 Results from MATLAB script file
Result
Thus experiment on RL circuit was performed successfully to view real time
simulation of differential equations and verified the same using MATLAB/Simulink
Toolbox: Control System Toolbox.
Ex. No. 4 Date
AIM:
To derive the mathematical model (transfer function) of the given DC motor by
experimentally and determine its transfer function parameters then perform the MATLAB
simulation to analyse time and frequency response.
COMPONENTS REQUIRED:
S. Name of the No of
Range Type
No Components Quantity
1 DC motor with loading arrangement DC 1
2 Ammeter (0-2A) MC 1
3 Ammeter (0-10A) MC 1
4 Voltmeter (0-300V) MC 1
5 Rheostat 270Ω, 1.2A 1
Fuse calculation:
125 % of full load current
Assumptions:
The field current is constant.
The flux which is proportional to the field current is also constant.
The torque generated is proportional to the product of flux and the armature current
Tm I a
T I a Tm K t I a
Tabulation
Armature Armature Field Spring Balance Torque
Voltage Current Current t
T 9.81 ( S1 ~ S 2 ) r
Va (V) Ia (A) If (A) S1 S2 S1 ~ S2 2
Average
Average
Formula used:
1) Inertia constant: J
J
Pr
Kg m 2
4 2
dN
N
3600 dt
2) Frictional Coefficient: f
Pr N .m rad
f 2
2N s
60
Pr – Rotational Losses from the graph
3) Back EMF constant K b
E b V I a Ra
60
K b Eb
2N
Where:
V- Applied voltage in V, Ia – Armature current in A.
Ra – Armature Resistance in Ω.
N – Rated speed in RPM
4) Transfer function
( s) Kt
G( s)
Eb (s) sRa sLa f sJ K t K b
Where:
KT – Torque constant calculated from graph (T Vs Ia)
Ra – Armature Resistance in Ω
La – Inductance of Armature in H
fo – Viscous friction coefficient In N-M / rad /sec
J – Equivalent moment of inertia of motor and load referred to motor shaft (K g -m2)
Kb – Is the back EMF constant.
Model graph
Eb T
Kb Kt
I a
Back EMF (V)
N
Torque (T)
∆Eb ∆T
∆N ∆Ia
∆N
∆t Pr
Programme
clc
clear all
close all
num = [0 0 0 Kt]
den = [La*J (La*f + J*Ra) (Ra*f + Kt*Kb) Kt]
sys = tf(num,den)
step(sys)
bode(sys)
Result:
Thus the mathematical model (transfer function) of the given DC motor was
successfully and its transfer function parameters were calculated also MATLAB simulation
of its time and frequency response was done successfully.
Ex. No. 5 Date
AIM
To design the system identification through the process reaction curve by using MATLAB
Software.
APPARATUS REQUIRED
PROCEDURE
Open the MATLAB software using a MATLAB icon Open a blank M- File or
Simulink file (File, New, M file)Type the given program in M file
Run the program using debug option or using F5 key
Find the stability of the system in the output graph and compare it with
theoretical value
PROGRAM
s = tf('s');
G = (2*s+1)/(s^2+3*s+2);
k = 0.7;
T = feedback(G*k,1);
pzmap(T)
grid, axis([-2 0 -1 1])
%------Applying Adaptive LMS algorithm --------%
for i=3:1:N
%Outputs
Plant_Output(i)=Input_Plant(i)*Weights_Plant(1)+Input_Plant(i-
1)*Weights_Plant(2)+Input_Plant(i-2)*Weights_Plant(3);
Model_Output(i)=Input_Model(i)*Weights_Model(1)+Input_Model(i-
2)*error(i));
end
%Plots of error square and log of normalized error square
t=1:1:N;
error_square=power(error,2);
Max_error_square=max(error_square);
Normalized_error_Square=error_square./Max_error_square;
plot(t,error_square);
legend('error square');
title('Plot of error square Vs no of iterations');
xlabel('iterations');
ylabel('error square')
figure,
plot(t,log(Normalized_error_Square));
legend('Normalized error square log');
title('Plot of Normalized error square log Vs no of iterations');
xlabel('iterations');
ylabel('Normalized error square log')
% Testing mode %
s=30;
Input_test=rand(1,s);
for j= 3:1:s
Plant_Out_test(1)=Input_test(1)*Weights_Plant(1);
Plant_Out_test(2)=Input_test(2)*Weights_Plant(1)+Input_test(1)*Weights_Plan
t(2);
Plant_Out_test(j)=Input_test(j)*Weights_Plant(1)+Input_test(j-
1)*Weights_Plant(2)+Input_test(j-2)*Weights_Plant(3);
Out_Model_test(1)=Input_test(1)*Weights_Model(1);
Out_Model_test(2)=Input_test(2)*Weights_Model(1)+Input_test(1)*Weights_Mode
l(2);
Out_Model_test(j)= Input_test(j)*Weights_Model(1)+Input_test(j-
1)*Weights_Model(2)+Input_test(j-2)*Weights_Model(3);
error_test(1)= Plant_Out_test(1)-Out_Model_test(1);
error_test(2)= Plant_Out_test(2)-Out_Model_test(2);
error_test(j)= Plant_Out_test(j)-Out_Model_test(j);
end
p=1:1:s;
figure,
plot(p,Plant_Out_test,'-ro',p,Out_Model_test,'-.b');
legend('Plant Out test','Out Model test');
title('Comparision of outputs of Plant and Model during testing');
xlabel('iterations');
ylabel('Output')
square_error= error_test.^2;
SSE=sum(square_error);
end
RESULT:
Thus the analysis of the system identification through process reaction curve
stability MATLAB simulation platform were done successfully.
Ex. No. 6 Date
Software Requirement:
1. Computer system with MATLAB
2. MATLAB/Simulink Toolbox: Control System Toolbox
Before discussing the Pole zero maps and Routh-Hurwitz Criterion, firstly we will study the
stable, unstable and marginally stable system.
1. Stable System: If all the roots of the characteristic equation lie on the left half of the
'S' plane then the system is said to be a stable system.
2. Marginally Stable System: If all the roots of the system lie on the imaginary axis of
the 'S' plane then the system is said to be marginally stable.
3. Unstable System: If all the roots of the system lie on the right half of the 'S' plane
then the system is said to be an unstable system.
Program
for j = 1:rhTableColumn - 1
% first element of upper row
firstElemUpperRow = rhTable(i-1,1);
Result
Thus the analysis of the stability of given transfer function using Pole zero maps and
Routh Hurwitz Criterion in MATLAB simulation platform were done successfully.
Ex. No. 7 Date
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 some parameter, often a proportional gain , varied
between 0 and . The figure below shows a unity-feedback architecture, but the procedure
is identical for any open-loop transfer function , even if some elements of the open-loop
transfer function are in the feedback path.
(1)
and thus the poles of the closed-loop system are values of such that .
If we write , then this equation can be rewritten as:
(2)
(3)
Let be the order of and be the order of (the order of the polynomial
corresponds to the highest power of ).
We will consider all positive values of . In the limit as , the poles of the closed-loop
system are solutions of (poles of ). In the limit as , the poles of the
closed-loop system are solutions of (zeros of ).
No matter our choice of , the closed-loop system has poles, where is the number of
poles of the open-loop transfer function . The root locus then has branches, each
branch starts at a pole of and approaches 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 open-
loop poles minus the number of open-loop zeros, and is the number of branches of the root
locus that go to "infinity" (asymptotes).
Since the root locus consists of the locations of all possible closed-loop poles, the root locus
helps us choose the value of the gain to achieve the type of performance we desire. If any
of the selected poles are on the right-half complex 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 if a system has three or four poles, it may still behave similar
to a second- or a first-order system, depending on the location(s) of the dominant pole(s).
(4)
How do we design a feedback controller for the system using the root-locus method? Let's
assume our design criteria are 5% overshoot and 1 second rise time.
Note that since the root locus may have more than one branch, when you select a pole, you
also identify where other closed-loop poles are too, all for the same corresponding value
of . Remember that these poles will affect the response too. From the plot above, we see
that of the four poles selected (indicated by "+" signs), the two closest to the imaginary axis
are in our desired region. Since these poles tend to dominate the response, we have some
confidence that are desired requirements will be met for a proportional controller with this
value of .
Closed-Loop Response
In order to verify the step response, you need to know the closed-loop transfer function.
You could compute this using the rules of block diagram reduction, or let MATLAB do it
for you (there is no need to enter a value for K if the rlocfind command was used):
The two arguments to the function feedback are the transfer function in the forward path
and the transfer function in the feedback path of the open-loop system. In this case, our
system is unity feedback.
If you have a non-unity feedback situation, look at the help file for the MATLAB
function feedback, which demonstrates how to find the closed-loop transfer function with a
gain in the feedback path.
Checking the step response of the closed-loop system with the chosen value of .
As we expected, this response has an overshoot less than 5% and a rise time less than 1
second.
Program
clear
close all
clc
s = tf('s');
sys = (s + 7)/(s*(s + 5)*(s + 15)*(s + 20));
rlocus(sys) %%Plotting the Root Locus of a Transfer Function
axis([-22 3 -15 15])
zeta = 0.7; %%Choosing a Value of K from the Root Locus
wn = 1.8;
sgrid(zeta,wn)
K = 350;
sys_cl = feedback(K*sys,1) %%Closed Loop Response of the given system
Result
Thus the simulation of Root Locus based for the given transfer function was done
successfully and stability of the system has been found.
Ex. No. 8 Date
To Design the bode plot for the given system and also determine the gain and phase margin
using MATLAB Software.
APPARATUS REQUIRED
PROCEDURE
Open the MATLAB software using a MATLAB icon Open a blank M- File or
Simulink file (File, New, M file)Type the given program in M file
Run the program using debug option or using F5 key
Find the stability of the system in the output graph and compare it with
theoretical value
PROGRAM
1. Lag Compensator
K=9600
d1=conv([1 4 0],[1 80]) % used to formulate the polynomial
G=tf(K,d1) % generate the transfer function.
margin(G)
pmreq=input('Enter Required Phase Margin') % enter 33 as given in question
pmreq=pmreq+5
phgcm=pmreq-180
wgcm=input('Enter new gain cross over frequency') % from the first bode
plot use the mouse pointer and locate wgcm corresponding to phgcm.
[Beta,p]=bode(G,wgcm)
T=10/wgcm
Zc=1/T
Pc=1/(Beta*T)
Gc=tf([1 Zc],[1 Pc])
sys=Gc*G/Beta
margin(sys)
2..LEAD COMPENSATOR
clear variables;
% plant G parameters
s = tf('s');
a = 2.5; b = 27;
%% a) Gain K for PO=10
PO = 10; % percentage overshoot
zeta = log(100/PO)/sqrt(pi^2+ (log(100/PO))^2 ); % damping ratio
PM_d = round(100*zeta)+1; % PM desired at the nearest round value
h = tand(180-90-PM_d);
omega_c = roots([1 (a+b)/h -a*b]); % new omega_c
K = omega_c(2)*sqrt(omega_c(2)^2+a^2)*sqrt(omega_c(2)^2+b^2); % new gain K
G = K/( s*(s+a)*(s+b) ); % Plant G
figure;
margin(G);
RESULT:
Thus the mathematical model (transfer function) of the given Physical system
successfully and its transfer function parameters were calculated also MATLAB simulation
of its time and frequency response and Bodes asymptotes was done successfully.
Ex. No. 9 Date
Software Requirement:
1. Computer system with MATLAB
2. MATLAB/Simulink Toolbox: Control System Toolbox
Problem
Our ability to graphically make the various measurements needed during the design
obviously depends on the accuracy and resolution of the Bode plots of |KcGp (jω)|. High
resolution plots like those obtained from MATLAB allow us to obtain reasonably accurate
measurements. Rough, hand-drawn sketches would yield much less accurate results and
might be used only for first approximations to the design. Being able to access the actual
numerical data allows for even more accurate results than the MATLAB-generated plots.
The procedure that I use when working in MATLAB generates the data arrays for
frequency, magnitude, and phase from instructions such as the following:
Program
Uncompensated system
%% where N1= log10 (ωmin), N2 = log10 (ωmax), and num, den are the numerator and
denominator polynomials, respectively, of KcGp (s). For this example, N1 = −3; N2 = 4;
clc
clear all
close all
N1 = −3;
N2 = 4;
num = 25 ∗ 280 ∗[1 0.5];
den = conv([1 0.2 0], conv([1 5],[1 70]));
w = logspace(N1,N2,1+100*(N2-N1));
[mag,ph] = bode(num,den,w);
semilogx(w,20*log10(mag),w,ph),grid
The data arrays mag, ph, and w can be searched to obtain the various values needed during
the design of the compensator.
Compensated system
clc
clear all
close all
N1 = −3;
N2 = 4;
w = logspace(N1,N2,1+100*(N2-N1));
The data arrays mag, ph, and w can be searched to obtain the various values needed during
the design of the compensator.
Result
Thus the design of the Lag Lead Compensator were done successfully and evaluation of
closed loop performance of given simple system had been done.
Ex. No. 10 Date
Software Requirement:
3. Computer system with MATLAB
4. MATLAB/Simulink Toolbox: Control System Toolbox
Theory
The PID controller is widely employed because it is very understandable and because it is
quite effective. One attraction of the PID controller is that all engineers understand
conceptually differentiation and integration, so they can implement the control system even
without a deep understanding of control theory. Further, even though the compensator is
simple, it is quite sophisticated in that it captures the history of the system (through
integration) and anticipates the future behavior of the system (through differentiation). We
will discuss the effect of each of the PID parameters on the dynamics of a closed-loop
system and will demonstrate how to use a PID controller to improve a system's
performance.
PID Overview
In this tutorial, we will consider the following unity-feedback system:
The output of a PID controller, which is equal to the control input to the plant, is calculated
in the time domain from the feedback error as follows:
(1)
First, let's take a look at how the PID controller works in a closed-loop system using the
schematic shown above. The variable ( ) represents the tracking error, the difference
between the desired output ( ) and the actual output ( ). This error signal ( ) is fed to the
PID controller, and the controller computes both the derivative and the integral of this error
signal with respect to time. The control signal ( ) to the plant is equal to the proportional
gain ( ) times the magnitude of the error plus the integral gain ( ) times the integral of
the error plus the derivative gain ( ) times the derivative of the error.
This control signal ( ) is fed to the plant and the new output ( ) is obtained. The new
output ( ) is then fed back and compared to the reference to find the new error signal ( ).
The controller takes this new error signal and computes an update of the control input. This
process continues while the controller is in effect.
The transfer function of a PID controller is found by taking the Laplace transform of
Equation (1).
(2)
where = proportional gain, = integral gain, and = derivative gain.
(5)
Let
m = 1 kg
b = 10 N s/m
k = 20 N/m
F=1N
Substituting these values into the above transfer function
(6)
The goal of this problem is to show how each of the terms, , , and , contributes to
obtaining the common goals of:
Fast rise time
Minimal overshoot
Zero steady-state error
Proportional Control
From the table shown above, we see that the proportional controller ( ) reduces the rise
time, increases the overshoot, and reduces the steady-state error. The closed-loop transfer
function of our unity-feedback system with a proportional controller is the following,
where is our output (equals ) and our reference is the input:
(7)
(8)
Let equal 300 as before and let equal 10.
This plot shows that the addition of the derivative term reduced both the overshoot and the
settling time, and had a negligible effect on the rise time and the steady-state error.
Proportional-Integral Control
Before proceeding to PID control, let's investigate PI control. From the table, we see that the
addition of integral control ( ) tends to decrease the rise time, increase both the overshoot
and the settling time, and reduces the steady-state error. For the given system, the closed-
loop transfer function with a PI controller is:
(9)
Let's reduce to 30, and let equal 70.
We have reduced the proportional gain ( ) because the integral controller also reduces the
rise time and increases the overshoot as the proportional controller does (double effect). The
above response shows that the integral controller eliminated the steady-state error in this
case.
Proportional-Integral-Derivative Control
Now, let's examine PID control. The closed-loop transfer function of the given system with
a PID controller is:
(10)
After several iterations of tuning, the gains = 350, = 300, and = 50 provided the
desired response.
Now, we have designed a closed-loop system with no overshoot, fast rise time, and no
steady-state error.
Program
clear
close all
clc
%% Initial values
Kp = 1;
Ki = 1;
Kd = 1;
s = tf('s');
C = Kp + Ki/s + Kd*s %% PID Controller Transfer Function
tf(C)
s = tf('s');
P = 1/(s^2 + 10*s + 20); %% given simple mass-spring-damper system TF
step(P) %% Open-Loop Step Response
Result
Thus the design of PID controllers was done successfully and evaluation of closed loop
performance of simple system was done.
Ex. No. 11 Date
x= Ax + Bu
y= Cx + Du
with x(t) Є Rn, measured output y(t) Є Rp, and control input u(t) Є Rm. For digital control
purposes it is desired to define a discrete time index k such that
t = Kt
with T the sampling period. Then, the discrete control input uk is to be switched at times
kT, k= 0,1,...,N-1 by the microprocessor.
The usual procedure for controlling the plant is to hold the control input u(t) constant
between control switching. This may be achieved by adding a ZOH before the plant.
Then, the continuous plant input u(t) is given in terms of the discrete control uk by
Note that u(t) is switched at the times kT so that it is continuous from the right.
T
uk u(t) x(t) y(t) yk
ZOH x Ax Bu C
hold sample
Sampling a continuous-time system
Also shown in the figure is a sampler with period T added to the output channel of the
plant. This A/D device generates the samples
Yk = Y(kT)
of the output. Let us also define the samples
Xk = X(kT)
of the state vector.
It is now required to determine a dynamical relation betweenuk and xk such that
Xk+1 = As Xk + Bs Uk.
That is, we need to determine the sampled equivalents As, Bs of Aand B.
To achieve this, first write the solution of state space equations, which is
t
x(t ) e A ( t t 0 )
x(t 0 ) e A(t ) Bu ( )d
t0
kT
Since u(t) has the constant value of uk over the sample period due to the ZOH, we may
extract it from the integrand. Then, changingvariables to λ= τ-kT yields
T
x k 1 e AT
x k e A[T ] Bd .u k
0
Changing variables again to τ= T-λ yields finally
T
x k 1 e AT x k e A Bd .u k
0
By comparison with (0 we may now identify the discretized plant matrices as
As= eAT
T
B e A Bd
s
H(s) = C (sI-A)-1 B
Hs(z) = C (zI-As)-1 Bs,
(1 e sT ) (1 z 1 )
L( ZOH )
s s
Let us consider Fig. Error! Reference source not found.. The transfer function from uk to yk
including the ZOH is given by
H (s)
H s ( z ) (1 z 1 ) Z With Z (.) the Z-transform.
s
This equation says that Hs(z)/(1-z-1)= Z(H(s)/s). Since the Z-transform of the discrete unit
step is 1/(1-z-1), this means that the discrete step response should equal the samples of the
continuous step response. Thus, ZOH sampling is also called discretization by step
invariance.
The key to finding the discretized transfer function Hs(z) is determining the Z-transform of
H(s)/s. This may be achieved using the partial fraction expansion. If the n+1 poles of H(s)/s
are distinct, then its PFE is
H ( s) n1 K i
s i 1 s si
with Ki the residue of the pole at s= si. A term-by-term Z- transform of this is easy to
perform, for recall that each term has an inverse Laplace transform of Kiesit. However, this
is equal to Ki(esiT)k= Kizik, which has a Z-transform of Ki/(1-ziz-1).
Therefore, the sampled transfer function is given by
n 1 n 1
Ki Ki
H s ( z ) (1 z 1 ) (1 z 1 ) where
i 1 1 e i 1 1
siT
z 1 z i z 1
zi e siT
Evaluation of Hs(z) by using this formula, or by discretization of (A,B) and then application
of (0, will yield the same result.
If H(s)/s has repeated poles the partial-fraction expansion will contain terms like K/(s-si)j.
If some of the poles of H(s)/s are complex, then the associated residues Ki in (0 will be
complex. In this case it is better to keep the complex pole pair in a single term. In either case
we should refer to Table 7.1-1 to obtain the Z-transforms of the terms in the partial-fraction
expansion of H(s)/s.
The relative degree of a scalar transfer function is the degree of the denominator minus the
degree of the numerator. It is equivalent to the number of zeros at infinity. It is an
interesting fact that, no matter what the relative degree of the continuous-time transfer
function, the relative degree of the discretized equivalent Hs(z) is always equal to one,
except at some isolated values of the sampling period T. This may be seen by examining (0,
for on combining the sum over a common denominator, the constant term in the numerator
vanishes because H(s)/s has relative degree of two. The numerator term in z-1 is the
highest-order term, and its coefficient is a transcendental equation in T. That is, it vanishes
only for isolated values of T.
Discretize the following continuous-time transfer function:
s 1
H (s) e 0.3s
s 4s 5
2
This system has an input delay of 0.3 s. Discretize the system using the triangle (first-order-
hold) approximation with sample time Ts = 0.1 s.
Program
clc
clear all
close all
H = tf([1 -1],[1 4 5],'InputDelay', 0.3);
Hd = c2d(H,0.1,'foh');
%%Compare the step responses of the continuous-time and discretized systems.
step (H,'-',Hd,'- -')
Result
Thus discretization the given continuous system were done successfully and the effect of
sampling for various sampling time also be done.
Ex. No. 12 Date
Software Requirement:
3. Computer system with MATLAB
4. MATLAB/Simulink Toolbox: Control System Toolbox
Problem:
Consider the state model given below.
𝑥̇ = 𝐴𝑥̇ + 𝐵𝑢
𝑦 = 𝐶𝑥̇
0 1 0 0
Where A 0 0
1 , B 0, C 1 0 0 in which
A31 A32 A33 1
𝐴31 = 𝑑𝑚𝑟, 𝐴33 = (𝑑 + 𝑚 + 𝑟), 𝐴32 = 𝑑𝑚 + (𝑑 + 𝑚) 𝑟,
With 𝑟 = number at the unit place in roll number,
𝑑 = number at the tenth place in date of birth,
𝑚 = number at the unit place in the month of birth.
Check controllability and observability of the above system by both Kalman’s Test and
Gilbert’s Test.
Programe :
%% Check for observability and controllability
% Name of student: Roll No. 33
% Date of birth: 17 Month of birth: 11
clear
close all
clc
%% Initial values
r = 3; % number at the unit place in roll number
d = 1; % number at tenth place in date of birth
m = 1; % number at unit place in month of birth
A31 = d*m*r; A32 = d*m+(d+m)*r; A33 = d+m+r;
%% Problem: Consider the system representation
A = [0 1 0;0 0 1;-A31 -A32 -A33];
B = [0; 0; 1];
C = [1 0 0];
% eigenvaues (just for checking stability)
E = eig(A);
%% Controllability Test
% Kalman's Test: Method 1 (by calculation)
Qc1 = [B A*B A^2*B];
R1 = rank(Qc1);
% Kalman's Test: Method 2 (using inbuilt command)
Qc2 = ctrb(A,B);
R2 = rank(Qc2);
% Gilbert's Test
[M,D] = eig(A); % To get modal and diagonal matrices
Lambda = inv(M)*A*M;
B_tilde = inv(M)*B;
%% Observability Test
% Kalman's Test: Method 1 (by calculation)
Qo1 = [C; C*A; C*A^2];
R3 = rank(Qo1);
% Kalman's Test: Method 2 (using inbuilt command)
Qo2 = obsv(A,C);
R4 = rank(Qo2);
% Gilbert's Test
C_tilde = C*M;
Result
Thus the controllability and observability in continuous and discrete domain in simulation
platform (MATLAB) was done successfully.
Ex. No. 13 Date
Software Requirement:
1. Computer system with MATLAB
2. MATLAB/Simulink Toolbox: Control System Toolbox
Problem
The magnetically suspended ball
There are several different ways to describe a system of linear differential equations.
The state-space representation is one of the way. For a single-input, single-output (SISO)
LTI system, the state-space form is given below:
where:
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 ( ).
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)).
For simplicity, let's assume the reference is zero, = 0. The input is then
The state-space equations for the closed-loop feedback system are, therefore,
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:
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).
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:
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 = ...).
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, : 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).
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.
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, .
Responses of all the state variables are plotted below. Recall that lsim gives us and ; to
get , we need to compute .
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.
Programe :
%% State feedback and state observer
clear
close all
clc
A=[0 1 0; 980 0 -2.8 ; 0 0 -100 ];
B=[0; 0; 100 ];
C = [ 1 0 0 ];
% eigenvaues (just for checking stability)
poles = eig(A)
% Draw the Open-Loop Response to Non-Zero Initial Condition
t = 0:0.01:2;
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)
title('Open-Loop Response to Non-Zero Initial Condition')
xlabel('Time (sec)')
ylabel('Ball Position (m)')
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)')
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)')
lsim(sys_cl,Nbar*u,t)
title('Linear Simulation Results (with Nbar)')
xlabel('Time (sec)')
ylabel('Ball Position (m)')
axis([0 2 0 1.2*10^-3])
Bt = [ B*Nbar
zeros(size(B)) ];
Ct = [ C zeros(size(C)) ];
sys = ss(At,Bt,Ct,0);
lsim(sys,zeros(size(t)),t,[x0 x0]);
title('Linear Simulation Results (with observer)')
xlabel('Time (sec)')
ylabel('Ball Position (m)')
t = 0:1E-6:0.1;
x0 = [0.01 0.5 -5];
[y,t,x] = lsim(sys,zeros(size(t)),t,[x0 x0]);
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)')
Result
Thus the design of State feedback and state observer and evaluation of closed loop
performance was done successfully.
References:
Experiments
These lab Manual experiments are taken from the following References
No.
https://en.wikipedia.org/wiki/Differential_equation
Solving Differential Equations Using MATLAB/Simulink
Frank W. Pietryga, P.E. University of Pittsburgh at Johnstown.
3
Proceedings of the 2005 American Society for Engineering Education
Annual Conference & Exposition Copyright © 2005, American Society for
Engineering Education
6 Routh- Hurwitz Criterion
https://www.javatpoint.com/control-system-routh-hurwitz-stability-
criterion
Program - Farzad Sagharchi
https://in.mathworks.com/matlabcentral/fileexchange/17483-routh-hurwitz-
stability-criterion
Pole Zero map - https://in.mathworks.com/help/ident/ref/lti.pzmap.html
7 Introduction: Root Locus Controller Design
https://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&sec
tion=ControlRootLocus
9 Lag-Lead Compensator Design Using Bode Plots - Prof. Guy Beale
Electrical and Computer Engineering Department, George Mason
University, Fairfax, Virginia
10 Introduction: PID Controller Design
https://ctms.engin.umich.edu/CTMS/index.php?example=Introduction&s
ection=ControlPID
11 These notes are taken from F.L. Lewis, Applied Optimal Control and
Estimation: Digital Design and Implementation, Prentice-Hall, New
Jersey, TI Series, Feb. 1992.