-
Notifications
You must be signed in to change notification settings - Fork 3
/
PItuning.m
115 lines (83 loc) · 3.22 KB
/
PItuning.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
%% PItuning.m
% Autors: Erick Fernando Alves, Daniel dos Santos Mota
% Date: 2021-09-13
%
% This function tunes the PI controllers for current and DC-link voltage
% regulation on the dq0 reference frame of a grid-connected three-phase
% voltage source converter (VSC).
%
%%
function [Icont, Ucont] = PItuning(param, dual)
%% Interface
% Input Struct
% param
% .Fn : [Hz] rated frequency
% .Sn : [VA] rated apparent power
% .Udc : [Vdc] rated dc voltage
% .Cdc : [F] dc link capacitor
% .dampDC : [-] damping of dc link voltage regulator
% .Fsw : [Hz] PWM switching frequency
% .Ts_control : [s] sampling time of control loop
% .L1 : [H] LCL converter side inductance
% .l1 : [pu] LCL converter side inductance
% .R1 : [Ohm] LCL converter side resistance
% .Cf : [F] shunt capacitance
% .Rf : [Ohm] damping resistor
% .L2 : [H] trafo short circuit inductance seen from LV side
% .fres : [Hz] filter resonance frequency
% dual : [0/1] 0 = single, 1 = dual controller
%% Output Struct
% Icont : kp (1 + 1/sTi)
% .Ti : [s] Integrator time
% .kp : [pu/pu] proportional gain
% Ucont : kp (1 + 1/sTi)
% .Ti : [s] Integrator time
% .kp : [pu/pu] proportional gain
%
Icont = {};
Ucont = {};
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
if dual == 1
disp('% PI tuning - Dual Controller');
else
disp('% PI tuning - Single Controller');
end
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
%% Suul 2008
% Tuning of Control Loops for Grid Connected Voltage Source Converters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Equations (8) and (10)
% Sum of small time constants
% assumed filter time constant at half fres
TsumI = 2 / (2 * pi * param.LCL.fres) + 0.5 / param.Fsw;
TsumU = TsumI + 2 / (2 * pi * param.LCL.fres);
if dual == 1
TsumI = TsumI + 1 / (2 * pi * param.Fn);
TsumU = TsumU + 1 / (2 * pi * param.Fn);
end
% Equation (13)
% Current controller parameters
halfTs = 0.5*param.Ts_control;
Icont.Ti = (param.LCL.L1/param.LCL.R1) + halfTs;
Icont.kp = 0.5* param.LCL.r1 * (Icont.Ti - halfTs)/(TsumI + halfTs);
disp('Current controller PI transfer function = kp (1 + 1/(sTi))');
disp([' Sum of small time constants TsumI = ',num2str(TsumI),' s']);
disp([' Ti = ',num2str(Icont.Ti),' s']);
disp([' kp = ',num2str(Icont.kp),' pu/pu']);
disp(' Current feedback from LV side of trafo!');
% Calculation of Tc in (20)
% Vdc[V] = 1/(Cdc[F]) * integral(Idc[A] dt)
% Vdc[V] = 1/(s Cdc[F]) Idc[A] : s is the Laplace variable
% vdc[pu] * Udc[V] = 1/(s Cdc[F]) * idc[pu] Idc[A] : Udc Idc are the bases
% vdc[pu] = 1/(s Tc) * idc[pu] : where Tc = Cdc[F] * Udc[V] / Idc[A]
Idc = param.Sn / param.Udc;
Tc = param.Cdc * param.Udc / Idc;
% Equation (18)
a = 2*param.dampDC + 1;
% Equations (20)
Ucont.Ti = a^2 * (TsumU + halfTs);
Ucont.kp = Tc / (a*(TsumU + halfTs));
disp('DC voltage controller PI transfer function = kpdc (1 + 1/(s Tidc))');
disp([' Sum of small time constants TsumU = ',num2str(TsumU),' s']);
disp([' Ti = ',num2str(Ucont.Ti),' s']);
disp([' kp = ',num2str(Ucont.kp),' pu/pu']);