[go: up one dir, main page]

0% found this document useful (0 votes)
47 views50 pages

C&i Lab Final Eee

Uploaded by

skvj0211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views50 pages

C&i Lab Final Eee

Uploaded by

skvj0211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

MANGAYARKARASI COLLEGE OF ENGINEERING

(Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai)


MANGAYARKARASI NAGAR, PARAVAI, MADURAI – 625 402
Website: http://mce-madurai.ac.in E-Mail: : mangai.enggcoll@gmail.com

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING


EE3512 CONTROL AND INSTRUMENTATION LABORATORY
(Regulation 2021)

LAB MANUAL

V SEMESTER / III YEAR

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:

ANALOG (OP-AMP BASED) SIMULATION OF LINEAR DIFFERENTIAL EQUATION


AIM
To digitally simulate the characteristics of Linear SISO systems using state variable formulation.

APPARATU REQUIRED
1. A PC with MATLAB package.

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

Impulse Input Open Loop –I Order


Impulse Response
4

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)

2. Impulse Input Close Loop –I Order

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)

Second Order System


TF= 4/s2+6s+16
1. Open Loop Response of Step Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
step(sys)
2. Open Loop Response of impulse Input
n=[4];
d=[1 6 16];
sys=tf(n,d);
impulse(sys)
Simulink Model
Step Input Open Loop –II Order

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 Input Open 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 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:

NUMERICAL SIMULATION OF GIVEN NON-LINEAR DIFFERENTIAL EQUATION


AIM
To digitally simulate the characteristics of Non Linear SISO systems using state variable formulation.

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

First Order Differential Equation


function dy = f(t,y)

dy = -2*y + (t>=0)-(t>=1);

t= [0 5];

inity=0;

[t,y]=ode45(@f, t, inity);
plot(t,y)

Solution of first order differential equation

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:

REAL TIME SIMULATION OF DIFFERENTIAL EQUATIONS


AIM
To digitally simulate the characteristics of real time simulation of differential equation.

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)

% Time span for simulation (0 to 10 seconds)


