0% found this document useful (0 votes)
171 views14 pages

Boost Converter Using Simulink

This document describes the steps to model a boost converter circuit in Simulink using MATLAB embedded functions. Key steps include: 1. Setting up the initial Simulink model with constant blocks, a subsystem block, and scope block. 2. Building the subsystem with integrator blocks, mux/demux blocks, and a MATLAB function block to define the converter equations. 3. Creating PWM, relay, and repeating sequence blocks to generate the switching signal. 4. Writing the state space equations in the MATLAB function block based on whether the MOSFET is on or off. 5. Configuring parameters like inductance and resistance as variables so users can adjust the model.

Uploaded by

Nicola Delmonte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views14 pages

Boost Converter Using Simulink

This document describes the steps to model a boost converter circuit in Simulink using MATLAB embedded functions. Key steps include: 1. Setting up the initial Simulink model with constant blocks, a subsystem block, and scope block. 2. Building the subsystem with integrator blocks, mux/demux blocks, and a MATLAB function block to define the converter equations. 3. Creating PWM, relay, and repeating sequence blocks to generate the switching signal. 4. Writing the state space equations in the MATLAB function block based on whether the MOSFET is on or off. 5. Configuring parameters like inductance and resistance as variables so users can adjust the model.

Uploaded by

Nicola Delmonte
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Boost Converter – Simulink Model

Using MATLAB Embedded Function


In this post, I am going to talk about modelling dc-dc power converters using MATLAB’s user defined function block.
Doing so saves a lot of time and it’s much more easier as compared to the Buck converter model in which each
dynamical equation is implemented using blocks. Doing so is not only time consuming, but tracking back and finding
out errors is hard especially when the system becomes larger. In this model, I have used as few blocks as possible.

The Boost converter circuit is shown in fig.1. I have accounted for the parasitic resistance in passive components as
well as the ON resistance for active device.

Vout
iL
vL
ic vc
ig iout

Fig. 1: Boost converter circuit with some parasitics.


Inputs the converter model are:

▪ Input voltage Vg
▪ Voltage control (duty cycle) d
▪ Load current iout

Converter outputs

▪ Capacitor voltage vC
▪ Inductor current iL
▪ Output voltage Vout
▪ Input current Ig
Step 1:
▪ Start Simulink either using the MATLAB command window or by clicking the Simulink button on the toolbar
▪ Create a new Simulink model file and save it as boost.slx
▪ From the Simulink place 3 instances of Constant block located under “Commonly used blocks”. Also place a
Subsystem block as well a Scope block.
At this point your model file will look something like fig. 2. Notice that I have renamed the blocks to identify their
respective characteristic.
Fig. 2: Initial set up for Boost converter model
Step – 2:
▪ Open the Boost converter subsystem block by double clicking on it.
Notice the default connection between In1 and Out1. Delete this connection.
▪ Add 2 more instances of In1 and 3 more instance of Out1 found under commonly used block
▪ Add an instance of Subsystem, mux, and demux found under commonly used block
▪ Navigate to user-defined functions and add a MATLAB Function block to your model file
▪ Go to the continuous library and add 2 instances of Integrator block to your model file.
Make the connections as shown in fig.3 and rename your blocks appropriately. Notice that by default Mux block has 2
inputs and Demux has 2 outputs. This can be changed by double clicking on the respective blocks and changing the
number of inputs/outputs

Fig. 3: Boost converter subsystem block


Step – 3:
▪ Open the PWM system block, and delete the default connection between In1 and Out1
▪ Add a Repeating Sequence block found under Sources
▪ Go to Math library and add a Subtract block
▪ Finally from the discontinuous library add a Relay block and make the necessary connection as shown in fig. 2
Fig. 4: PWM subsystem block

Open the Repeating Sequence block by double clicking. This block lets you set up switching frequency for the
converter as well as the amplitude VM for the PWM signal. Rather than setting it to some default value, this parameters
can be set as variables so that the user has control over changing them for different design.

