Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
49 views

Dual Active Bridge Co-Simulation.: Aristeo Barrios Rivera - Visiting Scholar at LIPE

The document describes Matlab simulations of dual active bridges and three-phase inverters. It includes the state-space equations, parameters, and code for implementing Runge-Kutta simulations of: 1) A dual active bridge with state variables of inductor current and capacitor voltage 2) A three-phase inverter with state variables of phase voltages and currents along with Park's transform variables 3) Plots of the simulation results including voltage and current waveforms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Dual Active Bridge Co-Simulation.: Aristeo Barrios Rivera - Visiting Scholar at LIPE

The document describes Matlab simulations of dual active bridges and three-phase inverters. It includes the state-space equations, parameters, and code for implementing Runge-Kutta simulations of: 1) A dual active bridge with state variables of inductor current and capacitor voltage 2) A three-phase inverter with state variables of phase voltages and currents along with Park's transform variables 3) Plots of the simulation results including voltage and current waveforms.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Aristeo Barrios Rivera - Visiting Scholar at LIPE

Dual Active Bridge Co-Simulation.

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Dual Active Bridge Matlab Simulation.
() = ()[1 () 2 ()]
() = ()[3 () 4 ()]

()
() =

() = () ()
() = ()[3 () 4 ()]
() +

() = ()[1 () 2 ()]
()[3 () 4 ()]


() =

()

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Three phase inverter Co-Simulation.

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Three phase inverter Matlab Simulation.
[

()
()]
[ ()]
()] = [ ()] +

()] = [ ()] [
()]

[
()] =

[
()]

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Three phase rectifier Co-Simulation.

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Three phase rectifier Matlab Simulation.

() + () + ()
() = () () [ ()
] ()

3

() + () + ()
() = () () [ ()
] ()

() + () + ()
() = () () [ ()
] ()

()
() = () () + () () + () ()

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Three phase rectifier Code.
clc, clear all
close all
format short
% Simulation settings
ti = 0;
tf = 0.5;
h = 1e-6;
N = (tf-ti)/h;
% Parameters
RL = 1;
L = 22e-3;
C = 2.2e-3;
Rload = 100;
Shift = (2/3)*pi;
VDC = 1;
% Frequencies
f = 20e3;
fo = 60;
% ====== Initial conditions ======
k = 1;
t(k)
= 0;
triang(k) = 0;
PLLa(k) = 0;
PLLb(k) = 0;
PLLc(k) = 0;
Ea(k) = 0;
Eb(k) = 0;
Ec(k) = 0;
x(:,k) = [0;0;0;0];
Am = 1;
for k=1:N
Teta = 2*pi*fo*t(k);
%Triangle Signal
triang(k+1) = ( (2)/(pi) ) * ( asin(sin(2*pi*t(k)*f)) );
%PLL reference
PLLa(k+1) = Am*sin(Teta
);
PLLb(k+1) = Am*sin(Teta - Shift);
PLLc(k+1) = Am*sin(Teta + Shift);
%Grid voltages
Ea(k+1) = sqrt(2)*120*sin(Teta
);
Eb(k+1) = sqrt(2)*120*sin(Teta - Shift);
Ec(k+1) = sqrt(2)*120*sin(Teta + Shift);
% Switches conmutation
Sa(k+1) = ( PLLa(k+1) >= triang(k+1) )*( VDC/2 ) + ( PLLa(k+1) < triang(k+1) )*( -VDC/2 ) + 0.5 ;
Sb(k+1) = ( PLLb(k+1) >= triang(k+1) )*( VDC/2 ) + ( PLLb(k+1) < triang(k+1) )*( -VDC/2 ) + 0.5 ;
Sc(k+1) = ( PLLc(k+1) >= triang(k+1) )*( VDC/2 ) + ( PLLc(k+1) < triang(k+1) )*( -VDC/2 ) + 0.5 ;
SS = ( Sa(k+1) + Sb(k+1) + Sc(k+1) )/3;
SSa = Sa(k+1) - SS;
SSb = Sb(k+1) - SS;
SSc = Sc(k+1) - SS;
A=[

-RL/L
0
0
-SSa/L ;
0
-RL/L
0
-SSb/L ;
0
0
-RL/L
-SSc/L ;
Sa(k+1)/C Sb(k+1)/C Sc(k+1)/C -1/(Rload*C) ];

