+1 (315) 557-6473 

Matlab Program to Create Voltage Regulator Assignment Solution.


Instructions

Objective
Write a program to create voltage regulator in matlab.

Requirements and Specifications

program to create voltage regulator in matlab

Source Code

clc, clear all, close all

lf = 1.1;

lr = 1.7;

xe = 0;

ye = 0;

phie = pi/4;

ve = 35;

betae = 0;

A = [0, 0, cos(phie+betae), -ve*sin(phie+betae);

0, 0, sin(phie+betae), ve*cos(phie+betae);

0, 0, 0, 0,;

0, 0, sin(betae)/lr, 0];

B = [-ve*sin(phie+betae) 0;ve*cos(phie+betae) 0;0 1;(ve/lr)*cos(betae) 0];

C = [0,1,0,0];

D = [0, 0];

sys = tf(ss(A,B,C,D));

% Kp = 2;

% Ki = 1;

% Kd = 10;

% Cs = pid(Kp, Ki, Kd);

% T = feedback(Cs*G, 1);

%% Question 2

G = sys(1);

a = 0;

yref = 0;

Kp = 1.5;

Ki = 38;

% Simulate

sim('question2_with_controller.slx', 3);

% Plot

t = ans.yout.Time;

yout = ans.yout.Data;

figure

plot(t, yout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('y(t) vs Time from Linear Model');

% pause

%% Question 3

sim('question3_nonlin.slx', 2);

t = ans.yout.Time;

yout = ans.yout.Data;

figure

plot(t, yout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('y(t) vs Time from Non-Linear model');

%% Question 4

Kpv = 15;

Kiv = 35;

vref = 35;

sim('question4.slx', 5);

t = ans.out4.Time;

yout = ans.out4.Data(:,1);

vout = ans.out4.Data(:,2);

figure

subplot(1,2,1)

plot(t, yout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('y(t) vs Time from Linear model');

subplot(1,2,2)

plot(t, vout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('v(t) vs Time from Linear model');

%% Question 5

Kpv = 15;

Kiv = 35;

vref = 35;

sim('question5.slx', 4);

t = ans.out5.Time;

yout = ans.out5.Data(:,1);

vout = ans.out5.Data(:,2);

figure

subplot(1,2,1)

plot(t, yout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('y(t) vs Time from Non-Linear model');

subplot(1,2,2)

plot(t, vout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('v(t) vs Time from Non-Linear model');

%% Question 5.b)

Kiv = Ki/100;

vref = 35;

sim('question5.slx', 4);

t = ans.out5.Time;

yout = ans.out5.Data(:,1);

vout = ans.out5.Data(:,2);

figure

subplot(1,2,1)

plot(t, yout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('y(t) vs Time from Non-Linear model (Slower controller for v)');

subplot(1,2,2)

plot(t, vout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('v(t) vs Time from Non-Linear model (Slower controller for v)');

%% Question 6

Kpv = 15;

Kiv = 35;

vref = 5;

sim('question5.slx', 4);

t = ans.out5.Time;

yout = ans.out5.Data(:,1);

vout = ans.out5.Data(:,2);

figure

subplot(1,2,1)

plot(t, yout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('y(t) vs Time from Non-Linear model');

subplot(1,2,2)

plot(t, vout)

grid on

xlabel('Time (s)')

ylabel('Amplitude')

title('v(t) vs Time from Non-Linear model');