Warnings due to variables


(fs and VM) not yet defined
in MATLAB Workspace

Fig. 5: Setting parameters in Repeating Sequence block


Step – 4:
Going back to the user defined function, this is where we will enter the converter state equations. You can refer to
the lecture notes on boost to get an in-depth view of how these equations are derived.
When the MOSFET M1 is on, the behavior of the converter can be captured by the following equations,

𝑣𝐿 = 𝑉𝑔 − 𝑖𝐿 (𝑅𝐿 + 𝑅𝑜𝑛 ) Ron = MOSFET on-state resistance

𝑖𝐶 = −𝑖𝑜𝑢𝑡

𝐼𝑔 = 𝑖𝐿

𝑉𝑜𝑢𝑡 = 𝑣𝐶 − 𝑖𝑜𝑢𝑡 𝑅𝐸𝑆𝑅

Similarly, when MOSFET switches off, the equations are


𝑣𝐿 = 𝑉𝑔 − 𝑖𝐿 𝑅𝐿 − 𝑉𝑜𝑢𝑡

𝑖𝐶 = 𝑖𝐿 − 𝑖𝑜𝑢𝑡

𝐼𝑔 = 𝑖𝐿

𝑉𝑜𝑢𝑡 = 𝑣𝐶 + 𝑅𝐸𝑆𝑅 (𝑖𝐿 − 𝑖𝑜𝑢𝑡 )

Over one switching period Ts the equations can be combined and represented as follow:

Inductor voltage,

𝑣𝐿 = 𝑉𝑔 − 𝑖𝐿 (𝑅𝐿 + 𝑅𝑜𝑛 ) ∙ 𝑑 + (𝑉𝑔 − 𝑖𝐿 𝑅𝐿 − 𝑉𝑜𝑢𝑡 ) ∙ (1 − 𝑑)

Capacitor current,

𝑖𝐶 = −𝑖𝑜𝑢𝑡 ∙ 𝑑 + (𝑖𝐿 − 𝑖𝑜𝑢𝑡 ) ∙ (1 − 𝑑)


Input current,

𝐼𝑔 = 𝑖𝐿 ∙ 𝑑 + 𝑖𝐿 ∙ (1 − 𝑑)

Output voltage,

𝑉𝑜𝑢𝑡 = 𝑣𝐶 − 𝑅𝐸𝑆𝑅 𝑖𝑜𝑢𝑡 ∙ 𝑑 + 𝑣𝐶 + 𝑅𝐸𝑆𝑅 (𝑖𝐿 − 𝑖𝑜𝑢𝑡 ) ∙ (1 − 𝑑)

Solving them, the equations simplify to,

𝑣𝐿 = 𝑉𝑔 − 𝑉𝑜𝑢𝑡 ∙ (1 − 𝑑) − 𝑖𝐿 (𝑅𝐿 +𝑅𝑜𝑛 ∙ 𝑑)

𝑖𝐶 = 𝑖𝐿 ∙ (1 − 𝑑) − 𝑖𝑜𝑢𝑡

𝐼𝑔 = 𝑖𝐿

𝑉𝑜𝑢𝑡 = 𝑣𝐶 + 𝑅𝐸𝑆𝑅 𝑖𝐿 ∙ (1 − 𝑑) − 𝑖𝑜𝑢𝑡

The above equations can be entered directly to our MATLAB function. The 5 inputs via Mux are stored in an array
format. The code should look something as follow:
function y = CCMBoost(u,L,C,RL,Ron,Resr)

% Inputs:
% u = [Vg d iout v_C i_L]
%
% Parameters:
% L, RL, C, Resr, Ron
%
% Outputs:
% y =[dv_C/C di_L/L Vo ig]

Vg = u(1); % Input voltage


d = u(2); % Switch control (duty cycle)
iout = u(3);% Load current
vC = u(4); % Capacitor voltage
iL = u(5); % Inductor current

dbar = 1-d;