b = [ Ea(k+1) ; Eb(k+1) ; Ec(k+1) ; 0 ]*(1/L);

%RungeKutta fourth-order

Aristeo Barrios Rivera - Visiting Scholar at LIPE


%============================================================
x1 = x(:,k);
k1 = A*x1 + b;
%============================================================
x2 = x(:,k) + (1/2)*k1*h;
k2 = A*x2 + b;
%============================================================
x3 = x(:,k) + (1/2)*k2*h;
k3 = A*x3 + b;
%============================================================
x4 = x(:,k) + k3*h;
k4 = A*x4 + b;
%============================================================
x(:,k+1) = x(:,k) + (1/6)*h*( k1 + 2*k2 + 2*k3 + k4 );
t(k+1) = t(k)+h;
end
figure(1)
plot(t,triang)
grid on
figure(2)
plot(t,Sa,t,PLLa,t,triang)
grid on
figure(3)
plot(t,x(4,:),'*',t,Ea,t,Eb,t,Ec)
xlabel('Time (seconds)')
ylabel('Voltage (volts)')
grid on
legend('DC Voltage','A Phase Grid','B Phase Grid','C Phase Grid')
max = max(Ea);
figure(4)
plot(t,x(1:3,:),t,Ea,t,Eb,t,Ec)
xlabel('Time (seconds)')
ylabel('Current (amperes)')
axis([(tf-(1/fo)*2) tf -(50+max) (50+max)])
grid on
legend('A Phase Current','B Phase Current','C Phase Current','A Phase Grid Voltage','B Phase Grid Voltage','C Phase Grid Voltage')

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Dual Active Bridge Code.
clc, clear all
close all
format short
% Simulation settings
ti = 0;
tf = 4000e-3;
h = 1e-6;
N = (tf-ti)/h;
% Triangular carrier wave
f = 20e3;
D = 45;
%Shift Angle
tD = (D*(1/f))/360;
%Shift Time
% Parameters
L = 50e-6;
RL = 0.1;
Rload = 10;
Np = 10;
Ns = 15;
C = 20e-6;
Vin = 400;
u = Vin;
% Modulation Index
m = 0;
k = 1;
t(k) = 0;
triang_HB_1(k) = 0;
triang_HB_2(k) = 0;
S1(k) = 0;
S2(k) = 0;
S3(k) = 0;
S4(k) = 0;
x(:,k) = [0 ; 0];
Vpri(k) = 0;
Vsec(k) = 0;
Vout(k) = 0;
for k=1:N
%State-space representation
A=[
-RL/L -(Np/Ns)*(1/L)*(S3(k)-S4(k)) ;
(1/C)*(S3(k)-S4(k))
-1/(Rload*C) ];
b = [ (S1(k)-S2(k))/L ; 0 ];
%RungeKutta fourth-order
%============================================================
x1 = x(:,k);
k1 = A*x1 + b*u;
%============================================================
x2 = x(:,k) + (1/2)*k1*h;
k2 = A*x2 + b*u;
%============================================================
x3 = x(:,k) + (1/2)*k2*h;
k3 = A*x3 + b*u;
%============================================================
x4 = x(:,k) + k3*h;
k4 = A*x4 + b*u;
%============================================================
x(:,k+1) = x(:,k) + (1/6)*h*( k1 + 2*k2 + 2*k3 + k4 );
% Switches H-Bridge 1
S1(k+1) = ( triang_HB_1(k) >= m );
S2(k+1) = ( triang_HB_1(k) <= m );
% Switches H-Bridge 2
S3(k+1) = ( triang_HB_2(k) >= m );
S4(k+1) = ( triang_HB_2(k) <= m );
% Triangle signals for both bridges
triang_HB_1(k+1) = ( (2)/(pi) ) * ( asin(sin(2*pi*t(k)*f)) );

