C&i Lab Final Eee
C&i Lab Final Eee
LAB MANUAL
Prepared by Verified By
D.Kalaiselvi/AP/EEE HOD/EEE
EE3512 CONTROL AND INSTRUMENTATION LABORATORY
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.
Expt. No:1 Date:
APPARATU REQUIRED
1. A PC with MATLAB package.
PROCEDURE
Open the MATLAB software using a MATLAB icon Open a blank M- File or
theoretical value
3.5
2.5
Amplitude
2
1.5
0.5
0
0 0.5 1 1.5 2 2.5 3
Time (sec)
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)
Simulink Model
1. Step Input Close Loop –I Order
Step Response
0.7
0.6
0.5
0.4
Amplitude
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (sec)
Impulse Response
4
3.5
2.5
Amplitude
1.5
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time (sec)
Step Response
0.35
0.3
0.25
0.2
Amplitude
0.15
0.1
0.05
0
0 2 2.5
Time (sec)
Impulse Response
0.45
0.4
0.35
0.3
0.25
Amplitude
0.2
0.15
0.1
0.05
-0.05
0 0.5 1 1.5 2 2.5 3
Time (sec)
Close Loop Response
1. Step Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
step(sys)
2. Impulse Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
sys=feedback(sys,1,-1) ;
Step Response
0.25
0.2
0.15
Amplitude
0.1
0.05
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8
Time (sec)
2. Impulse Input Close Loop –II Order
Impulse Response
0.45
0.4
0.35
0.3
0.25
Amplitude
0.2
0.15
0.1
0.05
-0.05
0 0.5 1 1.5 2 2.5
Time (sec)
RESULT
Thus the digital simulation of time response characteristics of a first and second order linear system with
step and impulse inputs were simulated using MATLAB and outputs are observed for respective inputs.
Expt. No:2 Date:
APPARATU REQUIRED
1. A PC with MATLAB package.
THEORY
An ordinary differential equation (ODE) is an equation that involves derivatives of an unknown function.
Ordinary differential equations are used to model changeover a single independent variable (it is usually
t for time). These equations do not involve any partial derivatives. Differential equations contain three
types of variables: an independent variable, at least one dependent variable (these will be functions of
the independent variable), and the parameters. ODE’s can contain multiple iterations of derivatives and
are named accordingly (i.e. if there are only first derivatives, then the ODE is called a first order ODE).
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:
syms p(t) m(t) l(t) T Y
Eqns = [diff(p(t),t) == (3*p(t)*(1-p(t)))-(30*(p(t)*m(t))); diff(m(t),t) == ((25*p(t)+l(t))*m(t)*(1-m(t)))-
m(t); diff(l(t),t) == (15*(1+tanh(2*m(t)-2)))-l(t)]
[DEsys,Subs] = odeToVectorField(Eqns);
DEFcn = matlabFunction(DEsys, 'Vars',{T,Y});
tspan = [0,25];
y0 = [0.01 0.05 0.539];
[T,Y] = ode45(DEFcn, tspan, y0);
figure(1)
plot(T,Y)
legend('p(t)','m(t)','l(t)')
grid
OUTPUT
dy = -2*y + (t>=0)-(t>=1);
t= [0 5];
inity=0;
[t,y]=ode45(@f, t, inity);
plot(t,y)
RESULT
Thus the digital simulation of time response characteristics of a nonlinear differential equations were
simulated using MATLAB and outputs are observed for respective inputs.
Expt. No:3 Date:
APPARATU REQUIRED
1. A PC with MATLAB package.
THEORY
This describes the use of MATLAB to solve differential equations. Two methods are described. The first
uses one of the differential equation solvers that can be called from the command line. The second uses
Simulink to model and solve a differential equation. Solving First Order Differential Equations with
ode45 The MATLAB commands ode 23 and ode 45 are functions for the numerical solution of ordinary
differential equations.
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
In this example we will solve the first order differential equation: dy/dt + 2y = 3u(t)
Graph
RESULT
Thus the digital simulation of time response characteristics of a real time differential equations were
simulated using MATLAB and outputs are observed for respective inputs.
Expt. No:4 Date:
APPARATUS REQUIRED:
S.no Software
1. MATLAB
2. Simulink
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
OUTPUT:
RESULT:
Thus, the mathematical model of the linear mechanical system was simulated, and the corresponding
parameters were noted.
b. ELECTRICAL SYSTEM
AIM
To design and simulate a mathematical model for a series RLC electrical circuit and
analyze the response graph.
APPARATUS
S.no Software
1. MATLAB
2. Simulink
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
>>R=3;
>>L=1;
>>C=0.05;
>>num=[1./L];
>>den=[1 (R/L) 1./(L*C) ];
>>G=tf(num,den);
>>step(G);
OBSERVATIONS:
1. MATLAB code:
2. Simulink:
MEASUREMENTS VALUES
30.921%
Overshoot
0.658%
Pre shoot
9.302%
Undershoot
317.030 ms
Rise Time
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.
Expt. No: 5 Date:
AIM:
To identify the given system using the process reaction curve using Simulink.
APPARATUS:
S.no Software
1. MATLAB
2. Simulink
Consider a first-order system with time delay described by the following transfer function:
PROGRAM
% Simulate and measure the output response of the system to a step input
% Replace 'input_signal' and 'output_response' with actual data from the experiment
figure;
xlabel('Time (s)');
ylabel('Output Response');
title('Process Reaction Curve');
grid on;
% Replace this part with your actual curve -fitting or optimization method
% For example, you can use 'lsqcurvefit', 'fminsearch', or other fitting techniques
K_estimated = params_fit(1);
L_estimated = params_fit(2);
T_estimated = params_fit(3);
disp('Estimated Parameters:');
RESULT:
Thus, using Simulink, it was possible to obtain the process reaction curves of thegiven
process. The parameters were obtained from the graph and additional values were
calculated as well. Thus, the resultant equations of the processes were modelled from
these values as well.
Expt. No: 6 Date:
To analyze the stability of the following Transfer function, Using Routh Hurwitz
PROCEDURE
1. Open the mat lab command window from the start up or from the short cut
2. Type edit to open the tool box
3. Create the new file
4. Write the program file
5. Save the program and run it
6. Observe the wave form and verify the output with the theoretical values
G(s) = (s + 2) / (s^2 + 3s + 2)
PROGRAM
OUTPUT
RESULT
Thus the pole zero maps and Routh Hurwitz Criterion was analyzed using MATLAB software.
Expt. No: 7 Date:
AIM
To Check the stability analysis of the given system or transfer function using
MATLAB Software.
APPARATUS REQUIRED
PROCEDURE
Open the MATLAB software using a MATLAB icon Open a blank M- File or
theoretical value.
PROGRAM
OUTPUT
RESULT
Thus the designs of root locus for the given transfer function using MATLAB Software was
executed.
Expt. No: 8 Date:
AIM :
Design the bode plot for the given system and also determine the gain and phase
margin using MATLAB Software.
APPARATUS REQUIRED
A PC with MATLAB package
PROCEDURE
Open the MATLAB software using a MATLAB icon Open a blank M- File or
OUTPUT
RESULT
Thus the design of bode plot for the given system using MATLAB Software was executed.
32
1. MATLAB R2021
grid on;
OUTPUT
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.
34
APPARATUS:
S.no Software
1. MATLAB
PROGRAM
PID CONTROLLER
% Create the closed-loop system by connecting the PID controller to the plant
closed_loop_system = feedback(pid_controller * plant_tf, 1);
RESULTS
>> Untitled115
Closed-Loop Performance Metrics:
Rise Time: 4.1957
Settling Time: 6.5119
Overshoot: 0.088029
OUTPUT
RESULT:
Thus, the PID controllers were designed and their corresponding closed loop
performance was analyzed.
36
AIM
To discretize the given continuous system and analyze the effect sampling
usingMATLAB.
APPARATUS:
S.no Software
1. MATLAB
FORMULA/THEORY:
where:
𝑥∗(𝑡) − 𝑠𝑎𝑚𝑝𝑙𝑒𝑑 𝑠𝑖𝑔𝑛𝑎𝑙
𝑇 − 𝑠𝑎𝑚𝑝𝑙𝑖𝑛𝑔 𝑡𝑖𝑚𝑒
Q1. Determine the z-domain transfer function for the following s-domain
transferfunction.
Discretize the given continuous system and study the effect of sampling.
38
PROGRAM
t_discrete = 0:Ts:5;
discrete_response = step(discrete_sys_tf, t_discrete);
stem(t_discrete, discrete_response, 'r', 'LineWidth', 1.5);
title(['Discrete System Response (Ts = ', num2str(Ts), 's)']);
xlabel('Time (s)');
ylabel('System Response');
grid on;
end
40
OUTPUT
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 studiedusing the step
response plots.
Expt. No: 12 Date:
AIM
To test the controllability and observability of a given system in both s and
zdomain using MATLAB.
APPARATUS:
S.no Software
1. MATLAB
FORMULA/THEORY:
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, whichtransfers x(0) to x(N) for some finite N. Otherwise
the state equation is stateuncontrollable.
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 rowrank. 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
matrixis full rank.
MATLAB CODE:
RESULTS
Continuous System:
Controllable: 1
Observable: 1
Discrete System:
Controllable: 1
RESULT
Thus the testing of controllability and observability for a given system in both s
and z domain using MATLAB simulated successfully.
AIM
To design a full state feedback controller for the given systems described using
state-space and evaluate their closed-loop performance.
APPARATUS:
S.no Software
1. MATLAB
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 rangeof 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:
Where:
𝑥(𝑡): 𝑠𝑡𝑎𝑡𝑒 𝑣𝑒𝑐𝑡𝑜𝑟
𝑢(𝑡): 𝑖𝑛𝑝𝑢𝑡/𝑐𝑜𝑛𝑡𝑟𝑜𝑙 𝑣𝑒𝑐𝑡𝑜𝑟
𝑥(𝑡): 𝑜𝑢𝑡𝑝𝑢𝑡 𝑣𝑒𝑐𝑡𝑜𝑟
A: 𝑆𝑦𝑠𝑡𝑒𝑚 𝑚𝑎𝑡𝑟𝑖𝑥 𝑡ℎ𝑎𝑡 𝑟𝑒𝑙𝑎𝑡𝑒𝑠 ℎ𝑜𝑤 𝑡ℎ𝑒 𝑐𝑢𝑟𝑟𝑒𝑛𝑡 𝑠𝑡𝑎𝑡𝑒 𝑎𝑓𝑓𝑒𝑐𝑡𝑠 𝑡ℎ𝑒 𝑠𝑡𝑎𝑡𝑒
𝑐ℎ𝑎𝑛𝑔𝑒
B: 𝐼𝑛𝑝𝑢𝑡 𝑜𝑟 𝑐𝑜𝑛𝑡𝑟𝑜𝑙 𝑚𝑎𝑡𝑟𝑖𝑥 − 𝑑𝑒𝑡𝑒𝑟𝑚𝑖𝑛𝑒𝑠 ℎ𝑜𝑤 𝑖𝑛𝑝𝑢𝑡 𝑎𝑓𝑓𝑒𝑐𝑡𝑠 𝑠𝑦𝑠𝑡𝑒𝑚
𝑐ℎ𝑎𝑛𝑔𝑒
PROGRAM
% Define the continuous-time system matrices (A, B, C, D)
A_continuous = [1, 2; 3, 4];
B_continuous = [1; 1];
C_continuous = [1, 0];
D_continuous = 0;
% Design the state feedback gain matrix K using pole placement method
desired_poles = [-1, -2]; % Choose desired closed-loop poles
K = place(A_continuous, B_continuous, desired_poles);
% Design the state observer gain matrix L using pole placement method
observer_poles = [-5, -6]; % Choose observer poles
L = place(A_continuous', C_continuous', observer_poles)';
% Create the closed-loop system with state feedback and state observer
A_closed_loop = A_continuous - B_continuous * K - L * C_continuous;
B_closed_loop = L;
C_closed_loop = eye(2); % Output all states for evaluation
D_closed_loop = 0;
closed_loop_sys = ss(A_closed_loop, B_closed_loop, C_closed_loop, D_closed_loop);
OUTPUT
RESULT:
Thus, the state feedback controller was designed accordingly, and their closed loop
performance was analyzed.
Expt. No: 14 Date:
Mini Project 1
AIM
To perform the Simulation of complete closed loop control systems including
sensor and actuator.
APPARATUS:
S.no Software
1. MATLAB
2. Simulink
Program
% Plant parameters
Kp = 1; % Proportional gain
Ti = 1; % Integral time constant
Td = 0.2; % Derivative time constant
OUTPUT
RESULT
Thus the Simulation of complete closed loop control systems including sensor
and actuator was simulated successfully.
Expt. No: 15 Date:
Mini Project 2
AIM
To perform the Demonstration of a closed loop system in hardware.
APPARATUS:
S.no Software
1. MATLAB
2. Simulink
Step 1: Define the System and Design the Control Algorithm First, define the
system you want to control and design the appropriate control algorithm (e.g.,
PID controller). This can be a motor, temperature control system, or any other
physical system you want to control.
Step 2: Select the Hardware Choose the appropriate hardware to interface with
MATLAB and implement the control algorithm. Depending on your system,
you may need microcontrollers, sensors, actuators, and any other necessary
components.
Step 5: Run the Demonstration Execute the MATLAB code to run the closed -
loop control system. Monitor the system's behavior through real -time data
acquisition and observe how the controller adjusts the system's output based on
the feedback.
It's important to ensure safety measures when interfacing hardware with
MATLAB. Test your system carefully and avoid situations that could lead to
damage or harm.
Please note that the specifics of hardware interfacing may vary depending on
the hardware components you use and your specific project requirements.
Always refer to the documentation of the hardware and MATLAB support
packages for guidance.