Commit f4cf941c authored by Martin Vítek's avatar Martin Vítek

Made state variable from Uin

parent 7d734cf0
......@@ -69,7 +69,8 @@ U_{in} &= (R_{62} + R_{Q25} + R_{L3})i_l + L_3\derivative{i_l}{t} + R_{Q24}i_l \
\begin{align}
\derivative{i_l}{t} &= \frac{1}{L_3}U_{in}-\frac{R_{62}+R_{Q25}+R_{L3}+R_{Q24}}{L_3}i_l \\
\derivative{u_c}{t} &= -\frac{1}{C_{out}(R_{63}+R_{load})}u_c
\derivative{u_c}{t} &= -\frac{1}{C_{out}(R_{63}+R_{load})}u_c \\
\derivative{U_{in}}{t} &= 0
\end{align}
\vspace{1em}
......@@ -77,16 +78,14 @@ U_{in} &= (R_{62} + R_{Q25} + R_{L3})i_l + L_3\derivative{i_l}{t} + R_{Q24}i_l \
\begin{align}
\derivative{}{t}
\begin{bNiceMatrix} i_l \\ u_c \end{bNiceMatrix}
\begin{bNiceMatrix} i_l \\ u_c \\ U_{in} \end{bNiceMatrix}
&=
\begin{bNiceMatrix}
-\frac{R_{62}+R_{Q25}+R_{L3}+R_{Q24}}{L_3} & 0 \\
0 & -\frac{1}{C_{out}(R_{63}+R_{load})}
-\frac{R_{62}+R_{Q25}+R_{L3}+R_{Q24}}{L_3} & 0 & \frac{1}{L_3} \\
0 & -\frac{1}{C_{out}(R_{63}+R_{load})} & 0 \\
0 & 0 & 0
\end{bNiceMatrix}
\begin{bNiceMatrix}i_l \\ u_c \end{bNiceMatrix}
+
\begin{bmatrix} \frac{1}{L_3} \\ 0 \end{bmatrix}
U_{in}
\begin{bNiceMatrix}i_l \\ u_c \\ U_{in}\end{bNiceMatrix}
\end{align}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......@@ -107,7 +106,8 @@ C_{out}\derivative{u_c}{t} &= i_l - \frac{u_c}{R_{63}+R_{load}}
\begin{align}
\derivative{i_l}{t} &= \frac{1}{L_3}(U_{in}-u_c)-\frac{R_{62}+R_{Q25}+R_{L3}+R_{s_{D6}}}{L_3}i_l \\
\derivative{u_c}{t} &= \frac{1}{C_{out}}i_l-\frac{1}{C_{out}(R_{63}+R_{load})}u_c
\derivative{u_c}{t} &= \frac{1}{C_{out}}i_l-\frac{1}{C_{out}(R_{63}+R_{load})}u_c \\
\derivative{U_{in}}{t} &= 0
\end{align}
\vspace{1em}
......@@ -115,16 +115,14 @@ C_{out}\derivative{u_c}{t} &= i_l - \frac{u_c}{R_{63}+R_{load}}
\begin{align}
\derivative{}{t}
\begin{bmatrix} i_l \\ u_c \end{bmatrix}
\begin{bmatrix} i_l \\ u_c \\ U_{in} \end{bmatrix}
=
\begin{bmatrix}
-\frac{R_{62}+R_{Q25}+R_{L3}+R_{s_{D6}}}{L_3} & -\frac{1}{L_3} \\
\frac{1}{C_{out}} & -\frac{1}{C_{out}(R_{63}+R_{load})}
-\frac{R_{62}+R_{Q25}+R_{L3}+R_{s_{D6}}}{L_3} & -\frac{1}{L_3} & \frac{1}{L_3} \\
\frac{1}{C_{out}} & -\frac{1}{C_{out}(R_{63}+R_{load})} & 0 \\
0 & 0 & 0
\end{bmatrix}
\begin{bmatrix}i_l \\ u_c \end{bmatrix}
+
\begin{bmatrix} \frac{1}{L_3} \\ 0 \end{bmatrix}
U_{in}
\begin{bmatrix}i_l \\ u_c \\ U_{in} \end{bmatrix}
\end{align}
......@@ -143,16 +141,14 @@ $A_1$, $B_1$ - Q24 v uzavřeném stavu, $A_2$, $B_2$ - Q24 v otevřeném stavu.
\begin{align}
\derivative{}{t}
\begin{bmatrix} i_l \\ u_c \end{bmatrix}
\begin{bmatrix} i_l \\ u_c \\ U_{in} \end{bmatrix}
=
\begin{bmatrix}
-\frac{R_{62}+R_{Q25}+R_{L3}+R_{s_{D6}}}{L_3} & -\frac{1-d}{L_3} \\
\frac{1-d}{C_{out}} & -\frac{1}{C_{out}(R_{63}+R_{load})}
-\frac{R_{62}+R_{Q25}+R_{L3}+R_{s_{D6}}}{L_3} & -\frac{1}{L_3}(1-d) & \frac{1}{L_3} \\
\frac{1}{C_{out}}(1-d) & -\frac{1}{C_{out}(R_{63}+R_{load})} & 0 \\
0 & 0 & 0
\end{bmatrix}
\begin{bmatrix}i_l \\ u_c \end{bmatrix}
+
\begin{bmatrix} \frac{1}{L_3} \\ 0 \end{bmatrix}
U_{in}
\begin{bmatrix}i_l \\ u_c \\ U_{in} \end{bmatrix}
\end{align}
\subsection{Odezva otevřené smyčky pro různé hodnoty střídy}
......@@ -172,43 +168,42 @@ U_{in}
\begin{align}
\derivative{}{t}
\begin{bmatrix} i_l \\ u_c \end{bmatrix}
\begin{bmatrix} i_l \\ u_c \\ U_{in} \end{bmatrix}
=
\begin{bmatrix}
-\frac{R_{in}}{L_3} & 0 \\
0 & -\frac{1}{C_{out}R_{out}}
-\frac{R_{in}}{L_3} & 0 & \frac{1}{L_3} \\
0 & -\frac{1}{C_{out}R_{out}} & 0 \\
0 & 0 & 0
\end{bmatrix}
\begin{bmatrix}i_l \\ u_c \end{bmatrix}
\begin{bmatrix}i_l \\ u_c \\ U_{in}\end{bmatrix}
+
\begin{bmatrix}
-\frac{\overline{u_c}}{L_3} \\
\frac{\overline{i_L}}{C_{out}}
\frac{\overline{i_L}}{C_{out}} \\
0
\end{bmatrix}
D
+
\begin{bmatrix} \frac{1}{L_3} \\ 0 \end{bmatrix}
U_{in}
\end{align}
\section{Diskretizace}
\begin{align}
\derivative{}{t}
\begin{bmatrix} i_l \\ u_c \end{bmatrix}
\begin{bmatrix} i_l \\ u_c \\ U_{in} \end{bmatrix}
=
\begin{bmatrix}
-\frac{R_{in}}{L_3} & 0 \\
0 & -\frac{1}{C_{out}R_{out}}
-\frac{R_{in}}{L_3} & 0 & \frac{1}{L_3} \\
0 & -\frac{1}{C_{out}R_{out}} & 0 \\
0 & 0 & 0
\end{bmatrix}
\begin{bmatrix}i_l \\ u_c \end{bmatrix}
\begin{bmatrix}i_l \\ u_c \\ U_{in}\end{bmatrix}
+
\begin{bmatrix}
-\frac{\overline{u_c}}{L_3} & \frac{1}{L_3} \\
\frac{\overline{i_L}}{C_{out}} & 0
\end{bmatrix}
\begin{bmatrix}
D \\ U_{in}
-\frac{\overline{u_c}}{L_3} \\
\frac{\overline{i_L}}{C_{out}} \\
0
\end{bmatrix}
D
\end{align}
\vspace{1em}
......@@ -216,34 +211,13 @@ U_{in}
\begin{align}
\begin{bmatrix}
i_{l,t+1} \\ u_{c,t+1}
i_{l,t+1} \\ u_{c,t+1} \\ U_{in,t+1}
\end{bmatrix}
=
\boldsymbol{A}
\begin{bmatrix}i_l \\ u_c \end{bmatrix}
\begin{bmatrix}i_{l,t} \\ u_{c,t} \\ U_{in,t}\end{bmatrix}
+
\boldsymbol{B}
\begin{bmatrix}
D \\ U_{in}
\end{bmatrix}
\end{align}
\begin{align}
\begin{bmatrix}
i_{l,t+1} \\ u_{c,t+1}
\end{bmatrix}
=
\boldsymbol{A}
\begin{bmatrix}i_l \\ u_c \end{bmatrix}
+
\begin{bmatrix}
\boldsymbol{B}_{1,1} \\ \boldsymbol{B}_{2,1}
\end{bmatrix}
D +
\begin{bmatrix}
\boldsymbol{B}_{1,2} \\ \boldsymbol{B}_{2,2}
\end{bmatrix}
U_{in}
\boldsymbol{B}D
\end{align}
......@@ -256,78 +230,74 @@ U_{in}
\begin{align}
\begin{bmatrix}
i_{l,t+1} \\ u_{c,t+1} \\ \Delta_{t+1}
i_{l,t+1} \\ u_{c,t+1} \\ U_{in,t+1} \\ \Delta_{t+1}
\end{bmatrix}
&=
\begin{bmatrix}
\boldsymbol{A}_{1,1} & \boldsymbol{A}_{1,2} & 0 \\
\boldsymbol{A}_{2,1} & \boldsymbol{A}_{2,2} & 0 \\
0 & \mathrm{d}t & 1 \\
\boldsymbol{A}_{1,1} & \boldsymbol{A}_{1,2} & \boldsymbol{A}_{1,3} & 0 \\
\boldsymbol{A}_{2,1} & \boldsymbol{A}_{2,2} & \boldsymbol{A}_{2,3} & 0 \\
\boldsymbol{A}_{3,1} & \boldsymbol{A}_{3,2} & \boldsymbol{A}_{3,3} & 0 \\
0 & \mathrm{d}t & 0 & 1 \\
\end{bmatrix}
\begin{bmatrix}
i_{l,t} \\ u_{c,t} \\ \Delta_t
i_{l,t} \\ u_{c,t} \\ U_{in,t} \\ \Delta_t
\end{bmatrix}
+
\begin{bmatrix}
\boldsymbol{B}_{1,1} \\
\boldsymbol{B}_{2,1} \\
\boldsymbol{B}_{3,1} \\
0
\end{bmatrix}
D +
\begin{bmatrix}
\boldsymbol{B}_{1,2} \\
\boldsymbol{B}_{2,2} \\
0 \\
\end{bmatrix}
U_{in} +
\begin{bmatrix}
0 \\ 0 \\ -\mathrm{d}t
0 \\ 0 \\ 0 \\ -\mathrm{d}t
\end{bmatrix}
u_{c,t}^*
\end{align}
\begin{align}
\begin{bmatrix}
i_{l,t+1} \\ u_{c,t+1} \\ \Delta_{t+1}
i_{l,t+1} \\ u_{c,t+1} \\ U_{in,t+1} \\ \Delta_{t+1}
\end{bmatrix}
&=
\begin{bmatrix}
\boldsymbol{A}_{1,1} & \boldsymbol{A}_{1,2} & 0 \\
\boldsymbol{A}_{2,1} & \boldsymbol{A}_{2,2} & 0 \\
0 & \mathrm{d}t & 1 \\
\boldsymbol{A}_{1,1} & \boldsymbol{A}_{1,2} & \boldsymbol{A}_{1,3} & 0 \\
\boldsymbol{A}_{2,1} & \boldsymbol{A}_{2,2} & \boldsymbol{A}_{2,3} & 0 \\
\boldsymbol{A}_{3,1} & \boldsymbol{A}_{3,2} & \boldsymbol{A}_{3,3} & 0 \\
0 & \mathrm{d}t & 0 & 1 \\
\end{bmatrix}
\begin{bmatrix}
i_{l,t} \\ u_{c,t} \\ \Delta_t
i_{l,t} \\ u_{c,t} \\ U_{in,t} \\ \Delta_t
\end{bmatrix}
+
\begin{bmatrix}
\boldsymbol{B}_{1,1} & \boldsymbol{B}_{1,2} & 0 \\
\boldsymbol{B}_{2,1} & \boldsymbol{B}_{2,2} & 0 \\
0 & 0 & -\mathrm{d}t
\boldsymbol{B}_{1,1} & 0 & 0 & 0 \\
\boldsymbol{B}_{2,1} & 0 & 0 & 0 \\
\boldsymbol{B}_{3,1} & 0 & 0 & 0 \\
0 & 0 & 0 & -\mathrm{d}t
\end{bmatrix}
\begin{bmatrix}
D \\ U_{in} \\ u_{c,t}^*
D \\ 0 \\ 0 \\ u_{c,t}^*
\end{bmatrix}
\end{align}
\section{Regulátor}
\begin{align}
d &= -\boldsymbol{L}x_t - \boldsymbol{K}w \\
d &= -\boldsymbol{L}
D &= -\boldsymbol{L}x_t - \boldsymbol{K}w \\
D &= -\boldsymbol{L}
\begin{bmatrix}
i_{l,t} \\ u_{c,t} \\ \Delta_{t}
i_{l,t} \\ u_{c,t} \\ U_{in,t} \\ \Delta_{t}
\end{bmatrix}
- \boldsymbol{K}
\begin{bmatrix}
D \\ U_{in} \\ u_{c,t}^*
\end{bmatrix} \\
- \boldsymbol{K}u_{c,t}^* \\
\boldsymbol{L} &= dlqr(\boldsymbol{A}, \boldsymbol{B}, \boldsymbol{Q}, \boldsymbol{N}, \boldsymbol{R}) \\
\boldsymbol{K} &= \{-\boldsymbol{C_w}[\boldsymbol{I}-(\boldsymbol{A}-\boldsymbol{BL})]^{-1}\boldsymbol{B}\}^{-1} \\
\boldsymbol{C}_w &= \begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1
\end{bmatrix}
\end{align}
......
......@@ -30,13 +30,15 @@ il_lin = 0.83;
% Continuous time matrixes
cssm.A = [-par.Rin/par.L3, 0;
0, -1/(par.Cout*par.Rout)];
cssm.A = [-par.Rin/par.L3, 0, 1/par.L3;
0, -1/(par.Cout*par.Rout), 0;
0, 0, 0];
cssm.B = [-uc_lin/par.L3, 1/par.L3;
il_lin/par.Cout, 0];
cssm.B = [-uc_lin/par.L3;
il_lin/par.Cout;
0];
cssm.C = eye(2);
cssm.C = eye(size(cssm.B,1));
cssm.D = zeros(size(cssm.B));
......@@ -44,46 +46,48 @@ cssm.D = zeros(size(cssm.B));
dssm = c2d(ss(cssm.A, cssm.B, cssm.C, cssm.D), Ts);
% Add error integration
dsys.A = [dssm.A(1,1), dssm.A(1,2), 0;
dssm.A(2,1), dssm.A(2,2), 0;
0, Ts, 1];
dsys.B = [dssm.B(1,1), dssm.B(1,2), 0;
dssm.B(2,1), dssm.B(2,2), 0;
0, 0, -Ts];
dsys.C = eye(3);
dsys.A = [dssm.A(1,1), dssm.A(1,2), dssm.A(1,3), 0;
dssm.A(2,1), dssm.A(2,2), dssm.A(2,3), 0;
dssm.A(3,1), dssm.A(3,2), dssm.A(3,3), 0;
0, Ts, 0, 1];
dsys.B = [dssm.B(1,1);
dssm.B(2,1);
dssm.B(3,1);
0];
dsys.C = eye(size(dsys.B, 1));
dsys.D = zeros(size(dsys.B));
% Simulate system (open loop)
% i = 1;
% i0 = 0.75;
% u0 = 170;
% delta0 = 0.9;
% tmax = 0.1;
%
% sim.vars(:,1) = [i0, u0, delta0];
% sim.t(i) = 0;
%
% for t=dssm.Ts:dssm.Ts:tmax
% sim.vars(:, i+1) = dsys.A*sim.vars(:, i) + dsys.B*[1-d; Uin; uc_req];
% sim.t(i+1) = t;
%
% i = i+1;
% end
%Simulate system (open loop)
i = 1;
i0 = 0.75;
u0 = Uin;
delta0 = 0.9;
tmax = 0.1;
% Plot it
%plot_sim(sim, "Open loop response", 1);
sim.vars(:,1) = [i0, u0, Uin, delta0];
sim.t(i) = 0;
for t=dssm.Ts:dssm.Ts:tmax
sim.vars(:, i+1) = dsys.A*sim.vars(:, i) + dsys.B*(1-d);
sim.t(i+1) = t;
i = i+1;
end
%Plot it
plot_sim(sim, "Open loop response", 1);
% Regulator
Q = diag([0, 0.01, 0.5]);
% Q = diag([0, 0.5, 0, 0.5]);
Q = 1e-5*eye(4);
R = 1;
N = zeros(3);
N = zeros(size(Q, 1),1);
L = dlqr(dsys.A, dsys.B, Q, R, N);
% Cw = eye(3);
Cw = [1, 0, 0 ; 0, 1, 0; 0, 0, 1];
p = inv(eye(3) - (dsys.A - dsys.B*L));
Cw = eye(4);
p = inv(eye(4) - (dsys.A - dsys.B*L));
K = inv(-Cw * p * dsys.B);
......@@ -148,16 +152,20 @@ title("d");
function plot_sim(sim, what, num)
figure(num);
sgtitle(sprintf("%s", what));
subplot(1,3,1);
subplot(1,4,1);
plot(sim.t, sim.vars(1,:));
title("il");
subplot(1,3,2);
subplot(1,4,2);
plot(sim.t, sim.vars(2,:));
title("uc");
subplot(1,3,3);
subplot(1,4,3);
plot(sim.t, sim.vars(3,:));
title("Uin");
subplot(1,4,4);
plot(sim.t, sim.vars(4,:));
title("delta");
hold off
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment