0% found this document useful (0 votes)
31 views32 pages

Seventh-Semester Submitted By: Ritik Raj (102104010) 4ELE1 BE Fourth Year (2021-2025) Electrical Engineering

The document outlines a series of experiments related to IoT and real-time systems, focusing on MATLAB and Simulink applications in electrical engineering. It includes detailed aims, codes, and outputs for various experiments, such as transformations in power systems, fault analysis, and system modeling. The document serves as a practical guide for students to understand and implement key concepts in electrical engineering using simulation tools.

Uploaded by

rjain5be21
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)
31 views32 pages

Seventh-Semester Submitted By: Ritik Raj (102104010) 4ELE1 BE Fourth Year (2021-2025) Electrical Engineering

The document outlines a series of experiments related to IoT and real-time systems, focusing on MATLAB and Simulink applications in electrical engineering. It includes detailed aims, codes, and outputs for various experiments, such as transformations in power systems, fault analysis, and system modeling. The document serves as a practical guide for students to understand and implement key concepts in electrical engineering using simulation tools.

Uploaded by

rjain5be21
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/ 32

IoT and Real Time Systems

(UEE706)
Seventh-Semester

Submitted by:
Ritik Raj [102104010]
4ELE1

BE Fourth Year (2021-2025)


Electrical Engineering

Submitted To:
Dr. S. K. AGGARWAL
ASSOCIATE PROFESSOR

DEPARTMENT OF ELECTRICAL AND INSTRUMENTATION


ENGINEERING
THAPAR INSTITUTE OF ENGINEERING AND TECHNOLOGY,
(A DEEMED TO BE UNIVERSITY), PATIALA, PUNJAB
INDIA
1
INDEX

S.No List of Experiments Date Remarks


1 Introduction to MATLAB and Simulink 07/08/2024

2 Develop the following programs to understand the concept 28/08/2024


of transformations
in power systems:
(i) polar to rectangular and vice versa
(ii) abc to symmetrical components and vice versa
(iii) Park's transformation
(iv) Discrete Fourier Transform

3 (a) Develop a program to simulate and analyse a 04/09/2024


transmission line model in Simulink.
(b) Develop a program for fault analysis in a given power
system using
symmetrical components.

4 Develop programs to create continuous and discrete time 11/09/2024


models.

5 Develop a program to simulate second order engineering 15/10/2024


systems (electrical and mechanical) using a numerical
technique
6 To draw the block diagram model of a two-area power 22/10/2024
system and design
integral and fuzzy controllers for load frequency control.

7 To design PID controller in a process control system 12/11/2024

2
EXPERIMENT: 1

Aim: Introduction to MATLAB and Simulink.

Software Used: MATLAB

Theory:

3
CODE AND OUTPUT:

4
5
6
EXPERIMENT: 2

Aim: Develop the following programs to understand the concept of


transformations in powersystems:

(i) polar to rectangular and vice versa


(ii) abc to symmetrical components and vice versa
(iii) Park’s transformation
(iv) Discrete Fourier Transform

Software used: MATLAB


Theory:

7
(i) Code: Polar to rectangular and vice versa

% Polar to Rectangular
r = 5; % Magnitude (Example)
theta = 30; % Phase in degrees (Example)

theta_rad = deg2rad(theta); % Convert to radians


z_rect = r * (cos(theta_rad) + 1j * sin(theta_rad)); % Rectangular form

disp('Polar to Rectangular:');
disp(['Rectangular form: ', num2str(real(z_rect)), ' + ', num2str(imag(z_rect)), 'j']);

% Rectangular to Polar
a = 3; % Real part (Example)
b = 4; % Imaginary part (Example)

r_polar = sqrt(a^2 + b^2); % Magnitude


theta_polar = rad2deg(atan2(b, a)); % Phase in degrees

disp('Rectangular to Polar:');
disp(['Magnitude: ', num2str(r_polar), ', Phase: ', num2str(theta_polar), ' degrees']);
OUTPUT:

(ii) Code: abc to symmetrical components and vice versa


% ABC to Symmetrical Components

V_a = 10 * exp(1j * deg2rad(30)); % Example phase A

voltage V_b = 10 * exp(1j * deg2rad(150)); % Example


phase B voltageV_c = 10 * exp(1j * deg2rad(-90)); %