%Triangle Signal for H-Bridge 1

Aristeo Barrios Rivera - Visiting Scholar at LIPE


triang_HB_2(k+1) = ( (2)/(pi) ) * ( asin(sin(2*pi*(t(k)-tD)*f)) );
Vout(k+1) = x(2,k+1);
Vpri(k+1) = Vin*( S1(k+1) - S2(k+1) );
Vsec(k+1) = Vout(k+1)*( S3(k+1) - S4(k+1) );
t(k+1) = t(k) + h;
end
iL = x(1,:);
Vout = x(2,:);
figure(1)
plot(t,triang_HB_1,t,triang_HB_2)
axis([(tf-(1/f)*3) tf -(1.5) (1.5)])
xlabel('Time (seconds)')
grid on
legend('Triangle wave Bridge 1','Triangle wave Bridge 2')
figure(2)
plot(t,Vout)
xlabel('Time (seconds)')
ylabel('Voltage (volts)')
grid on
legend('DC Voltage')
figure(3)
plot(t,Vpri,t,Vsec,t,iL)
xlabel('Time (seconds)')
legend('Primary Voltage','Secondary Voltage','Leakage Current')
axis([(tf-(1/f)*3) tf -(50+Vin) (50+Vin)])
grid on

%Triangle Signal for H-Bridge 2

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Three phase inverter Code.
clc, clear all
close all
format short
% Simulation settings
ti = 0;
tf = 0.1;
h = 1e-6;
N = (tf-ti)/h;
Am = 1;
f = 20e3;
fo = 60;
Shift = (2/3)*pi;
VDC = 680;
L = 4e-3;
RL = 0.01;
C = 10e-6;
RLOAD = 100;
Vbase = VDC/2;
setpoint = 120;
setpoint_pu = setpoint/Vbase;
k = 1;
triang(k) = 0;
t(k) = 0;
PLLa(k) = 0;
PLLb(k) = 0;
PLLc(k) = 0;
Fundamental(:,k) = [0 ; 0 ; 0];
v_a0(k) = 0;
v_b0(k) = 0;
v_c0(k) = 0;
v_ab(k) = 0;
v_bc(k) = 0;
v_ca(k) = 0;
v_an(k) = 0;
v_bn(k) = 0;
v_cn(k) = 0;
x(:,k) = [0 ; 0 ; 0 ; 0 ; 0 ; 0 ; 0 ];
i(:,k) = [0 ; 0 ; 0 ];
v(:,k) = [0 ; 0 ; 0 ];
v_dq0(:,k) = [0 ; 0 ; 0 ]
v_q(k+1) = 0;
v_q_pu(k+1) = 0;
A=[0
0
0
0
0
0
0;
0 -1/(C*RLOAD)
0
0 1/C
0
0;
0
0 -1/(C*RLOAD)
0
0 1/C
0;
0
0
0 -1/(C*RLOAD)
0
0 1/C ;
0
-1/L
0
0 -RL/L
0
0;
0
0
-1/L
0
0 -RL/L
0;
0
0
0
-1/L
0
0 -RL/L ];
b = [1 ; 0 ; 0 ; 0 ; 1/L ; 1/L ; 1/L];
error_pu = 0;
kc = 10;
Ti = 0.01;
for k=1:N

Aristeo Barrios Rivera - Visiting Scholar at LIPE


