Seventh-Semester Submitted By: Ritik Raj (102104010) 4ELE1 BE Fourth Year (2021-2025) Electrical Engineering
Seventh-Semester Submitted By: Ritik Raj (102104010) 4ELE1 BE Fourth Year (2021-2025) Electrical Engineering
(UEE706)
Seventh-Semester
Submitted by:
Ritik Raj [102104010]
4ELE1
Submitted To:
Dr. S. K. AGGARWAL
ASSOCIATE PROFESSOR
2
EXPERIMENT: 1
Theory:
3
CODE AND OUTPUT:
4
5
6
EXPERIMENT: 2
7
(i) Code: Polar to rectangular and vice versa
% Polar to Rectangular
r = 5; % Magnitude (Example)
theta = 30; % Phase in degrees (Example)
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)
disp('Rectangular to Polar:');
disp(['Magnitude: ', num2str(r_polar), ', Phase: ', num2str(theta_polar), ' degrees']);
OUTPUT:
% Symmetrical Components
Negative sequence
8
disp('Symmetrical Components:');
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
(Example)V_a = 10 * exp(1j *
deg2rad(30));
V_b = 10 * exp(1j *
deg2rad(150));V_c = 10 *
exp(1j * deg2rad(-90));
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
];
Transform to dq0
1, 0, 0;
10
];
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:
% 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(X);
OUTPUT:
12
EXPERIMENT: 3(a)
Simulation
13
Model Components:
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)
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
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)
% Initial conditions
x0_mechanical = [0; 0]; % Initial position and velocity for mechanical system
x0_electrical = [0; 0]; % Initial current and voltage for electrical system
% 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
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
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
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);
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