Example phase C voltage

% Symmetrical Components

a = exp(1j * 2*pi/3); % Phase shift


operator (a)V0 = (V_a + V_b + V_c) / 3;

V1 = (V_a + a * V_b + a^2 * V_c) / 3; % Positive

sequence V2 = (V_a + a^2 * V_b + a * V_c) / 3; %

Negative sequence

8
disp('Symmetrical Components:');

disp(['V0 (Zero Sequence): ', num2str(abs(V0)), ' ∠ ', num2str(rad2deg(angle(V0))) '°']);

disp(['V1 (Positive Sequence): ', num2str(abs(V1)), ' ∠ ', num2str(rad2deg(angle(V1))) '°']);

disp(['V2 (Negative Sequence): ', num2str(abs(V2)), ' ∠ ', num2str(rad2deg(angle(V2))) '°']);

% Symmetrical Components to ABC

V_a_reconstructed = V0 + V1 + V2;
V_b_reconstructed = V0 + a * V1 + a^2

* V2;V_c_reconstructed = V0 + a^2 *

V1 + a * V2;

disp('Reconstructed ABC:');

disp(['V_a: ',
num2str(abs(V_a_reconstructed)), ' ∠ ',
num2str(rad2deg(angle(V_a_reconstructed)))
'°']);

disp(['V_b: ',
num2str(abs(V_b_reconstructed)), ' ∠ ',
num2str(rad2deg(angle(V_b_reconstructed)))
'°']);

disp(['V_c: ',
num2str(abs(V_c_reconstructed)), ' ∠ ',
num2str(rad2deg(angle(V_c_reconstructed)))
'°']);

OUTPUT:

9
(iii) Code: Park transform

% Define the input voltages in ABC

(Example)V_a = 10 * exp(1j *
deg2rad(30));

V_b = 10 * exp(1j *
deg2rad(150));V_c = 10 *
exp(1j * deg2rad(-90));

% Park's Transformation (abc

to dq0)T_abc_to_dq0 = (2/3) *

1, -0.5, -0.5;
0, sqrt(3)/2, -sqrt(3)/2;
0.5, 0.5, 0.5

];

V_abc = [V_a; V_b; V_c]; % Column vector of ABC

voltagesV_dq0 = T_abc_to_dq0 * [V_abc]; %

Transform to dq0

disp('Park''s Transformation (abc to dq0):');

disp(['V_d: ', num2str(abs(V_dq0(1))), ' ∠ ', num2str(rad2deg(angle(V_dq0(1)))) '°']);

disp(['V_q: ', num2str(abs(V_dq0(2))), ' ∠ ', num2str(rad2deg(angle(V_dq0(2)))) '°']);


disp(['V_0: ', num2str(abs(V_dq0(3))), ' ∠ ', num2str(rad2deg(angle(V_dq0(3)))) '°']);

% Inverse Park's Transformation (dq0


to abc)T_dq0_to_abc = [

1, 0, 0;

-0.5, sqrt(3)/2, 0.5;

-0.5, -sqrt(3)/2, 0.5

10
];

V_abc_reconstructed = T_dq0_to_abc * V_dq0;

disp('Inverse Park''s Transformation (dq0 to abc):');

disp(['V_a: ',
num2str(abs(V_abc_reconstructed(1))), ' ∠ ',
num2str(rad2deg(angle(V_abc_reconstructed(1))))
'°']);

disp(['V_b: ',
num2str(abs(V_abc_reconstructed(2))), ' ∠ ',
num2str(rad2deg(angle(V_abc_reconstructed(2))))
'°']);

disp(['V_c: ',
num2str(abs(V_abc_reconstructed(3))), ' ∠ ',
num2str(rad2deg(angle(V_abc_reconstructed(3))))
'°']);

OUTPUT:

(iv) Code: Discrete fourier transform

% Example Discrete

Signal N = 8; %

Number of samples
x = [1, 2, 3, 4, 5, 6, 7, 8]; % Discrete signal (Example)

11
% Compute the DFT
using FFTX = fft(x, N);

