Code covered by the BSD License

# Closed-Loop Input and Output Impedance of DC/DC Power Converters (Voltage or Current Mode)

by

### Reza (view profile)

Calculates closed-loop impedances and converter trasnfer functions for a power converter

buck.m
```clear all
clc
%% Open-Loop Transfer Functions
%Parameter defenitions
syms ron rL R rc d Vin vd L C S Iload

%Comment any of the parasitic values below to consider that value in the
%transfer function calculations
ron=0;
vd=0;
rc=0;
rL=0;

%State-space equations for
%Kx_dot=Ax+Bu
%y=Cx+Du
%where x=[iL,vc], u=[vin,vd,iload], y=[iin, vo, iL]
%First mode of operation
A1=[-(ron+rL+(R*rc/(R+rc))) -R/(R+rc) ; R/(R+rc) -1/(R+rc)];
B1=[sym(1) 0 -rc*R/(R+rc); 0 0 -R/(R+rc)];
C1=[1 0 ; rc*R/(R+rc) R/(R+rc) ; 1 0];
D1=[0 0 0 ; 0 0 -R*rc/(R+rc); 0 0 0];
K=[L 0 ; 0 C];
%Second mode of operation
A2=[-R*rc/(R+rc)-rL -R/(R+rc) ; R/(R+rc) -1/(R+rc)];
B2=[0 -sym(1) R*rc/(R+rc) ; 0 0 -R/(R+rc)];
C2=[0 0 ; R*rc/(R+rc) R/(R+rc) ; 1 0];
D2=[0 0 0 ; 0 0 -R*rc/(R+rc); 0 0 0];

%Averaging state-space equations
Aavg=d*A1+(1-d)*A2;
Aavg=simple(Aavg);
Bavg=d*B1+(1-d)*B2;
Bavg=simple(Bavg);
Cavg=d*C1+(1-d)*C2;
Cavg=simple(Cavg);
Davg=d*D1+(1-d)*D2;
Davg=simple(Davg);

%Small-signal state-space model
% Kx_dot=Aavg*x+Bavg*u+E*d
% y=Cavg*x+Davg*u+F*d
X=-Aavg^-1*Bavg*U;
X=simple(X);
E=(A1-A2)*X+(B1-B2)*U;
E=simple(E);
F=(C1-C2)*X+(D1-D2)*U;
F=simple(F);

H=Cavg*((S*[sym(1) 0; 0 sym(1)]-(K^(-1))*Aavg)^-1)*(K^(-1))*Bavg+Davg;
H=simple(H);
Zin=(H(1,1))^-1;
Gvg=H(2,1);
Gig=H(3,1);

%Transfer functions when d=0, vin=0
Zout=-H(2,3);
GiL=H(3,3);

%Transfer functions when u=0
G=(Cavg*((S*[sym(1) 0; 0 sym(1)]-(K^(-1))*Aavg)^-1)*(K^(-1))*E)+F;
G=simple(G);
Gind=G(1,1);    %iin/d
Gvd=G(2,1);
Gid=G(3,1);

'Open-Loop Transfer Functions'
'Gvg='
pretty(Gvg)
'Gvd='
pretty(Gvd)
'Zout='
pretty(Zout)
'Gig='
pretty(Gig)
'Gid='
pretty(Gid)
'GiL='
pretty(GiL)
'Zin='
pretty(Zin)
'Gind='
pretty(Gind)
'GinL='
pretty(GinL)

%% Clsoed-Loop Input and Output Impedances
%Voltage Mode Control
syms vo vi Gc Ss Gm iin iload

solution1 = solve('vo=Gvg*vi+Gvd*d','d=-vo*Gc*Ss*Gm','iin=(Zin^(-1))*vi+Gind*d','vo','d','vi');
ZinCLv=solution1.vi/iin;
ZinCLv=simple(ZinCLv);

ZoutCLv=simple(ZoutCLv);

'Voltage Mode Control'
'ZinCL (VMC)'
pretty(ZinCLv)
'='
pretty(subs(ZinCLv))
'ZoutCL (VMC)'
pretty(ZoutCLv)
'='
pretty(subs(ZoutCLv))

%Current Mode Control
syms Fm iL Rf Fv Fg

ZoutCLi=simple(ZoutCLi);

solution4 = solve('vo=Gvg*vi+Gvd*d','d=Fm*(-vo*Ss*Gc-Rf*iL-Fv*vo-Fg*vi)','iL=Gig*vi+Gid*d','iin=(Zin^(-1))*vi+Gind*d','vo','d','iL','vi');
ZinCLi=solution4.vi/iin;
ZinCLi=simple(ZinCLi);

'Current Mode Control'
'ZinCL (CMC)'
pretty(ZinCLi)
'='
pretty(subs(ZinCLi))
'ZoutCL (CMC)'
pretty(ZoutCLi)
'='
pretty(subs(ZoutCLi))

%% Substituting Values in Closed-Loop Impedances
%Enter your values in the "Values" matrix for the corresponding parameters in
%the "Parameters" matrix below
Parameters=[C L R rL rc Vin vd Gm Fm Fv Fg Rf d Iload Gc Ss];
Values=[3.4e-6 2.1e-3 10 0.1 0.1 400 0.6 1 1 1.2 1.4 1.5 0.3 5 1+1/S 1/S];

ZoutCLvs=collect(simple(subs(subs(ZoutCLv),Parameters,Values)),S);
ZinCLvs=collect(simple(subs(subs(ZinCLv),Parameters,Values)),S);
ZoutCLis=collect(simple(subs(subs(ZoutCLi),Parameters,Values)),S);
ZinCLis=collect(simple(subs(subs(ZinCLi),Parameters,Values)),S);

'Transfer Functions with Parameter Values'
'ZoutCL (VMC)'
pretty(ZoutCLvs)
'ZinCL (VMC)'
pretty(ZinCLvs)
'ZoutCL (CMC)'
pretty(ZoutCLis)
'ZinCL (CMC)'
pretty(ZinCLis)

%% Transform the Symbolic Transfer Functions Into ZPK Transfer Functions

[symNum,symDen] = numden(ZoutCLvs);
TFnum = sym2poly(symNum);
TFden = sym2poly(symDen);
ZoutCLvt =tf(TFnum,TFden);

[symNum,symDen] = numden(ZinCLvs);
TFnum = sym2poly(symNum);
TFden = sym2poly(symDen);
ZinCLvt =tf(TFnum,TFden);

[symNum,symDen] = numden(ZoutCLis);
TFnum = sym2poly(symNum);
TFden = sym2poly(symDen);
ZoutCLit =tf(TFnum,TFden);

[symNum,symDen] = numden(ZinCLis);
TFnum = sym2poly(symNum);
TFden = sym2poly(symDen);
ZinCLit =tf(TFnum,TFden);

'ZPK Transfer Functions'
'ZoutCL (VMC)'
ZoutCLvt
'ZinCL (VMC)'
ZinCLvt
'ZoutCL (CMC)'
ZoutCLit
'ZinCL (CMC)'
ZinCLit

```