# Converter System Modeling via MATLAB/Simulink

A powerful environment for system modeling and simulation
MATLAB: programming and scripting environment
Simulink: block diagram modeling environment that runs inside MATLAB
Things we can achieve, relative to Spice:
•  Higher level of abstraction, suitable for higher-level system models
•  More sophisticated controller models
•  Arbitrary system elements
But:
•  We have to derive our own mathematical models
•  Simulink signals are unidirectional as in conventional block
diagrams
At CoPEC, nearly all simulation is done within MATLAB/Simulink
Open-loop buck converter
Time domain simulation including switching ripple
Closed-loop buck converter, digital control
Time domain simulation with switching ripple
Open-loop buck-boost converter
Frequency domain simulation, averaged model
Control-to-output transfer function
Closed-loop buck converter
Frequency domain simulation, averaged model
Loop gain: Bode plot
•  A structured way to write the converter averaged equations,
State-space averaging
•  Some basic converter models, implemented in Simulink
•  How to plot small-signal transfer functions in Simulink
•  Modeling the discontinuous conduction mode
Synchronous buck converter
Formulating state equations for Simulink model
i
C
= i – i
i
g
= di
L
+
t
r
T
s
i
L
+
Q
r
T
s
Averaging the input current
Averaging the capacitor current:
For both intervals,
Resulting state equations:
v
L
(t)
t
dT
s
T
s
Averaging the inductor voltage
v
L
= d v
g
– i R
on
+ R
L
– v
out
+ d – i R
on
+ R
L
– v
out
with v
out
= v + i – i
esr
so v
L
= dv
g
– i R
on
+ R
L
– v – i – i
esr
i
g
= di
L
+
t
r
T
s
i
L
+
Q
r
T
s
L
di
dt
= v
L
= dv
g
– i R
on
+ R
L
– v – i – i
esr
C
dv
dt
= i
C
= i – i
v
out
= v + i – i
esr
Basic buck converter model
Independent
inputs
Integration of state
variables
Outputs
Embedded MATLAB
code block:
vector
•  Set circuit parameters
•  Calculate state
equations and outputs
•  Place results in output
y vector
(used in current
mode control)
Time-domain simulation
employing
synchronous buck
model, with voltage
mode control
Output voltage transient
response
Generating a Bode Plot from the Simulink file
1. Set transfer function input and output points
•  Right-click on the desired wire
•  Select “Linearization Points”, then “input point” or “output point”
Generating a Bode Plot from Simulink, p. 2
%% Bode plotter using linearization tool
% requires simulink control design toolbox
mdl = 'buckCPM4Vmodetester'; % set to file name of simulink model. Must
have i/o points set within this model
io = getlinio(mdl) % get i/o signals of mdl
op = operspec(mdl)
op = findop(mdl,op) % calculate model operating point
lin = linearize(mdl,op,io) % compute state space model of linearized
system
ltiview(lin) % send linearized model to LTI Viewer tool
•  Save this as a script (“.m ﬁle”) and run it whenever you want to
generate a Bode plot
•  This script ﬁnds the steady-state operating point and linearizes the
model
•  The last line opens the LTI Viewer tool, which generates various
small-signal plots including Bode, step response, pole/zero, Nyquist,
etc.
Control-to-output transfer function G
vd

Synchronous buck example of previous slides
Modeling DCM
i
L
(t)
t
i
pk
dT
s
d
2
T
s
T
s
In DCM, the average inductor current
can be expressed as:
i
L
t =
1
2
i
pk
d + d
2
with i
pk
=
v
g
v
L
dT
S
so i
L
t =
1
2
v
g
v
L
dT
S
d + d
2
Treat the average inductor current
as an independent state, and solve
for d
2
:

Note that d
2
= 1 – d in CCM, and
d
2
< 1 – d in DCM
Combined CCM-DCM model
Buck converter
State equations:

v
L
t d v
g
d d

v
i
C
t i i
i
g
t
d
d d

i
Buck control-to-output transfer function
CCM vs. DCM
R = 3Ω: CCM
R = 24Ω: DCM
Fundamentals of Power Electronics Chapter 9: Controller design
46
9.5.4. Design example
+

+
v(t)

v
g
(t)
28 V