tspan = [0, 10];
% Initial conditions [position, velocity]
initial_conditions = [1, 0];
% Time step for real-time simulation
time_step = 0.1; % seconds
% Real-time simulation loop
t_current = tspan(1);
y_current = initial_conditions;
while t_current < tspan(2)
% Update the state using numerical integration (Euler's method)
t_next = t_current + time_step;
y_next = y_current + time_step * (-2 * y_current + 3);
% Substitute the differential equation
% Update current time and state for the next iteration
t_current = t_next;
y_current = y_next;
% Visualization (plot position over time)
plot(t_current, y_current(1), 'bo', 'MarkerSize', 8);
xlabel('Time (s)');
ylabel('Position (y)');
title('Real-Time Simulation of Harmonic Oscillator');
grid on;
drawnow;
% Pause for real-time simulation effect
pause(time_step);
end

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:

MATHEMATICAL MODELING AND SIMULATION OF PHYSICAL SYSTEMS


a. Mechanical system
AIM:

To design and simulate a mathematical model for a linear mechanical system.

APPARATUS REQUIRED:

S.no Software

1. MATLAB

2. Simulink

The corresponding differential equations are as


follows: Consider the parameters as given below:
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

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

1. MATLAB initialization parameters and Code:

Parameter initialization in MATLAB:


Parameters:
 R=3 Ohm
 L=1 H
 C= 0.05 F
PROGRAM

>>R=3;

>>L=1;
>>C=0.05;
>>num=[1./L];
>>den=[1 (R/L) 1./(L*C) ];
>>G=tf(num,den);
>>step(G);

>>[w,zeta,p]=damp(G); %damp() gives the frequency


domain parameters
>>tau=1./w; %time constant
2. Simulink model:

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:

SYSTEM IDENTIFICATION THROUGH PROCESS REACTION CURVE

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:

G(s) = K * exp(-Ls) / (Ts + 1)


where: K = system gain L = time delay T = time constant s = Laplace variable

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

input_signal = [0, 1, 1, 1, 1, 1]; % Step input

output_response = [0, 0, 0, 0.5, 0.9, 1]; % Output response over time

% Plot the process reaction curve

figure;

plot(input_signal, output_response, 'o', 'MarkerSize', 8, 'LineWidth', 1.5);

xlabel('Time (s)');

ylabel('Output Response');
title('Process Reaction Curve');

grid on;

% Fit data and estimate parameters (K, L, T)

% Replace this part with your actual curve -fitting or optimization method

% For example, you can use 'lsqcurvefit', 'fminsearch', or other fitting techniques

% Here, we'll use 'polyfit' as a simple example for illustration purposes

% Define the model function

model_func = @(params, t) params(1) * exp(-params(2) * t) ./ (params(3) * t + 1);

% Initial guess for parameters [K, L, T]

initial_guess = [1, 0.5, 1];

% Perform curve fitting

params_fit = lsqcurvefit(model_func, initial_guess, input_signal, output_response);

% Extract estimated parameters

K_estimated = params_fit(1);

L_estimated = params_fit(2);

T_estimated = params_fit(3);

% Display the estimated parameters

disp('Estimated Parameters:');

disp(['K: ', num2str(K_estimated)]);

disp(['L: ', num2str(L_estimated)]);

disp(['T: ', num2str(T_estimated)]);


OUTPUT

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:

STABILITY ANALYSIS USING POLE ZERO MAPS AND ROUTH HURWITZ


CRITERION IN SIMULATION PLATFORM.
AIM

To analyze the stability of the following Transfer function, Using Routh Hurwitz

APPARATUS REQUIRED / INSTRUMENTS REQUIRED

System with MATLAB

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

let’s consider a second-order system with the following transfer function:

G(s) = (s + 2) / (s^2 + 3s + 2)
PROGRAM

numerator = [1, 2]; % Coefficients of the numerator of the transfer function


denominator = [1, 3, 2]; % Coefficients of the denominator of the transfer function
% Create the transfer function model
sys = tf(numerator, denominator);

% Plot the pole-zero map


figure;
pzmap(sys);
title('Pole-Zero Map');
grid on;
% Check stability using the Routh-Hurwitz criterion
rhTable = routh(denominator);
% Count the number of sign changes in the first column of the Routh table
numSignChanges = sum(diff(sign(rhTable(:, 1))) ~= 0);
% Determine stability based on the number of sign changes
if numSignChanges == 0
disp('System is stable (all poles have negative real parts)');
elseif numSignChanges > 0
disp('System is unstable (at least one pole has a positive real part)');
else
disp('System is marginally stable (all poles have non-positive real parts, but there are zeros in
the first column)');
end

OUTPUT

RESULT
Thus the pole zero maps and Routh Hurwitz Criterion was analyzed using MATLAB software.
Expt. No: 7 Date:

ROOT LOCUS BASED ANALYSIS SIMULATION

AIM

To Check the stability analysis of the given system or transfer function 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

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

numerator = [1]; % Coefficients of the numerator of the transfer function


denominator = [1, 3, 2]; % Coefficients of the denominator of the transfer function
% Create the transfer function model
sys = tf(numerator, denominator);
% Plot the root locus
figure;
rlocus(sys);
title('Root Locus Analysis');
grid on;

OUTPUT
RESULT
Thus the designs of root locus for the given transfer function using MATLAB Software was
executed.
Expt. No: 8 Date:

DETERMINATION OF TRANSFER FUNCTION OF A PHYSICAL SYSTEM


USING FREQUENCY RESPONSE AND BODE’S ASYMPTOTES.

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

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
MATLAB CODE:

% Example frequency response data


frequencies = logspace(-1, 2, 100); % Frequency range from 0.1 to 100 rad/s
magnitude = 2./(sqrt(1 + (frequencies/10).^2)); % Magnitude response (example function)
phase = atan(-frequencies/10); % Phase response (example function)
% Plot the Bode diagram
figure;
subplot(2, 1, 1);
semilogx(frequencies, 20*log10(magnitude));
xlabel('Frequency (rad/s)');
ylabel('Magnitude (dB)');
title('Bode Magnitude Plot');
grid on;
subplot(2, 1, 2);
semilogx(frequencies, rad2deg(phase));
xlabel('Frequency (rad/s)');
ylabel('Phase (degrees)');
title('Bode Phase Plot');
grid on;

OUTPUT

RESULT
Thus the design of bode plot for the given system using MATLAB Software was executed.
32

Expt. No: 9 Date:

DESIGN OF LAG, LEAD COMPENSATORS AND EVALUATIONOF


CLOSED LOOP PERFORMANCE
AIM:
To design Lag, lead compensators and evaluation of
closed loop performance for the given system using
MATLAB.
APPARATUS:

S.no Software Version

1. MATLAB R2021

numerator = [1]; % Coefficients of the numerator of the plant transfer function


denominator = [1, 3, 2]; % Coefficients of the denominator of the plant transfer function

% Create the plant transfer function model


plant_tf = tf(numerator, denominator);

% Define the lag compensator


lag_compensator = tf([1, 0.1], [1, 0.01]);

% Compute the compensated transfer function


compensated_tf = plant_tf * lag_compensator;

% Define the lead compensator


lead_compensator = tf([1, 10], [1, 100]);

% Compute the compensated transfer function


compensated_tf = plant_tf * lead_compensator;

% Define the feedback control system


feedback_system = feedback(compensated_tf, 1);

% Plot the step response of the closed-loop system


figure;
step(feedback_system);
title('Step Response of the Closed-Loop System');
33

grid on;

% Evaluate closed-loop performance metrics


info = stepinfo(feedback_system);
disp('Closed-Loop Performance Metrics:');
disp(['Rise Time: ', num2str(info.RiseTime)]);
disp(['Settling Time: ', num2str(info.SettlingTime)]);
disp(['Overshoot: ', num2str(info.Overshoot)]);
disp(['Steady-State Error: ', num2str(info.SteadyStateError)]);

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

Expt. No: 10 Date:

DESIGN OF PID CONTROLLERS AND EVALUATION OFCLOSED LOOP


PERFORMANCE
AIM:
To design PI, and PID controllers and evaluate their closed loop performance.

APPARATUS:

S.no Software

1. MATLAB

PROGRAM

PID CONTROLLER

numerator = [1]; % Coefficients of the numerator of the plant transfer function


denominator = [1, 3, 2]; % Coefficients of the denominator of the plant transfer function

% Define PID controller parameters


Kp = 1.2; % Proportional gain
Ki = 1.0; % Integral gain
Kd = 0.5; % Derivative gain
% Create the PID controller
pid_controller = pid(Kp, Ki, Kd);

% Create the closed-loop system by connecting the PID controller to the plant
closed_loop_system = feedback(pid_controller * plant_tf, 1);

% Plot the step response of the closed-loop system


figure;
step(closed_loop_system);
title('Step Response of the Closed-Loop System with PID Controller');
grid on;

% Evaluate closed-loop performance metrics


info = stepinfo(closed_loop_system);
disp('Closed-Loop Performance Metrics:');
disp(['Rise Time: ', num2str(info.RiseTime)]);
disp(['Settling Time: ', num2str(info.SettlingTime)]);
disp(['Overshoot: ', num2str(info.Overshoot)]);
35

disp(['Steady-State Error: ', num2str(info.SteadyStateError)]);

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

Expt. No: 11 Date:

DISCRETIZATION OF A CONTIN UOUS SYSTEM AND THE


EFFECT OF SAMPLING

AIM
To discretize the given continuous system and analyze the effect sampling
usingMATLAB.

APPARATUS:

S.no Software

1. MATLAB

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 asystem.
Theoretical Method:
The theoretical way of discretizing a system is by:
1. Converting given s-domain transfer function to time domain

2. Sampling the obtained time domain response

3. Taking z-transform of the sampled response to obtain the


z-domain transfer function.

This method is commonly known as the impulse invariant method because,


theimpulse response of both the continuous system and the discrete system will
remain the same. (The discrete time impulse response being the sampled
continuous time impulse response).
37

Let a unit impulse train be defined as follows:

If a continuous-time signal x(t) is sampled in a periodic manner,


mathematically,the sampled signal can be represented as follows:

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

% Define the continuous system transfer function


numerator = [1]; % Coefficients of the numerator of the continuous system
denominator = [1, 3, 2]; % Coefficients of the denominator of the continuous system

% Create the continuous system transfer function model


continuous_sys_tf = tf(numerator, denominator);

% Define the sampling time (Ts)


Ts = 0.1; % Choose an appropriate sampling time

% Discretize the continuous system using Zero-Order Hold (ZOH) method


discrete_sys_tf = c2d(continuous_sys_tf, Ts, 'zoh');

% Create a time vector for simulation


t_continuous = 0:0.001:5; % Time vector for continuous system simulation
t_discrete = 0:Ts:5; % Time vector for discrete system simulation

% Simulate the continuous and discrete systems


continuous_response = step(continuous_sys_tf, t_continuous);
discrete_response = step(discrete_sys_tf, t_discrete);
% Plot the responses of the continuous and discrete systems
figure;
plot(t_continuous, continuous_response, 'b', 'LineWidth', 1.5);
hold on;
stem(t_discrete, discrete_response, 'r', 'LineWidth', 1.5);
hold off;
xlabel('Time (s)');
ylabel('System Response');
title('Continuous and Discrete System Responses');
legend('Continuous System', 'Discrete System');
grid on;

% Different sampling times to test


sampling_times = [0.01, 0.1, 0.5, 1]; % Change the sampling times as required

% Create a subplot for each sampling time


figure;
for i = 1:length(sampling_times)
subplot(length(sampling_times), 1, i);
Ts = sampling_times(i);
discrete_sys_tf = c2d(continuous_sys_tf, Ts, 'zoh');
39

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:

TEST OF OBSERVABILITY AND CONTROLLABILITY IN CONTINUOUS


AND DISCRETE DOMAIN IN SIMULATION PLATFORM

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:

Controllability and observability are two important properties of state


models which are integral to the designing of a controller. These two
properties suggestwhat modifications should be made to the plant
(actuators and sensors) so thatthe desired action is achieved.

Controllability deals with the possibility of forcing the system to a


particular stateby application of a control input. More formally, if a state is
controllable, it meansthat there exist some control signals that allow the
system to reach any state in afinite amount of time. It is also known as
reachability. 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
outputor not is determined using observability property. If all states of a
system can be known from the system output, then the system is
observable.

It is impractical to know all the states of a system. So, sometimes it is


limited tothe critical states. Thus, if a state is not observable then the
controller will not be able to determine its behavior from the system output
and hence not be able to use that state to stabilize the system.
Controllability and observability work together, as stated in a further theorem.
Controllability:

Consider a dynamic system as follows:

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.

2. When the matrix ‘A’ has distinct eigenvalues and in


Jordan/Diagonal canonical form, the state model is
controllable if and only if all the rowsof matrix ‘B’ are non-
zero.

MATLAB CODE:

% Define the continuous system matrices (A, B, C, D)


A_continuous = [1, 2; 3, 4];
B_continuous = [1; 1];
C_continuous = [1, 0];
D_continuous = 0;

% Create the continuous system state-space model


continuous_sys = ss(A_continuous, B_continuous, C_continuous, D_continuous);

% Define the sampling time (Ts)


Ts = 0.1; % Choose an appropriate sampling time

% Discretize the continuous system using Zero-Order Hold (ZOH) method


discrete_sys = c2d(continuous_sys, Ts, 'zoh');

% Test controllability and observability for the continuous system


controllable_continuous = ctrb(continuous_sys);
observable_continuous = obsv(continuous_sys);

% Test controllability and observability for the discrete system


controllable_discrete = ctrb(discrete_sys);
observable_discrete = obsv(discrete_sys);

% Check the ranks of the controllability and observability matrices


is_continuous_controllable = rank(controllable_continuous) == size(A_continuous, 1);
is_continuous_observable = rank(observable_continuous) == size(A_continuous, 1);

is_discrete_controllable = rank(controllable_discrete) == size(A_continuous, 1);


is_discrete_observable = rank(observable_discrete) == size(A_continuous, 1);

% Display the results


disp('Continuous System:');
disp(['Controllable: ', num2str(is_continuous_controllable)]);
disp(['Observable: ', num2str(is_continuous_observable)]);
disp('Discrete System:');
disp(['Controllable: ', num2str(is_discrete_controllable)]);
disp(['Observable: ', num2str(is_discrete_observable)]);

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.

Expt. No: 13 Date:

DESIGN OF STATE FEEDBACK CONTROLLER


ANDEVALUATION OF CLOSED LOOP
PERFORMANCE

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: 𝐼𝑛𝑝𝑢𝑡 𝑜𝑟 𝑐𝑜𝑛𝑡𝑟𝑜𝑙 𝑚𝑎𝑡𝑟𝑖𝑥 − 𝑑𝑒𝑡𝑒𝑟𝑚𝑖𝑛𝑒𝑠 ℎ𝑜𝑤 𝑖𝑛𝑝𝑢𝑡 𝑎𝑓𝑓𝑒𝑐𝑡𝑠 𝑠𝑦𝑠𝑡𝑒𝑚
𝑐ℎ𝑎𝑛𝑔𝑒

C: 𝐷𝑒𝑡𝑒𝑟𝑚𝑖𝑛𝑒𝑠 𝑡ℎ𝑒 𝑟𝑒𝑙𝑎𝑡𝑖𝑜𝑛𝑠ℎ𝑖𝑝 𝑏𝑒𝑡𝑤𝑒𝑒𝑛 𝑡ℎ𝑒 𝑠𝑦𝑠𝑡𝑒𝑚 𝑠𝑡𝑎𝑡𝑒𝑠 𝑎𝑛𝑑 𝑡ℎ𝑒


𝑠𝑦𝑠𝑡𝑒𝑚
𝑜𝑢𝑡𝑝𝑢𝑡
D: 𝐴𝑙𝑙𝑜𝑤𝑠 𝑖𝑛𝑝𝑢𝑡 𝑡𝑜 𝑑𝑖𝑟𝑒𝑐𝑡𝑙𝑦 𝑎𝑓𝑓𝑒𝑐𝑡 𝑡ℎ𝑒 𝑠𝑦𝑠𝑡𝑒𝑚 𝑜𝑢𝑡𝑝𝑢𝑡

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;

% Create the continuous-time system state-space model


continuous_sys = ss(A_continuous, B_continuous, C_continuous, D_continuous);

% 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);

