# Buck Converter, cmc

state 1 matrices

A1: matrix([0, -1/L], [1/c, 0]);

B1: matrix([1/L, 0], [0, -1/c]);

C1: matrix([0, 1], [1, 0]);

D1: matrix([0, 0], [0, 0]);

state 2 matrices

A2: matrix([0, -1/L], [1/c, 0]);

B2: matrix([0, 0], [0, -1/c]);

C2: matrix([0, 1], [0, 0]);

D2: matrix([0, 0], [0, 0]);

state variables, dc

X0: matrix([Il], [Vc]);

input variables, dc

U0: matrix([Vin], [Iout]);

basic computation; keep it as it is

A: D0 * A1 + (1 - D0) * A2;

A: ratsimp(A);

B: D0 * B1 + (1 - D0) * B2;

B: ratsimp(B);

C: D0 * C1 + (1 - D0) * C2;

C: ratsimp(C);

D: D0 * D1 + (1 - D0) * D2;

D: ratsimp(D);

dc computation, still without d hat, keep it as it is

iA: invert(A);

iA: ratsimp(iA);

x0: -iA . B . U0;

x0: ratsimp(x0);

y0: (D - C . iA . B) . U0;

y0: ratsimp(y0);

ac computation, keep it as it is

E: (A1 - A2) . X0 + (B1 - B2) . U0;

E: ratsimp(E);

F: (C1 - C2) . X0 + (D1 - D2) . U0;

F: ratsimp(F);

merging E and F; keep it as it is

B: addcol(B, E);

D: addcol(D, F);

computing transfer functions; keep it as it is

S0: s * diagmatrix(2, 1) - A;

S: invert(S0);

S: ratsimp(S);

S: facsum(S, s);

tox: S . B;

tox: ratsimp(tox);

tox: ev(tox, Il=x0[1, 1], Vc=x0[2, 1]);

tox: ratsimp(tox);

tox: facsum(tox, s);

toy: C . S . B + D;

toy: ratsimp(toy);

toy: ev(toy, Il=x0[1, 1], Vc=x0[2, 1]);

toy: ratsimp(toy);

toy: facsum(toy, s);

current mode control

Hiv: tox[1, 1];

Hii: tox[1, 2];

Hid: tox[1, 3];

Hvv: toy[1, 1];

Hvi: toy[1, 2];

Hvd: toy[1, 3];

Gvv

Gvv: Hvv - Hvd * Hiv / Hid;

Gvv:ratsimp(Gvv);

Gvv: facsum(Gvv, s);

Gvi

Gvi: Hvi - Hvd * Hii / Hid;

Gvi: ratsimp(Gvi);

Gvi: facsum(Gvi, s);

Gvc

Gvc: Hvd / Hid;

Gvc: ratsimp(Gvc);

Gvc: facsum(Gvc, s);

numerical values

Hvvn: ev(Hvv, Vin=10, Vout=5, Iout=2, D0=0.5, L=10e-6, c=0.5e-3);

Hvin: ev(Hvi, Vin=10, Vout=5, Iout=2, D0=0.5, L=10e-6, c=0.5e-3);

Hvdn: ev(Hvd, Vin=10, Vout=5, Iout=2, D0=0.5, L=10e-6, c=0.5e-3);

Gvvn: ev(Gvv, Vin=10, Vout=5, Iout=2, D0=0.5, L=10e-6, c=0.5e-3);

Gvin: ev(Gvi, Vin=10, Vout=5, Iout=2, D0=0.5, L=10e-6, c=0.5e-3);

Gvcn: ev(Gvc, Vin=10, Vout=5, Iout=2, D0=0.5, L=10e-6, c=0.5e-3);