Teta = 2*pi*fo*t(k);
%Triangle Signal
triang(k+1) = ( (2)/(pi) ) * ( asin(sin(2*pi*t(k)*f)) );
%PLL reference
PLLa(k+1) = Am*sin(Teta
);
PLLb(k+1) = Am*sin(Teta - Shift);
PLLc(k+1) = Am*sin(Teta + Shift);
% Inverter circuit derive pole voltages
v_a0(k+1) = ( Fundamental(1,k) >= triang(k+1) )*( VDC/2 ) + ( Fundamental(1,k) < triang(k+1) )*( -VDC/2 ) ;
v_b0(k+1) = ( Fundamental(2,k) >= triang(k+1) )*( VDC/2 ) + ( Fundamental(2,k) < triang(k+1) )*( -VDC/2 ) ;
v_c0(k+1) = ( Fundamental(3,k) >= triang(k+1) )*( VDC/2 ) + ( Fundamental(3,k) < triang(k+1) )*( -VDC/2 ) ;
% Line to line voltages
v_ab(k+1) = v_a0(k+1) - v_b0(k+1);
v_bc(k+1) = v_b0(k+1) - v_c0(k+1);
v_ca(k+1) = v_c0(k+1) - v_a0(k+1);
% Phase Voltages
v_an(k+1) = ( v_ab(k+1) - v_ca(k+1) )/3;
v_bn(k+1) = ( v_bc(k+1) - v_ab(k+1) )/3;
v_cn(k+1) = ( v_ca(k+1) - v_bc(k+1) )/3;
% System Input
u = [(kc/Ti)*error_pu ; 0 ; 0 ; 0 ; v_an(k+1) ; v_bn(k+1) ; v_cn(k+1) ];
%RungeKutta fourth-order
%============================================================
x1 = x(:,k);
k1 = A*x1 + b.*u;
%============================================================
x2 = x(:,k) + (1/2)*k1*h;
k2 = A*x2 + b.*u;
%============================================================
x3 = x(:,k) + (1/2)*k2*h;
k3 = A*x3 + b.*u;
%============================================================
x4 = x(:,k) + k3*h;
k4 = A*x4 + b.*u;
%============================================================
x(:,k+1) = x(:,k) + (1/6)*h*( k1 + 2*k2 + 2*k3 + k4 );
v(:,k+1) = x(2:4,k+1);
i(:,k+1) = x(5:7,k+1);
%Park's transformation
%=====================================================================
T = (2/3)*[ cos(Teta) cos(Teta-Shift) cos(Teta+Shift) ;
-sin(Teta) -sin(Teta-Shift) -sin(Teta+Shift) ;
0.5
0.5
0.5 ];
v_dq0(:,k+1) = T*v(:,k+1);
i_dq0(:,k+1) = T*i(:,k+1);
v_q(k+1) = -v_dq0(2,k+1);
%PI Controller
%=====================================================================
v_q_pu(k+1) = v_q(k+1)/Vbase;
error_pu = setpoint_pu - v_q_pu(k+1);
Proportional = kc*error_pu;
Integral = x(1,k+1);
v_q_pu_controlled = Proportional + Integral;
%Inverse Park's transformation
%=====================================================================

Aristeo Barrios Rivera - Visiting Scholar at LIPE


IT = [ cos(Teta )
-sin(Teta)
1;
cos(Teta-Shift) -sin(Teta-Shift) 1 ;
cos(Teta+Shift) -sin(Teta+Shift) 1 ];
v_dq0_controlled = [0 ; -v_q_pu_controlled ; 0];
v_abc_pu_controlled = IT*v_dq0_controlled;
%Feedback
%=====================================================================
Fundamental(:,k+1) = v_abc_pu_controlled;
%Load change
%=====================================================================
if t(k) >= 0.05
setpoint = 200;
setpoint_pu = setpoint/Vbase;
end
t(k+1) = t(k)+h;
end
figure(1)
plot(t,v)
xlabel('Time (seconds)')
ylabel('Voltage (volts)')
legend('A Phase Output Voltage','B Phase Output Voltage','C Phase Output Voltage')
grid on
figure(2)
plot(t,v_q_pu)
grid on
figure(3)
plot(t,i)
xlabel('Time (seconds)')
ylabel('Current (amperes)')
legend('A Phase Output Current','B Phase Output Current','C Phase Output Current')
grid on

You might also like