% Simulate the step response of the closed-loop system


t = 0:0.01:5; % Time vector for simulation
x0 = [0; 0]; % Initial state vector
[y, t_sim, x] = initial(closed_loop_sys, x0, t);

% Plot the response of the closed-loop system


figure;
subplot(2, 1, 1);
plot(t_sim, y);
title('Step Response of the Closed-Loop System');
xlabel('Time (s)');
ylabel('Output y(t)');
grid on;
subplot(2, 1, 2);
plot(t_sim, x);
title('State Evolution in Closed-Loop System');
xlabel('Time (s)');
ylabel('State Variables');
legend('x1', 'x2');
grid on;

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

% Plant transfer function


numerator = [Kp * Ti * Td, Kp];
denominator = [Ti, 0];
plant_tf = tf(numerator, denominator);

% PID controller transfer function


pid_controller = pid(Kp, Ti, Td);

% Create the closed-loop system


closed_loop_sys = feedback(pid_controller * plant_tf, 1);

% Sensor transfer function


sensor_tf = tf(1, 1);

% Actuator transfer function


actuator_tf = tf(1, [0.1, 1]);

% Create the complete closed-loop system


complete_closed_loop_sys = sensor_tf * closed_loop_sys * actuator_tf;

% Simulate the step response of the complete closed-loop system


t = 0:0.01:10; % Time vector for simulation
reference = ones(size(t)); % Step reference signal
[y, t_sim] = lsim(complete_closed_loop_sys, reference, t);

% Plot the step response


figure;
plot(t_sim, y, 'b', 'LineWidth', 1.5);
xlabel('Time (s)');
ylabel('Output Response');
title('Step Response of the Complete Closed-Loop Control System');
grid on;

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

As an AI language model, I don't have direct access to hardware to demonstrate


projects. However, I can outline the general steps you can follow to
demonstrate a closed-loop control system in hardware using MATLAB and
appropriate hardware interfacing:

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 3: Set up Hardware Interfacing in MATLAB Connect the hardware to your


computer and set up the necessary interfacing in MATLAB. MATLAB supports
various hardware platforms, and you may need to install relevant support
packages or use Arduino or Raspberry Pi support.

Step 4: Implement the Control Algorithm in MATLAB Write MATLAB code to


implement the control algorithm based on the system's feedback. Use the
hardware interfacing capabilities to read sensor data and send control signals to
actuators.

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.

You might also like