disp('Discrete Fourier Transform


(DFT):');disp('Frequency
Components:');

disp(X);

OUTPUT:

12
EXPERIMENT: 3(a)

Aim: Write a program to simulate and analyze a transmission line model in


simulink
Software Used: Simulink 2023b
Theory:

Simulation

13
Model Components:

 AC voltage source: Provides input power (e.g., 230V, 50Hz).


 Series RLC branch: Represents the transmission line with R, L, & C parameters.
 R-L load: Simulates the load at the end of the transmission line.
 Voltage & current measurement blocks: Measure voltage across the load & current
through the line.
 Scope: Visualizes real-time waveforms of voltage & current.
Simulation Response:
The model aims to analyse voltage drops, current flow, and system performance under
varying conditions. By visualizing these parameters, users can understand the efficiency &
behaviour of power transmission.

14
EXPERIMENT: 3(b)

Aim: Develop a program for fault analysis in a given power system using
symmetricalcomponents.
Software used: MATLAB
Theory:

15
Code:
% Given parameters
V_a = 10 * exp(1j * deg2rad(30)); % Phase A voltage (pre-fault)
V_b = 10 * exp(1j * deg2rad(150)); % Phase B voltage (pre-
fault)V_c = 10 * exp(1j * deg2rad(-90)); % Phase C voltage
(pre-fault)Z_f = 0.01 + 1j * 0.02; % Fault impedance (assumed)

% Symmetrical Components Transformation Matrix (abc to symmetrical


components)a = exp(1j * 2*pi/3); % Phase shift operator (a)

% Create the pre-fault phase voltage


vectorV_abc = [V_a; V_b; V_c];

% Calculate the symmetrical components (V0,


V1, V2)V0 = (V_a + V_b + V_c) / 3;
V1 = (V_a + a * V_b + a^2 * V_c) / 3; % Positive
sequence V2 = (V_a + a^2 * V_b + a * V_c) / 3; %
Negative sequence

disp('Symmetrical Components before fault:');


disp(['V0 (Zero Sequence): ', num2str(abs(V0)), ' ∠ ', num2str(rad2deg(angle(V0))) '°']);
disp(['V1 (Positive Sequence): ', num2str(abs(V1)), ' ∠ ', num2str(rad2deg(angle(V1))) '°']);
disp(['V2 (Negative Sequence): ', num2str(abs(V2)), ' ∠ ', num2str(rad2deg(angle(V2))) '°']);

% Apply Line-to-Ground Fault on phase A (Fault at phase A)


% In this case, we assume fault only on phase A, i.e., V2 and V0 remain unchanged, but V1
isaffected
% We assume fault impedance Zf is connected between phase A and ground.

% Fault current (using the fault


impedance) I_fault = V_a / Z_f; % Fault
current in phase A

% Sequence network analysis:


% The post-fault sequence voltages for the faulted phase (phase A) will be
% affected by the fault impedance. Assuming a line-to-ground fault on phase A,
% the sequence components for phase A after fault are as follows:
% Sequence components after fault (for line-to-ground fault):
% V1' = V1 + (Fault Impedance * I_fault)
% V2' = V2 (negative sequence unchanged)
% V0' = V0 (zero sequence unchanged)

16
V1_fault = V1 + Z_f * I_fault; % Affected positive sequence due
to faultV2_fault = V2; % Negative sequence unaffected
V0_fault = V0; % Zero sequence unaffected

disp('Symmetrical Components after fault (SLG on Phase A):');


disp(['V1 (Positive Sequence) after fault: ',
num2str(abs(V1_fault)), ' ∠ ',num2str(rad2deg(angle(V1_fault)))
'°']);
disp(['V2 (Negative Sequence) after fault: ',
num2str(abs(V2_fault)), ' ∠ ',num2str(rad2deg(angle(V2_fault)))
'°']);
disp(['V0 (Zero Sequence) after fault: ',
num2str(abs(V0_fault)), ' ∠ ',
num2str(rad2deg(angle(V0_fault))) '°']);

% Reconstruct the post-fault voltages in ABC


form V_a_post = V0_fault + V1_fault +
V2_fault; V_b_post = V0_fault + a * V1_fault +
a^2 * V2_fault;V_c_post = V0_fault + a^2 *
V1_fault + a * V2_fault;

disp('Post-fault Phase Voltages (ABC):');


disp(['V_a post-fault: ', num2str(abs(V_a_post)), ' ∠ ',
num2str(rad2deg(angle(V_a_post))) '°']);disp(['V_b post-fault: ',
num2str(abs(V_b_post)), ' ∠ ', num2str(rad2deg(angle(V_b_post))) '°']);disp(['V_c post-
fault: ', num2str(abs(V_c_post)), ' ∠ ', num2str(rad2deg(angle(V_c_post))) '°']);

Output:

17
EXPERIMENT: 4
Aim: Develop programs to create continuous and discrete time models.
Software Used: MATLAB
Theory:

18
Code:
function create_alternate_system_models()
% Define continuous-time state-space system
A = [0 1; -1 -2]; % State matrix
B = [0; 1]; % Input matrix
C = [1 0]; % Output matrix
D = 0; % Feedthrough matrix
% Create continuous-time state-space model
continuous_sys_ss = ss(A, B, C, D);
% Convert state-space to transfer function
continuous_sys_tf = tf(continuous_sys_ss);
% Display continuous-time model
fprintf('Continuous-Time State-Space Model:\n');
disp(continuous_sys_ss);
fprintf('Equivalent Continuous-Time Transfer Function:\n');
disp(continuous_sys_tf);
% Define sampling time for discrete-time model
Ts = 0.1; % Sampling time
% Create discrete-time model from continuous-time state-space
discrete_sys_ss = c2d(continuous_sys_ss, Ts, 'zoh');
% Display discrete-time model
fprintf('Discrete-Time State-Space Model:\n');
disp(discrete_sys_ss);
fprintf('Equivalent Discrete-Time Transfer Function:\n');
disp(tf(discrete_sys_ss));
% Plot the step response for both systems
figure;
subplot(2, 1, 1);
step(continuous_sys_ss);
title('Continuous-Time Step Response');

19
xlabel('Time (s)');
ylabel('Response');
subplot(2, 1, 2);
step(discrete_sys_ss);
title('Discrete-Time Step Response');
xlabel('Time (s)');
ylabel('Response');
end

OUTPUT:

20
EXPERIMENT: 5
Aim: Develop a program to simulate second order engineering systems
(electrical and mechanical) using a numerical technique.
Software Used: MATLAB
Theory:

21
Code:
function simulate_second_order_systems_euler()
% Simulation parameters
tspan = [0 10]; % Time span for the simulation
dt = 0.01; % Time step for numerical integration
time = tspan(1):dt:tspan(2); % Time vector

% System parameters
m = 1; % Mass (for mechanical system, kg)
b = 0.5; % Damping coefficient (for mechanical system, Ns/m)
k = 2; % Spring constant (for mechanical system, N/m)

R = 1; % Resistance (for electrical system, Ohm)


L = 0.5; % Inductance (for electrical system, H)
V = 10; % Input voltage (for electrical system, V)

% Initial conditions
x0_mechanical = [0; 0]; % Initial position and velocity for mechanical system
x0_electrical = [0; 0]; % Initial current and voltage for electrical system

% Simulate mechanical system using Euler's method


[t_mechanical, x_mechanical] = euler_method(@mechanical_system, x0_mechanical,
tspan, dt, m, b, k);

% Simulate electrical system using Euler's method


[t_electrical, x_electrical] = euler_method(@electrical_system, x0_electrical, tspan, dt, R,
L, V);

% Plot results
figure;

22
% Mechanical system results
subplot(2, 1, 1);
plot(t_mechanical, x_mechanical(1, :), 'b', 'LineWidth', 1.5);
grid on;
title('Mechanical System: Mass-Spring-Damper Response');
xlabel('Time (s)');
ylabel('Position (m)');
legend({'Position'}); % Use a cell array for legend

subplot(2, 1, 2);
plot(t_mechanical, x_mechanical(2, :), 'r', 'LineWidth', 1.5);
grid on;
xlabel('Time (s)');
ylabel('Velocity (m/s)');
legend({'Velocity'}); % Use a cell array for legend

% Electrical system results


figure;

subplot(2, 1, 1);
plot(t_electrical, x_electrical(1, :), 'b', 'LineWidth', 1.5);
grid on;
title('Electrical System: RLC Circuit Response');
xlabel('Time (s)');
ylabel('Current (A)');
legend({'Current'}); % Use a cell array for legend

subplot(2, 1, 2);
plot(t_electrical, x_electrical(2, :), 'r', 'LineWidth', 1.5);
grid on;

23
xlabel('Time (s)');
ylabel('Voltage (V)');
legend({'Voltage'}); % Use a cell array for legend
end

function [t, x] = euler_method(system_func, x0, tspan, dt, varargin)


% Euler method for numerical integration
t = tspan(1):dt:tspan(2); % Time vector
x = zeros(length(x0), length(t)); % State variable matrix
x(:, 1) = x0; % Initial condition

for i = 1:length(t)-1
dxdt = system_func(t(i), x(:, i), varargin{:}); % Get the derivatives
x(:, i+1) = x(:, i) + dxdt * dt; % Update state using Euler's method
end
end
function dxdt = mechanical_system(t, x, m, b, k)
% Mechanical system dynamics: mx'' + bx' + kx = 0
dxdt = zeros(2, 1);
dxdt(1) = x(2); % Velocity
dxdt(2) = -(b/m) * x(2) - (k/m) * x(1); % Acceleration
end

function dxdt = electrical_system(t, x, R, L, V)


% Electrical system dynamics: Ldi/dt + Ri + V = 0
dxdt = zeros(2, 1);
dxdt(1) = (V - R*x(1))/L; % Current
dxdt(2) = -x(1); % Voltage across inductor
end

24
OUTPUT:

25
EXPERIMENT: 6
Aim: To draw the block diagram model of a two-area power system and design
integral and fuzzy controllers for load frequency control.
Software Used: MATLAB
Theory:

26
Code:
clc;
clear;
close all;

% System Parameters
M1 = 0.166; % Inertia constant for Area 1
M2 = 0.167; % Inertia constant for Area 2
D1 = 0.008; % Damping coefficient for Area 1
D2 = 0.009; % Damping coefficient for Area 2
T12 = 0.545; % Synchronizing coefficient between areas
Kp1 = 120; % Governor gain for Area 1
Kp2 = 120; % Governor gain for Area 2
Ki = 1; % Integral gain

% Transfer Functions
s = tf('s');
Area1 = Kp1 / (M1 * s + D1);
Area2 = Kp2 / (M2 * s + D2);

% Tie-Line Power Flow


TieLine = T12 / s;

% Open Loop Model


OpenLoop = [Area1, -TieLine; -TieLine, Area2];

% Closed Loop with Integral Control


IntegralController = Ki / s * eye(2); % Integral controllers for both areas
System = feedback(OpenLoop, IntegralController);

27
% Step Response for Load Disturbance
figure;
step(System);
title('Load Frequency Control with Integral Controller');
xlabel('Time (s)');
ylabel('Frequency Deviation (Hz)');
grid on;

% Stability Analysis
figure;
bode(System);
title('Bode Plot of Two-Area System');
grid on;

OUTPUT:

28
EXPERIMENT: 7
Aim: To design PID controller in a process control system.
Software Used: Matlab
Theory:

29
Code:
clc;
clear;
close all;
% Process model: Transfer function (example: first-order system)
Kp = 1; % Process gain
tau = 5; % Time constant
L = 2; % Time delay
sys = tf(Kp, [tau 1], 'InputDelay', L);
% Display process transfer function
disp('Process Transfer Function:');
sys
% PID controller design
Kp_pid = 2; % Proportional gain
Ki_pid = 1; % Integral gain
Kd_pid = 0.5; % Derivative gain
% PID controller transfer function
C_pid = pid(Kp_pid, Ki_pid, Kd_pid);
% Closed-loop system
sys_cl = feedback(C_pid * sys, 1);
% Step response of the closed-loop system
figure;
step(sys_cl);
title('Closed-Loop Step Response with PID Controller');
xlabel('Time (s)');
ylabel('Process Output');
grid on;
% Bode plot for stability analysis
figure;
bode(sys_cl);

30
title('Bode Plot of Closed-Loop System');
grid on;
% Root Locus Plot
figure;
rlocus(sys_cl);
title('Root Locus of the Closed-Loop System');
grid on;
% Performance metrics (optional)
[peak, timeToPeak] = stepinfo(sys_cl);
disp('Performance Metrics:');
fprintf('Peak Value: %.3f\n', peak);
fprintf('Time to Peak: %.3f s\n', timeToPeak);

OUTPUT:

31
BLOCK DIAGRAM:

32

You might also like