% State equations
Vo = vC + Resr*((iL*dbar) - iout); % Output voltage
Ig = iL; % Input current
iC = (iL*dbar) - iout; % Capacitor current
vL = Vg - (Vo*dbar) - iL*((Ron*D) + RL); % Inductor voltage

% Output
y = [iC/C vL/L Vo Ig];

Save the MATLAB function. Now we want the parameters be set as variables so that the user can change them. In
order to do so, click on Edit Data in Editor menu as shown in fig. 6

Fig. 6: Edit Data tool button in the Editor menu


In the next window, select you will find a list of your I/O ports as well as the parameters specified in the function file.
Select the input port u and change it’s size to 5 so that it matches the input array.

Fig. 7: Changing data port u property

Also, change the scope of L, C, RL, Ron and RESR from input to parameter. This can be done simply by clicking on
the respective input and selecting parameter from the drop-down menu. At the end, your port manager window
should look as follow:
Fig. 8: Port/Data Manager

Going back to the Boost subsystem block, you can set up initial conditions for the inductor current and capacitor
voltage. In order to do so, open the capacitor integrator block, and type in a variable name under the initial condition
field. Do the same for inductor integrator block as well. As an example, they can be named them as vC_0 and iL_0.

Fig. 8-b: Main Subsystem appearance at this stage.


Fig. 9: Configuring initial condition variable
Now, go back to the starting, open the Scope block and open the scope parameters. Under Configuration Properties in Main tab,
change the Number of input ports to 4. Then under Logging uncheck limit data points to last. Click apply and connect the scope
inputs to the boost converter outputs.

Fig. 10: Changing scope setting

Now, you can connect all the blocks of the system as shown in Figure 11.
Fig. 11: Final connections
Right click on the Boost subsystem block, and select Create Mask. This will open Mask Editor, where you can create a UI for the
user to change the boost converter variables and parameters. In the Mask Editor, click on Parameters & Dialog tab. Then add all the
variables via the Edit button. Make sure that the variable name matches the ones used within the subsystems.

Variable name to set


Text that will be shown
in the User Interface
(UI), or the windows of
the Mask

Value editable by the user


Click here to add new parameter
Your final mask window should look something as follow,

Fig. 12: Mask editor

Apply your settings and close the editor window. Now if you try and open (double click on it) the Boost converter
subsystem block you will see a dialog box as follow,
Fig. 13: Setting parameters
I have set the parameters as follow:

Input voltage: Vg = 12 V MOSFET on-state resistance, Ron = 10 m 

PWM sawtooth carrier amplitude, VM = 1


Required output voltage is 30 V. Hence,
Initial inductor current, iL(0) = 1.5 A (N.B. This value for the inductor
was obtained using the fact that the average inductor current in a boost
𝑉𝑔 12 𝑉
Duty cycle, 𝑑 = 1 − =1− = 0.6 converter is given by 𝐼𝐿 = 𝑜𝑢𝑡 )
𝑉𝑜𝑢𝑡 30 1−𝑑 𝑅

Initial capacitor voltage, vC(0) = 30 V


Load resistance, R = 50 
N.B. You can even leave the initial condition set to 0.

𝑉𝑜𝑢𝑡 30
Load current, 𝑖𝑜𝑢𝑡 = = = 0.6 𝐴
𝑅 50

Switching frequency, fs = 100 kHz

Inductance, L = 120 H

Inductor series resistance, RL = 10 m

Capacitance, C = 50 F

Capacitor series resistance RESR = 1 m


Now that all the parameters are configured, its time to simulate and verify that our model produces the expected result.
Save your design and go to configure Model Settings under MODELING. I have set the stop time to 100 ms and
step size to 1 s.

Fig. 14: Configuration Parameters for simulation

Click on «Apply» before «OK». Otherwise, the


values entered will not be used for simulation!
Now run the simulation. If everything works out properly, then you
will get the following result.

Fig. 15: Simulation results


Fig. 16: Zoomed simulation results

You might also like