PLECS Blockset Demo Model
Overview
This demo model shows a single-phase full-wave diode rectifier connected to an unregulated boost converter. To demonstrate different ways of connecting PLECS Circuit blocks, two loads were implemented and connected using different methods. The demo model is intended to demonstrate PLECS Blockset specific features such as:
Modulator with open loop controls integrated at the Simulink level
Signal wire connections between different PLECS Circuit Blocks at the Simulink level
Physical wire connections between different PLECS Circuit Blocks at the Simulink level
Customizing the PLECS Circuit block and defining mask parameters
Initialization commands at the Simulink level and subsystem mask level
Model
The top level schematic of the demo model is depicted in Fig. 1. The model basically consists of three PLECS circuit blocks: “Power stage”, “Load profile” and “Resistive load”. Two parts are implemented at the Simulink level and contain a modulator with fixed duty cycle and a load profile which is implemented using a look-up table, respectively. The modulator generates a PWM signal using a sawtooth carrier, which is available in the Simulink Library under “PLECS Extras”. This library provides several other types of modulators.
Fig. 1 Overview of the PLECS Blockset model on the level of Simulink
Power stage
The “Power stage” is depicted in Fig. 2 and includes a single-phase full-wave diode rectifier connected to a boost converter. The loads are connected in two ways:
Signal wire The “Load profile” circuit block is connected to the power stage using signal wires. This is implemented by sensing the voltage using a Voltmeter in the “Power stage” circuit and using this voltage to drive a Controlled Voltage Source component in the “Load profile” circuit. The same concept applies to the current information that is also transmitted between the two circuit blocks using signal wires.
Physical wires Another method uses Electrical Ports that allow to directly connect different circuit blocks with physical (in this case electrical) wires.
Note
Note that by using the signal wire approach, it is possible to connect a PLECS Circuit to models from other toolboxes in Simulink. With Electrical Ports only connections between PLECS Circuit blocks are possible.
Fig. 2 Single-phase full-wave diode rectifier connected to a boost converter
Load profile
The PLECS Circuit “Load profile” implements a Controlled Current Source which is driven by a current reference value calculated by a look-up table on Simulink level. The measured output voltage of the boost converter is input as “Vin” and fed to the Controlled Voltage Source to achieve the same voltage level at the load. The measured load current is provided as a signal output “Iout” to the boost converter.
Fig. 3 Load profile
Resistive load
The PLECS Circuit “Resistive load” is interfaced to the “Power stage” by the Electrical Ports “EL. Port +” and “EL. Port -“.
Fig. 4 Resistive load
In PLECS Blockset, if an Electrical Port is placed in a top-level schematic, the PLECS Circuit block in the Simulink model will show a corresponding electrical terminal, which may be connected with other electrical terminals of the same or a different PLECS Circuit block. The Electrical Port is also assigned a unique physical port number. Together with the parameter Location on circuit block the port number determines the position of the electrical terminal of the PLECS Circuit block.
Working with the PLECS Circuit block
Initializing a PLECS Blockset Model
There are different ways to initialze a PLECS Blockset model.
Matlab script: Model variables can be initialized using a MATLAB Script written in the command window or in a separate m-file. This approach is not used in this demo model but is explained in the demo model Buck Converter with Parameter Sweep. In general, all variables that are in the Matlab Base workspace can be used to initialize a PLECS Blockset model. Please note at this point that using this type of model initialization is independent of the used PLECS model so that if the model is shared with other the initialization commands always have to be additionally shipped.
Model callbacks: Variables for a Simulink model, including any embedded PLECS Circuit blocks, can be initialized in the InitFcn tab of the Model Properties + Callbacks. In this case variables are initialized to the MATLAB base workspace. To access this menu right-click on the Simulink schematic and navigate to Model Properties. For this example initialization commands are depicted in Fig. 5.
Fig. 5 Initialization to the MATLAB base workspace by the InitFcn of the Model Properties Callbacks
Note
In all official PLECS Blockset demo models the variables are initialized in the InitFcn of the Model Properties Callbacks, as shown in Fig. 5.
Mask initialization: Variables in a local mask workspace are only visible to the underlying PLECS Circuit. Select the block to initialize mask variables, then choose Edit Mask from the Edit menu or from the block’s context menu. The initialization commands can be found under the Initialization tab, as shown in Fig. 6. In this example the load resistor
Rloadis calculated in the mask initialization commands using the dialog variablesPresisitiveandVoutDC_Mask. More information about masking subsystems is given in Defining mask parameters.Fig. 6 Initialization commands of the Mask Editor
Note
You must not change the mask type or remove the callback plecs('sl', 215) from the initialization commands. Doing so will break the interface and may lead to loss of data.
Create a mask for the PLECS Circuit Block
Adding a mask to the Circuit block allows you for example to change the block icon or to define mask parameters. For a complete guide on Simulink block masks please refer to the Simulink documentation.
Fig. 7 Block Parameters of the “Resistive load” PLECS Circuit mask
Defining mask parameters
To add parameters to the mask, select the block, then choose Edit Mask from the Edit menu or from the block’s context menu that is accessed with a right-click. On the Parameters & Dialog tab of the Mask Editor, as shown in Fig. 8, different types of parameters can be added. In this example two Edit parameters named “Resistive Power” and “DC Output Voltage” have been added and appear in the Block Parameters window, as shown in Fig. 7. These variables and their assigned values are provided to the mask workspace for evaluation.
The mask workspace contains both the mask parameters and any additional variables defined by the mask initialization commands. These variables are only visible to the underlying PLECS circuit and not to the whole Simulink Model. The mask parameter value can be entered either in the mask dialog window (Fig. 8) or via the Block Parameters window, as shown in Fig. 7.
Fig. 8 Parameters & Dialog of the Mask Editor
Accessing masked subsystems
By default, a double-click on the Circuit block opens the schematic editor. If the block is masked, however, the parameter window will appear. For this specific situation one can change the behavior of the double click in the Circuit block so that both the schematic and the parameter window are opened. This option is implemented in this example. By clicking on the PLECS Circuit “Resistive load” the mask dialog (see Fig. 7) including the underlying schematic open. For more details on how to implement this feature, please refer to the PLECS User Manual under the section Creating a New Circuit.
Simulation
Run a simulation with the model as provided. From \(0\) to \(0.5\,\mathrm{s}\) simulation time only the resistive load is present. After \(0.5\,\mathrm{s}\) the load profile is switched on, reaches its maximum after \(1\,\mathrm{s}\) and is switched off again after \(1.5\,\mathrm{s}\). The two loads are initialized in different ways:
The load profile is initialized within the model callbacks, as explained in Initializing a PLECS Blockset Model, and defined using a 1D Lookup Table component.
The resistance of the fixed load \(R_{\mathrm{load}}\) is defined in the PLECS Circuit Block mask as a function of two variables that are initialized in the Simulink model callbacks: \(R_{\mathrm{load}} = V_{\mathrm{outDC,Matlab}}^2/P_{\mathrm{resistive}}\).
Fig. 9 Simulation result of the load current and output voltage
Conclusion
As shown in this demo model, there are different options to implement initialization commands for PLECS Blockset models in Simulink. It is important to understand the workspace options and scope of the initialized variables. Furthermore, different methods of connecting physical signals between PLECS Circuit blocks were shown. To show the interconnection of a PLECS model inside Simulink a Sawtooth PWM block from the “PLECS Extras” Library and a 1D Lookup Table block from the standard Simulink library are connected with the PLECS circuit blocks.