C&i Lab Manual-Sscet-20.11.2024
C&i Lab Manual-Sscet-20.11.2024
LABORATORY RECORD
Submitted by
STUDENT NAME :
REGISTER NUMBER :
BRANCH : EEE
Laboratory
CYCLE 1
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’
asymptotes.
CYCLE 2
TOTAL: 60 PERIODS
CONTENTS
Exp. Page Marks
Date Title of the Experiment Signature
No. No. (10)
10 .
11
12
13
14
15
16
1
1. MATLAB R2021
2. Simulink -
FORMULA:
𝑑2 𝑑 𝑑
𝑀2 2 (𝑦2) + 𝑓2 ( (𝑦2) − (𝑦1)) + 𝐾2(𝑦2 − 𝑦1) = 𝐹(𝑡)
𝑑𝑡 𝑑𝑡 𝑑𝑡
𝑑2 𝑑 𝑑 𝑑
𝑀1 (𝑦1) − 𝑓 2 ( (𝑦2) − (𝑦1)) − 𝐾 (𝑦
2 2 − 𝑦1 ) + 𝑓 1 ( (𝑦1)) + 𝐾1𝑦1 = 0
𝑑𝑡2 𝑑𝑡 𝑑𝑡 𝑑𝑡
BLOCK DIAGRAM/CODE:
1. Code:
>>num=[5 5 11];
>>den=[25 40 91 27 30];
>>G=tf(num,den);
>>kp=dcgain(G);
>>ess=1/(1+kp);
>>step(G);
3
2. Simulink model:
OBSERVATIONS:
1. Code:
num =
5 5 11
den =
25 40 91 27 30
G=
5 s^2 + 5 s + 11
--- - - - - -
25 s^4 + 40 s^3 + 91 s^2 + 27 s + 30
ess =
0.7317
4
2. Simulink:
5
MEASUREMENTS VALUES
60.484%
Overshoot
0.806
Preshoot
5.563
Undershoot
1.8585 seconds
Rise Time
1.848 seconds
Fall Time
45.5 seconds
Settling Time
0.347
Final Value
0.7317
Steady state Error
INFERENCE:
The differential equations for a linear mechanical system were established and it
was realized using Simulink.
The corresponding transfer function graph was plotted for step input, in Simulink
and MATLAB, and the properties were analyzed.
The damping effect of the spring system was established, and the corresponding
data was tabulated.
RESULT:
Thus, the mathematical model of the linear mechanical system was simulated,
and the corresponding parameters were noted.
6
APPARATUS:
1. MATLAB R2021
2. Simulink -
FORMULA/DERIVATION:
In a series RLC circuit, the resistor acts as the dissipating element, while the
conductor and inductor act as energy storing elements. We utilize the transfer
function, and by giving the input as a unit step signal, we can model the system
and obtain the respective graph.
Here, let:
L = inductance (H)
R = resistance ( R)
C = capacitance(F)
7
𝐿𝑑𝑖(𝑡) 1
𝑉𝑠 (𝑡) − − 𝑖(𝑡)𝑅 − ∫ 𝑖(𝑡)𝑑𝑡 = 0
𝑑𝑡 𝐶
𝑑𝑞(𝑡)
Here we know that 𝑖(𝑡) = ,
𝑑𝑡
𝐿𝑑 𝑑𝑞(𝑡) 𝑅𝑑𝑞(𝑡) 1
𝑉(𝑡)𝑠 = ( ) + + ∫ 𝑑𝑞
𝑑𝑡 𝑑𝑡 𝑑𝑡 𝐶
𝐿𝑑2𝑞(𝑡) 𝑅𝑑𝑞 𝑞
𝑉𝑠 (𝑡) = + +
𝑑𝑡2 𝑑𝑡 𝐶
𝑑2𝑞(𝑡) 𝑑𝑞(𝑡) 1
𝐿 = 𝑅( ) + 𝑞(𝑡) = 𝑉𝑠 (𝑡)
𝑑𝑡2 𝑑𝑡 𝐶
𝑄(𝑠) = (1/𝐿)
𝑉 (𝑠) 𝑅𝑠 1
𝑠 𝑠2 + 𝐿 + 𝐿𝐶
8
BLOCK DIAGRAM/CODE:
>>num=[1/L];
>>den=[1 R/L 1/(L*C) ];
>>G=tf(num,den);
>>step(G);
>>[w,zeta,p]=damp(G);
>>tau=1./w; %time constant
2. Simulink model:
9
OBSERVATIONS:
1. MATLAB code:
2. Simulink:
10
MEASUREMENTS VALUES
30.921%
Overshoot
0.658%
Pre shoot
9.302%
Undershoot
317.030 ms
Rise Time
Theory:
We know that current lags in the inductor, leads in capacitor and is in phase in
resistor.
Here, the graph is divided into transient and steady state regions, where the
transient state is influenced by initial conditions(R,L,C), while the steady state
component remains unchanged.
Hence from the graphs, we can observe the under damping of the wave,
before reaching a steady state value. By changing the values of R, L and C, we
can change the damping ratio and in turn the response as well.
RESULT:
Thus, for a series RLC electrical circuit, the transfer function was
obtained, and the corresponding Simulink model and MATLAB code
was designed. For a step input, the resultant graph was plotted and
analyzed.
11
1. MATLAB R2021
2. Simulink -
FORMULA/THEORY:
A process reaction curve will be generated in response to a disturbance. This
process curve is then used to calculate the controller gain, integral time, and
derivative time. It is performed in open loop so that no control action occurs,
and the process response can be isolated.
To generate a process reaction curve, the process can reach steady state or as
close to steady state as possible. Then, in open loop, so that there is no control
action, a small step disturbance is introduced, and the reaction of the process
variable is b recorded.
For an oscillatory reaction curve, the dimensionless equation for model 1 will
be adopted. To distinguish between process models that do not have a process
zero (where 𝑎̅ = 0) and those which do have a zero (where 𝑎̅≠ 0) the following
lemma is needed.
12
13
14
BLOCK DIAGRAM:
1. Simulink model:
OBSERVATIONS:
1. Simulink:
Process A:
Process B:
15
CALCULATIONS:
1. Process A:
1 1.005 − 1
𝜒= 𝑙𝑛 ( )
10.33 − 24.73 1.206 − 1
𝝌 = 𝟎. 𝟐𝟓𝟖
ln(1.206 − 1)2
𝜍= √
𝜋2 + (𝑙𝑛1.206 − 1)2
𝝇 = 𝟎. 𝟒𝟒𝟗
14.4
𝑟=
√4𝜋2 + 14.42 ∗ 0.2582
𝑟 = 𝟏. 𝟗𝟕𝟐𝟕
16
1.9727
𝜃 = 10.33 + ln(1.206 − 1)
0.449
𝜽 = 𝟑. 𝟑𝟗
2. Process B:
1 1.01 − 1
𝜒= 𝑙𝑛 ( )
8.331 − 22.73 1.385 − 1
𝝌 = 𝟎. 𝟐𝟓𝟕
14.199 ∗ 0.257
𝜍=
√4𝜋2 + 14.1992 ∗ 0.2572
𝝇 = 𝟎. 𝟓
14.199
𝑟=
√4𝜋2 + 14.1992 ∗ 0.2572
𝑟 = 𝟏. 𝟗𝟓𝟒
1.385 − 1 2
𝑎′ = 0.5 + √0.52 + (1 − ( ) )
𝑒−0.5∗8.531
𝒂′ = 𝟏. 𝟓𝟑𝟗
1. ς 0.449 0.5
2. χ 0.258 0.257
3. τ 1.9727 1.954
4. a’ 0 1.539
5. θ 3.39 4.657
INFERENCE:
From the graphs, we can analyze the process curve and obtain the necessary
parameters.
The damping ratio for both the processes reinforce the fact that the curves are
under damped.
The delay time θ is higher for process B and it is indicative for the fact that
process reaction curve for process B takes longer than that of A.
RESULT:
Thus, using Simulink, it was possible to obtain the process reaction curves of the
given process. The parameters were obtained from the graph and additional
values were calculated as well. Thus, the resultant equations of the processes
were modeled from these values as well.
18
APPARATUS:
1. MATLAB R2021
2. Simulink -
THEORY:
The necessary and sufficient condition for stability is that all the elements
in the column of a Routh array be positive. If the condition is not met, the
system is unstable and the number of the sign changes in the elements of
the first column of the Routh array corresponds to the number of roots in
the characteristic equation in the right half of the s-plane.
Thus, if all the roots are placed in the left side of s-plane, then the system is
stable. Even if some roots are placed on the right side of the s-plane, then the
system becomes unstable.
CALCULATION:
𝟐𝟓
𝑮(𝒔) =
𝒔𝟐+𝟔𝒔
s2 1 25
6
s1
25
s0
Since there are no sign changes in the first column of the Routh array, the
system is ‘Stable’. Both roots lie on the left half of s-plane.
Number of Zeros: 0
Number of Roots: 2 [0, -6]
20
MATLAB CODE:
𝟐𝟓
𝑮(𝒔) = 𝒔𝟐+𝟔𝒔
clear;
close all;
clc;
format compact;
coeffVector = input (‘input vector of your system coefficients: \n i.e. [an an-
1 an-2 ... a0] = ‘);
ceoffLength = length(coeffVector);
rhTableColumn = round(ceoffLength/2);
rhTable = zeros(ceoffLength,rhTableColumn);
if (rem(ceoffLength,2) ~= 0)
% if odd, second row of table will be
rhTable(2,1:rhTableColumn – 1) = coeffVector(1,2:2:ceoffLength);
else
% if even, second row of table will be
rhTable (2,: ) = coeffVector(1,2:2:ceoffLength);
end
21
epss = 0.01;
for I = 3:ceoffLength
for j = 1:rhTableColumn – 1
% first element of upper row
firstElemUpperRow = rhTable(i-1,1);
unstablePoles = 0;
for I = 1:ceoffLength – 1
if sign(rhTable(I,1)) * sign(rhTable(i+1,1)) == -1
unstablePoles = unstablePoles + 1;
end
end
if unstablePoles == 0
fprintf (‘~~~~~> it is a stable system! <~~~~~\n’)
else
fprintf (‘~~~~~> it is an unstable system! <~~~~~\n’)
end
fprintf (‘\n Number of right hand side poles =%2.0f\n’,unstablePoles)
reply = input (‘Do you want roots of system be shown? Y/N ‘, ‘s’);
if reply == ‘y’ || reply == ‘Y’
sysRoots = roots(coeffVector);
fprintf (‘\n Given polynomial coefficients roots :\n’)
sysRoots
end
OBSERVATIONS:
1. Code:
𝟐𝟓
𝑮(𝒔) = 𝒔𝟐+𝟔𝒔
Routh-Hurwitz Table:
rhTable =
1 25
6 0
25 0
~~~~~> it is a stable system! <~~~~~
-3.0000 - 4.0000i
H1 =
25
--- - -
s^2 + 6 s
INFERENCE:
For a stable system, the roots of the characteristic equation must have negative
real parts.
If any root of the characteristic equation has a positive real part or if there is a
repeated root on the imaginary axis, then the system is unstable.
If all the roots of the characteristic equation have negative real parts except for
the presence of one or more non repeated roots on the imaginary axis, then the
system is limitedly or marginally stable.
The pole zero map also reinforces the above conditions, in a graphical manner.
RESULT:
1. MATLAB R2021
THEORY:
The root locus technique in control system was first introduced in the
year 1948 by Evans. Any physical system is represented by a transfer
function in the form of
We can find poles and zeros from G(s). The location of poles and zeros are crucial
keeping view stability, relative stability, transient response, and error analysis.
When the system is put to service stray inductance and capacitance get into the
system, thus changes the location of poles and zeros.
In root locus technique in control system, we will evaluate the position of the
roots, their locus of movement and associated information. This information will
be used to comment upon the system performance.
Keeping all these points in mind we are able to draw the root locus plot for any
kind of system. Now let us discuss the procedure of making a root locus:
Find out all the roots and poles from the open loop transfer function and
then plot them on the complex plane.
All the root loci start from the poles where k = 0 and terminates at the
zeros where K tends to infinity. The number of branches terminating at
infinity equals to the difference between the number of poles & number
of zeros of G(s)H(s).
Find the region of existence of the root loci from the method described
above after finding the values of M and N.
Plot the asymptotes and centroid point on the complex plane for the root
loci by calculating the slope of the asymptotes.
Now calculate angle of departure and the intersection of root loci with
imaginary axis.
Now determine the value of K by using any one method that I have
described above. By following above procedure, you can easily draw the
root locus plot for any open loop transfer function.
You can easily comment on the stability of the system by using Routh
Array.
28
MATLAB CODE:
1. Code:
1
1. 𝑠3+6𝑠2+45𝑠
29
0.075𝑠2+𝑠+1
2.
𝑠3+3𝑠2+5𝑠
OBSERVATIONS:
1. Code:
1
1.
𝑠3+6𝑠2+45𝑠
30
0.075𝑠2+𝑠+1
2.
𝑠3+3𝑠2+5𝑠
INFERENCE:
Note that if the denominator of G(s) and the numerator of H(s) involve common
factors then the corresponding open-loop poles and zeros will cancel each other,
reducing the degree of the characteristic equation by one or more.
A slight change in the pole-zero configuration may cause significant
changes in the root- locus configurations.
The cancelled pole of G(s)H(s) is a closed-loop pole of the system and this must
be added to the closed-loop poles obtained from the root-locus plot of G(s)H(s).
General effects of the addition of zeros:
RESULT:
Thus, the Root Locus analysis is done on the given systems using MATLAB, and
the corresponding characteristics and graphs were obtained and studied.
32
1. MATLAB R2021
33
A) Bode plot A
34
B) Bode plot B
TABULATION:
INFERENCE:
For both the system the phase starts at -90 and hence there is a pole at the
origin for both the systems.
From the tabular column Gain margin for A is 48dB and that for B it is infinity.
35
Since for the magnitude Bode plot B the Gain margin is infinity it is inferred
that it is a very stable system, but the response is sluggish with no
oscillations. It is a very stable system because infinite gain can be increased
or decreased, and the stability of the system won’t be affected
For the bode plot B 48db can be increased or decreased till the system
becomes unstable.
Greater the phase margin greater the stability of the system. The phase
margin of B is > than the phase margin of A.
RESULT:
Thus, the 3rd order system was analyzed using bode plot and the frequency
parameters were tabulated
36
APPARATUS:
1. MATLAB R2021
FORMULA/THEORY:
Frequency response is the quantitative measure of the output
spectrum of a system inresponse to a stimulus, usually a sinusoidal
input, and is used to characterize the dynamics of the system.
Frequency response analysis is the technique whereby a sinusoidal test
signal is usedto measure points on the frequency response of a transfer
function.
CALCULATION:
Number of poles=2
Number of zeros=0
From the magnitude plot, it can be seen that the slope with
which it starts is -20 dB/dec. Thus, the system is a type-1 system,
i.e., it has a pole at 𝑠 = 0. This can also be said from the fact that
the phase plot begins at −90°.
4. Finding Gain:
MATLAB CODE:
MATLAB:
40
INFERENCE:
A pole contributes −90° to the phase plot because:
This method of finding the transfer function is immensely helpful when working
with experimental data. From the data, the Bode plot can be obtained and thus,
the transfer function of the system can be easily obtained.
RESULT:
Thus, the transfer function of the given system was found using frequency
response and Bode’s asymptotes.
42
1. MATLAB R2021
FORMULA/THEORY:
1. Lead compensator:
We know that the phase of the output sinusoidal signal is equal to the sum of the
phase angles of input sinusoidal signal and the transfer function. So, to produce
the phase lead at the output of this compensator, the phase angle of the transfer
function should be positive. This will happen when 0<β <1. Therefore, zero will be
nearer to origin in pole-zero configuration of the lead compensator.
2. Lag Compensator:
Here, the capacitor is in series with the resistor R2 and the output is measured
across this combination.
From the transfer function, we can conclude that the lag compensator has one
1 1
pole at 𝑠 = − and one zero at 𝑠 = − . This means, the pole will be nearer to
𝑐𝛼 𝛼
origin in the pole-zero configuration of the lag compensator.
Substitute, 𝑠 = 𝑗𝜔 in the transfer function.
45
PROCEDURE:
Q1. The open loop transfer function of certain unity feedback control system is given by
G(s) = K/s(s+4) (s+80). It is desired to have the phase margin to be at least 33° and the
velocity error constant Kv= 30 sec-1. Design a phase lag series compensator.
ANS:
8. The open loop response is generated by placing the plant in series with the lag
compensator.
46
The actual phase margin is calculated at the new gain crossover frequency.
Q2. Design a lead compensator for a unity feedback system with open loop transfer
function, G(s) = K/s(s+8) to satisfy the following specifications (i) percentage peak
overshoot = 9.5% (ii) natural frequency response, ωn = 12 rad/sec (iii) Velocity error
constant Kv ≥ 10.
ANS:
1. Determination of the dominant pole with the given parameters
6. Determining the open loop transfer function of the lead compensated system
The lead compensator is connected in series with the plant the value of K is
determined by the above formula. And the vector lengths from all poles are
represented as l1,l2,l4 and for zeroes it is l3.
7. The check for error requirement is done.
47
MATLAB CODE:
Q1.
>> Kv = 30
>> K = Kv * 4 * 80
>> G=tf(K, conv([1 4 0],[1 80]))
>> [Gm Pm] = margin(G)
>> margin(G)
>> Pd = 33
>> Pd = Pd + 5
>> Phgcm = -142
>> wgcm= 4.58 % 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
>> figure(1)
>> margin(G)
>> hold on
>> margin(sys)
>> legend('Without Compensator', 'With Lag compensator')
>> figure(2)
>> step(feedback(G,1))
>> hold on
>> step(feedback(sys,1))
>> legend('Without Compensator', 'With Lag compensator')
Q2.
>> Mp=9.5
>> e=log(Mp)*sqrt(1/(pi^2+(log(Mp)^2)));
>> w=12;
>> s1 = 0
>> s2 = -8
48
%Dominant pole
>> sd1=-e*w+j*w*sqrt(1-e^2)
>> sd2=-e*w-j*w*sqrt(1-e^2)
>> theta1=angle(sd1 - s1)
>> theta2=angle(sd1 - s2)
>> phi = theta1 + theta2 - 3.14
>> phi1 = (phi)/2
>> K=(l1*l2*l4)/l3;
>> G=K*G/(s*(s+8))
>> sys=K/(s*(s+8))
>> figure(1)
>> margin(sys)
>> hold on
>> margin(G)
>> legend('Uncompensated','Compensated')
>> figure(2)
>> step(feedback(sys,1))
>> hold on
49
>> step(feedback(G,1))
>> legend('Without Compensator', 'With Lead compensator')
OBSERVATION:
Q1.
50
Q2.
51
TABULATION:
Parameters Q1 Q2
Uncompensated Compensated Uncompensated Compensated
0.1064 0.2525 0.1110 0.1432
Rise time(s)
2.9940 2.3096 0.9089 0.4917
Settling
Time(s)
68.2050 40.4974 33.7293 12.6234
Overshoot(%)
0.2895 0.649 0.2763 0.3137
Peak time(s)
1.6821 1.4050 1.3373 1.1262
Peak Value
INFERENCE:
Lag compensators reduce the gain crossover frequency of the system. Thus,
the system response becomes slower.
Lag compensators reduce the high frequency gain of the system. Hence, the
high frequency noise attenuation becomes better.
52
The time constant of the lag compensator should not be unnecessarily large.
Otherwise, the system's response will be too slow.
From the observation table for the first question Lag compensators allow a
high gain at low frequencies and thus improve the steady state error.
From the observation table the presence of a lead compensator increases the
gain of the system at high frequencies (the amount of this gain is equal to a).
This can increase the crossover frequency, which will help to decrease the rise
time and settling time of the system (but may amplify high frequency noise).
And it is seen that the gain margin of lead compensated system is infinity.
A gain margin of infinity means that no matter how much you increase
the gain, the system will always be stable.
o If the design specifications are given in terms of steady state error and
phase margin, either the lead or the lag compensator may be able to
meet the requirement.
o However, if specification on rise time or gain crossover frequency is
also to be met, then only one of the two compensators would be able
to do the job. Or we need to combine lag and lead compensator.
RESULT:
Thus, the lead and lag compensators were designed as per the requirements and
their closed loop performance was analyzed. The corresponding graphs were also
plotted and analyzed.
53
APPARATUS:
1. MATLAB R2021
FORMULA/THEORY:
For a PI controller:
Step 4:
Determine open loop transfer function of compensated system.
54
When the damping ratio 𝜁, error constant and natural frequency 𝜔d are the
design parameters, the following steps are followed:
Step 1:
Determine the dominant pole 𝑠d and calculate its magnitude and phase:
Step 2:
Step 3:
Determination of transfer function of PI/PID controller
For PI controller:
Determine 𝐾i from the specified error constant, such that the compensated
system meets the error requirement.
Calculate the parameter 𝐾D and 𝐾P using the following equations
55
Step 4:
Determine open loop transfer function of compensated system
Questions Given:
1. Consider a unity feedback system with open loop transfer function G(s) =
100/(s+1)(s+2)(s+5). Design a PI controller, so that the phase margin of the
system is 60° at a frequency of 0.5 rad/sec.
56
2. Consider a unity feedback system with open loop transfer function G(s) = 75/
(s+1)(s+3)(s+8). Design a PID controller to satisfy the following specifications
(a) steady state error for unit ramp input should be less than 0.08, (b)
Damping ratio = 0.8 (c) Natural frequency of oscillation = 2.5 rad/sec.
MATLAB CODE:
For 1st question:
>> PM1=3.14+(theta1)
>> theta2=PM-PM1
%determining constants
>> Ki=(-w*sin(theta2))/M1
>> Kp=cos(theta2)/M1
>> contr=pid(Kp,Ki)
>> OL=contr*G
>> figure(1)
>> step(feedback(G,1))
>> hold on
>> step(feedback(OL,1))
>> legend('Without controller', 'With controller')
>> figure(2)
>> subplot 211
>> rlocus(OL)
>> title('Root Locus of G(s)')
57
>> e=0.8;
>> ess=0.08;
>> w=2.5;
>> s=tf('s');
>> G=75/((s+1)*(s+3)*(s+8));
%Dominant pole
>> sd1=-e*w+j*w*sqrt(1-e^2)
>> sd2=-e*w-j*w*sqrt(1-e^2)
>> M1=abs(sd1)
>> theta1=angle(sd1)
>> G1=75/((sd1+1)*(sd1+3)*(sd1+8));
>> M2=abs(G1)
>> theta2=angle(G1)
>> Kv=1/ess
>> Ki=Kv/3.125
>> Kd=(sin(theta2)/(M1*M2*sin(theta1)))+(Ki/M1^2)
>> Kp=(-sin(theta2+theta1)/(M2*sin(theta1)))-(2*Ki*cos(theta1)/M1)
%Finding the TF
>> cont=pid(Kp,Ki,Kd)
>> OL=G*cont
>> figure(1)
>> step(feedback(G, 1))
>> hold on
>> step(feedback(OL, 1))
>> legend('No controller', 'With controller')
>> figure(2)
>> subplot 211
>> rlocus(OL)
>> title('Root Locus of G(s)')
59
OBSERVATIONS:
First question:
60
Second question:
61
TABULATIONS:
INFERENCE:
From the observations, a PI/PID controller always makes the steady state
error vanish.
From the plots obtained, the system’s closed loop step response reaches
steady state more quickly, except in the case of controller 2, where the design
specification led to the settling time being higher than the uncompensated
system.
62
From the Bode plot of controller 1, we can see that the design specification of
phase margin has been met, thus, the controller is functioning properly.
From the root locus plots of the compensated and uncompensated systems,
we can see that the addition of the poles/zeros by the controller pulls the root
locus towards the left so that it can accommodate the necessary gains.
The step responses inform us about the closed loop performance of the
system. The primary goal of any system is to obtain the desired response, i.e.,
the input. More the system is close to the input, more closed loop stable it is.
RESULT:
Thus, the PI and PID controllers were designed and their corresponding closed
loop performance was analyzed.
63
APPARATUS:
1. MATLAB R2021
FORMULA/THEORY:
Discretization is the process of transferring continuous functions, models,
variables, and equations into discrete counterparts. This process is usually
carried out as a first step toward making them suitable for numerical
evaluation and implementation on digital computers. It must be made clear
that, while discretizing a system, information/data is always lost. Thus,
depending on the necessities, there can be different methods of discretizing a
system.
64
QUESTIONS:
Q1. Determine the z-domain transfer function for the following s-domain transfer
function.
Discretize the given continuous system and study the effect of sampling.
PROCEDURE:
Conversion to s-domain:
Step 1: Take Inverse Laplace transform of H(s)
MATLAB CODE:
>> a = 2;
>> e = 2.71;
>> i = 1;
>> t = 0.3;
>> s = tf('s');
>> z = tf('z');
>> h = a/(s+a)^2;
>> disp("The s-domain transfer function converted to s-domain is: ")
>> sys = c2d(h, 1, 'impulse')
>> step(h)
>> hold on
>> while(a<=6)
>> figure(i+1)
>> h = a/(s+a)^2;
>> f=(a*t*z*e^(a*t))/((z*e^(a*t)-1)^2);
>> step(h)
>> hold on
>> step(f)
>> legend(strcat('continuous: a=',num2str(Ar(i))), strcat('discrete:
a=',num2str(Ar(i))))
>> i = i+1;
>> a= a+2;
66
>> end
OBSERVATION:
𝑃𝑙𝑜𝑡 2: 𝑎 = 2, 𝑇𝑠 = 1
67
𝑃𝑙𝑜𝑡 3: 𝑎 = 4, 𝑇𝑠 = 1
𝑃𝑙𝑜𝑡 4: 𝑎 = 6, 𝑇𝑠 = 1
68
INFERENCE:
If the signal is slowly varying, then fewer samples per second will be required
than if the waveform is rapidly varying.
The major drawback of random undersampling is that this method can
discard potentially useful data that could be important for the induction
process.
It can be seen that undersampling causes poor resolution and the step
response is not smooth as well.
As the sampling time increases the resolution gets clearer. This is because of
Oversampling. It can be inferred that oversampling helps in improving the
resolution and also data is not discarded
From the above it can be inferred that:
1. Oversampling methods duplicate or create new synthetic examples in the
minority class.
2. Undersampling methods delete or merge examples in the majority class.
As the ‘a’ in the equation increases, the resolution increases in the step response
of the z domain
RESULT:
Thus, the given continuous system (in the form of transfer function) was
converted to z- domain and was discretized. The effect of sampling was studied
using the step response plots.
69
APPARATUS:
1. MATLAB R2021
FORMULA/THEORY:
Controllability deals with the possibility of forcing the system to a particular state
by application of a control input. More formally, if a state is controllable, it means
that there exist some control signals that allow the system to reach any state in a
finite amount of time. It is also known as reach ability. If a state is uncontrollable,
then no input will be able to control that state.
On the other hand, whether the initial states can be observed from the output
or not is determined using observability property. If all states of a system can
be known from the system output, then the system is observable.
70
Controllability:
The state equation (or the pair (A, B)) is said to be completely state
controllable or simply state controllable if for any initial state x(0) and any
final state x(N), there exists an input sequence u(k), k = 0, 1, 2, · · · , N, which
transfers x(0) to x(N) for some finite N. Otherwise the state equation is state
uncontrollable.
1. The state equation (1) or the pair (A, B) is state controllable if and
only if the n × np state controllability matrix has rank n, i.e., full row
rank.
The state controllability matrix is given as follows:
𝑈𝑐 = [𝐵 𝐴𝐵 𝐴2𝐵 … … … 𝐴𝑛−1 𝐵]
The full rank condition can also be stated as follows: If the
determinant of the the controllability matrix is zero, then the matrix
is full rank.
Observability:
The state model (or the pair (A, C) ) is said to be observable if any initial state x(0)
can be uniquely determined from the knowledge of output y(k) and input
sequence u(k), for k = 0, 1, 2, · · · , N, where N is some finite time. Otherwise, the
state model is unobservable.
71
QUESTIONS:
Q1. Test the controllability and observability of the given system in both continuous
and discrete domain.
Given characteristic equation: 5𝑧2 − 2𝑧 + 2 = 0
PROCEDURE:
Finding the transfer function:
We know that any transfer function is of the form:
Thus,
The transfer function in z-domain is:
MATLAB CODE:
H=tf([5,-2,1],[5,-2,2],0.1)
[b1 a1] = tfdata(H, 'v');
[A1,B1,C1,D1]=tf2ss(a1,b1);
g1=rank(ctrb(A1,B1));
g2=rank(obsv(A1,C1));
n = size(A1, 1);
if (g1==n || g2==n)
disp('Given system is both fully controllable and observable')
elseif (g1==n)
disp('Given system is fully controllable only')
elseif (g2==n)
disp('Given system is fully observable only')
else
disp('Given system is neither fully controllable nor observable')
end
fprintf('\n')
disp('To check controllability and obsevability in s-domain')
73
if (f1==n || f2==n)
disp('Given system is both fully controllable and observable')
elseif (f1==n)
disp('Given system is fully controllable only')
elseif (f2==n)
disp('Given system is fully observable only')
else
disp('Given system is neither fully controllable nor observable')
end
OBSERVATION:
74
INFERENCE:
RESULT:
Thus, the given system was tested for controllability and observability in both s
and z domain.
75
APPARATUS:
1. MATLAB R2021
2. Simulink -
FORMULA/THEORY:
The state of a system is a minimal set of variables such that the knowledge of
these variables at a particular time t0, with the knowledge of the input(s) to the
system for t>t0, can completely determine the behavior of the system. The state
space approach is a method for modelling, analyzing, and designing a wide range
of both linear and non-linear systems. State space models use state variables to
describe a system by a set of first order differential equations.
A system is represented in state space by the following equations:
76
Question:
A single input system is described by the following equations:
Design a state feedback controller which will give closed loop poles at -1±j2, -6.
From the question, we can see that the given system will have 3 state variables. The
gain matrix ‘K’ can be found easily, as the closed loop poles, i.e., eigenvalues of the
matrix (A – BK) is given. An additional block ‘Kr’ can be added in cascade with the
reference input ‘r’ so that the steady state error of the total controlled system goes to
zero.
Code:
>> sys=ss(A,B,C,D);
>> disp(eig(sys));
>> dp1=complex(-1,2);
77
>> dp2=complex(-1,-2);
>> dp3=-6;
>> dp=[dp1,dp2,dp3];
>> %Calculating Gain K
>> gainK=place(A,B,dp);
>> sys_new=ss(A-B*gainK,B,C,D);
>> Kr = 1/dcgain(sys_new);
>> sys_new1=ss(A-B*gainK,B*Kr,C,D);
>> disp(eig(sys_new));
>> step(sys)
>> hold on
>> step(sys_new1)
>> hold on
>> plot(out.tout, out.Output, 'r')
>> legend('Without feedback','With state feedback');
Explanation:
1. Simulink Diagram:
OBSERVATION:
79
TABULATION:
INFERENCE:
The state feedback will work only for fully controllable systems. This is
because all the states of the system are fed back to the reference input,
and if the system is not controllable, then this feedback won’t properly
function.
From the step response plot for state feedback, the step response for the
uncontrolled system has a higher rise time and has a negative steady-state
error, i.e., the output is higher than the value of the step input. Whereas,
with the state feedback, the rise time & settling time gets reduced, the
steady state error also goes to zero (This is due to the corrective gain term
Kr).
Only one integrator is used in the Simulink model because all the gain
terms are modelled as Matrix K*u, so that the output can be
demultiplexed to obtain the different states.
The method of pole placement is basically an upgraded version of the root locus
compensator design. In root locus, we have one gain that we can alter (i.e., ‘K’),
and we can move the positions of the poles only along the root locus. But here,
we have a gain matrix K and we have the entire s-plane to place our poles.
80
RESULT:
Thus, the state feedback controller was designed accordingly, and their closed
loop performance was analyzed.
81
APPARATUS:
1. MATLAB R2021
2. Simulink -
82
Substituting for the above equation from the previous equations, we get:
This above equation means that, we choose the feedback gain matrix ‘L’
such that our system equation (A - LC) becomes stable, so that e(t) goes
to zero and the approximation is accurate.
The quicker the approximation, better the observer system is. So,
based on the value of the gain matrix L, we will get quicker or slower
approximations. The process described above is same as the process
adopted for the state feedback controller design. So, it can be said
that both problems are mathematically the same. This property is
called duality.
Question:
84
From the question, the given system will have 2 state variables.
1. Code:
>> sys=ss(a,b,c,d);
>> eig(sys);
>> rank(obsv(sys));
Explanation:
2. Simulink Diagram:
86
Q1.
INFERENCE:
From the Simulink plots of the state observer, we can see that the
observer estimatesthe states of the given system perfectly, and that is
exactly the job of an observer system; to estimate the unmeasurable
states of a given system.
Plots 2 and 4 show the error signal between the original plant and the
observer system. It decays to zero within 2 seconds. This means that it is a
particularly good approximation, and the placement of poles/eigenvalues
is good.
Plots 1 and 3 show the actual states of the system, and the states which
the observer estimates. As we have taken the plant with initial conditions,
the states of the plant decay to zero from that initial condition. Here too,
we can see that the observer startsto follow the state of the system very
quicky (2-3 seconds). So, the observer is tracking the states of the system
perfectly.
Plot 5 shows the output of the plant and output of the observer. Similar to
89
the statesplot, the observer quickly starts following the output of the
system y(t).
From the Simulink model, the difference between the outputs of theplant
and observer system is fed back to the observer via a gain matrix ‘L’. This
process continuously refines the error until it becomes zero, i.e., the
observer properlyestimates the states/output of the given system/plant.
RESULT:
Thus, the state observer was designed accordingly, and their closed loop
performance was analyzed.