+
Compensator
Hv
Pulse-width
modulator
v
c
Transistor
gate driver
δ
G
c
(s)
H(s)
v
e
Error
signal
Sensor
gain
i
L
50 µH
C
500 µF
R
3 Ω
f
s
= 100 kHz
V
M
= 4 V
v
ref
5 V
Closed-loop buck converter
Simulink frequency domain simulation, averaged model
Loop gain: Bode plot
Transfer function blocks:
Implementing the PID compensator
Injection point for
measurement of
loop gain T(s)
f
c
ϕ
m
Closed-loop line-to-output transfer function
Closed loop G
vg
Open loop G
vg
Open loop
Closed loop
Script that generates both plots

Open-loop buck converter Time domain simulation including switching ripple .

digital control Time domain simulation with switching ripple .Closed-loop buck converter.

averaged model Control-to-output transfer function .Open-loop buck-boost converter Frequency domain simulation.

averaged model Loop gain: Bode plot .Closed-loop buck converter Frequency domain simulation.

suitable for implementation in Simulink: State-space averaging •  Some basic converter models. implemented in Simulink •  How to plot small-signal transfer functions in Simulink •  Modeling the discontinuous conduction mode .MATLAB/Simulink discussion •  A structured way to write the converter averaged equations.

i C = i – i Load dTs Ts t Resulting state equations: i g = di L + L di = vL = dvg – i R on + R L – v – i – i Load esr dt C dv = i C = i – i Load dt vout = v + i – i Load esr tr Q iL + r Ts Ts vL = d vg – i R on + R L – vout + d – i R on + R L – vout with vout = v + i – i Load esr so vL = dvg – i R on + R L – v – i – i Load esr .Synchronous buck converter Formulating state equations for Simulink model Averaging the input current i g = di L + tr Q iL + r Ts Ts Averaging the inductor voltage vL(t) Averaging the capacitor current: For both intervals.

Basic buck converter model Averaged model for Simulink Integration of state variables Outputs Independent inputs Embedded MATLAB code block: •  Load inputs from u vector •  Set circuit parameters •  Calculate state equations and outputs •  Place results in output y vector (used in current mode control) .

Time-domain simulation Synchronous buck example. Simulink Simulink model employing synchronous buck model. with voltage mode control Output voltage transient response .

Generating a Bode Plot from the Simulink file 1. then “input point” or “output point” . Set transfer function input and output points •  Right-click on the desired wire •  Select “Linearization Points”.

pole/zero. etc. Must have i/o points set within this model io = getlinio(mdl) % get i/o signals of mdl op = operspec(mdl) op = findop(mdl.op) % calculate model operating point lin = linearize(mdl.m ﬁle”) and run it whenever you want to generate a Bode plot •  This script ﬁnds the steady-state operating point and linearizes the model •  The last line opens the LTI Viewer tool. which generates various small-signal plots including Bode.io) % compute state space model of linearized system % send linearized model to LTI Viewer tool ltiview(lin) •  Save this as a script (“. 2 %% Bode plotter using linearization tool % requires simulink control design toolbox mdl = 'buckCPM4Vmodetester'.op.Generating a Bode Plot from Simulink. % set to file name of simulink model. p. . step response. Nyquist.

Control-to-output transfer function Gvd Generated by Simulink Synchronous buck example of previous slides .

the average inductor current can be expressed as: Treat the average inductor current as an independent state. and d2 < 1 – d in DCM .Modeling DCM Buck example. Simulink model iL(t) ipk dTs d2Ts Ts t In DCM. and solve for d2: Note that d2 = 1 – d in CCM.

Combined CCM-DCM model Buck converter Simulink model State equations: .

Buck control-to-output transfer function CCM vs. DCM R = 3Ω: CCM R = 24Ω: DCM .

5.4. Design example L 50 µH + vg(t) 28 V + – C 500 µF v(t) – Transistor gate driver δ fs = 100 kHz Error signal ve iload R 3Ω H(s) Sensor gain Fundamentals of Power Electronics 46 Chapter 9: Controller design –+ Pulse-width vc G (s) c modulator VM = 4 V Compensator Hv vref 5V .9.

Closed-loop buck converter Simulink frequency domain simulation. averaged model fc ϕm Loop gain: Bode plot Injection point for measurement of loop gain T(s) Transfer function blocks: Implementing the PID compensator .

Closed-loop line-to-output transfer function Simulink frequency domain simulation Closed loop Gvg Open loop Closed loop Open loop Gvg Script that generates both plots .