Plexim PLECS RT Box User manual

H-Bridge Converter
1 Overview
This RT Box demo model features a current-controlled H-bridge circuit powering an inductive load.
The model is split into two distinct subsystems called “Plant” and “Controller”. The plant contains an
H-bridge converter with inductive load, and the controller employs a proportional-integral (PI) current
control scheme. These subsystems can then be independently built on the PLECS RT Box either for
Hardware-in-the-loop (HIL) testing of an external controller or for rapid control prototyping (RCP).
The following sections provide a brief description of the model and instructions on how to simulate it.
Real-time execution on the RT Box requires the model to execute using a fixed-step solver. The dis-
cretization step size parameter specifies the base sample time of the generated code and is used to dis-
cretize the physical model and control domain state-space equations. The execution time represents
the actual time it takes to execute one discrete step of the PLECS model on the RT Box hardware. The
chosen discretization step sizes and average execution times for each subsystem in this demo model
are shown in Tab. 1.
Table 1: Discretization step size and average execution time of real-time models with two RT Box 1
Subsystem Discretization Step Size Average Execution Time
Plant 2 µs 1 µs
Controller 100 µs(fsw = 10 kHz)0.7µs
1.1 Requirements
To run this demo model, the following items are needed (available at www.plexim.com):
• Two PLECS RT Boxes and one PLECS and PLECS Coder license
• The RT Box Target Support Library
• Follow the step-by-step instructions on configuring PLECS and the RT Box in the Quick Start guide
of the RT Box User Manual.
• Two 37 pin Sub-D cables to connect the boxes front-to-front.
Note that this demo model is targeted at two RT Boxes application, with one running the Plant and
the other running the Controller. In this way, the execution time of each real-time target is minimized.
Besides, the setup can easily transition to a HIL or RCP test later on.
However if the user has only one RT Box available, please check the corresponding models targeted
for one RT Box application. In this case, two 37 pin Sub-D cables are still needed to connect in front
Analog Out interface with Analog In interface, and Digital Out interface with Digital In interface.
• For RT Box 2 and 3, by default the multi-tasking feature is enabled in this demo. “Controller” part
is circled with a Task frame block, and runs in one core. The rest of the circuit on the schematic be-
longs to the “Base task”, and runs in another core. In this way the computational effort is split onto
different cores. Please check the default setting under Scheduling tab of the Coder options... win-
dow.
• For RT Box 1, multi-tasking is disabled since there is only one CPU core available for calculating
the model, which includes both Plant and the Controller.
Note This model contains model initialization commands that are accessible from:
PLECS Standalone: The menu Simulation + Simulation Parameters... + Initializations
PLECS Blockset: Right click in the Simulink model window + Model Properties + Callbacks +
InitFcn*
www.plexim.com 1

H-Bridge Converter
2 Model
The top level schematic contains two separate subsystems representing the controller and plant mod-
els, as shown in Fig. 1. Both subsystems are enabled for code generation from the Edit + Subsystem
+ Execution settings... menu. This step is necessary to generate the model code for the RT Box.
Plant
PWMCapture
Vdc'
Io'
Controller
Io
Vdc
PWMOut
z-1
z-1
Figure 1: Top level schematic of the plant and the controller subsystems
2.1 Power Circuit
The power circuit, shown in Fig. 2, is supplied by a DC source voltage of Vdc = 24 V. The H-bridge is
composed of two IGBT Half Bridge power module components, powering an inductive load. The pulse-
width modulated (PWM) switching signals are obtained from the PWM Capture block of the PLECS
RT Box library. The modeling of the power module components and the sub-cycle averaged handling
are described in the work of [1]. The measurements of DC input voltage and output inductor current
are sensed and exported out of the subsystem via Analog Out blocks from the PLECS RT Box library.
The discretization step size of the plant subsystem is set to 2µs.
V
Vdc
Vdc'
channel:
11
Analog
Out
PWMCapture
channel:
[1619]
PWM
Capture
L:
L
R:
R
A
Io'
channel:
4
Analog
Out
Figure 2: Power circuit of the H-Bridge with inductive load
Scaling Analog Outputs
The limits on Analog input and output voltage ranges of the of the PLECS RT Box target can be set in
between −10 V to 10 V from the Target tab of the Coder options... window.
However, in a typical HIL simulation, since the Analog Out values exported out of the RT Box are fed
to an embedded controller, these values are scaled and offset to be within 0 V to 3.3 V, to satisfy volt-
age requirements of a typical embedded controller.
The sensed input voltage, Vdc, is scaled to be within a 3.3 V range with a scaling factor of Vm.K.
Vm.K = 3.3
Vdc
(1)
www.plexim.com 2

H-Bridge Converter
The sensed inductor current, Io, is scaled and offset to be within a 3.3 V range with a scaling factor of
Im·Kand an offset factor of Im ·O. These factors are calculated as follows based on the maximum and
minimum current set-points Isetmax and Isetmin, respectively:
Im.K = 3.3·2
abs(Iset,max) + abs(Iset,min) (2)
Im.O = 3.3
2(3)
2.2 Controls
The controller subsystem, shown in Fig. 3, receives the sensed inductor current and the DC input
voltage values in the Analog In blocks of the PLECS RT Box component library. These values are in-
versely scaled to reverse the scaling applied at the Analog Out blocks of the “Plant” subsystem. The
modulator modeled in the subsystem named “Right Leg Duty-Cycle” modulates the right leg of the H-
bridge circuit by sensing the DC input voltage and maintaining a fixed duty cycle to achieve 12 V. The
LeftLegDuty-Cycle
V*
duty
Vdc
V
Current
Compensator
(PI)
error
out
out*
RightLegDuty-Cycle
V*
duty
Vdc
V
12
Vbias
+
−
Io
channel:
4
Analog
In
Vdc
channel:
11
Analog
In
PWMOut
channel:
[1619]
PWM
Out
+
−
+
+
Iset
Hi:
Iset_max
Lo:
Iset_min
f:
ftoggle
iL
Figure 3: Controller of the H-Bridge circuit
modulator modeled in the subsystem named “Left Leg Duty-Cycle” modulates the left leg of the H-
bridge based on a proportional-integral (PI) controller, as shown in Fig. 4. The sensed inductor current
is compared to a setpoint that is toggled between −5 A and 5 A. This error is used for current compen-
sation by the digital PI controller, which is equipped with anti-windup logic. For an elaborate explana-
tion on PI controller design parameters, please refer to “Boost Converter” demo model of the RT Box
Target Support Package. The outputs from the modulators are fed as a modulation index to the PWM
error
out
out*
K
K:
Kpz+Kiz
+
+
z-1
Ts:
Ts
+
−
+
K
K:
Kiz/(Kpz+Kiz)
Kiz
K:
Kiz
−
+
ZOH
Figure 4: Proportional-Integral controller with anti-windup
Out block from the PLECS RT Box component library. The PWM Out block has been configured to be
synchronized with the execution step size of the controller, which is set to the inverse of the switching
frequency of 10 kHz.
www.plexim.com 3

H-Bridge Converter
3 Simulation
This model can run both, in offline mode on a computer or in real-time mode on the PLECS RT Box.
For the real-time operation, two RT Boxes (referred to as “Plant” and “Controller”) need to be set up
as demonstrated in Fig. 5. Please follow the instructions below to run a real-time model on two RT
Boxes:
• Connect the Analog Out interface of the “Plant” RT Box to the Analog In interface of the “Con-
troller” RT Box, and the Digital In interface of the “Plant” RT Box to the Digital Out interface of
the “Controller” RT Box (e.g. using two DB37 cables shown in Fig. 5).
• From the System tab of the Coder options... window, select the “Plant” and Build it onto the
“Plant” RT Box. Then, select “Controller" and Build it onto the “Controller” RT Box.
• Once the models are uploaded, from the External Mode tab of the Coder options... window, Con-
nect to both RT Boxes and Activate autotriggering.
Analog In
Analog Out
Digital In
Digital Out
Analog In
Analog Out
Digital In
Digital Out
Controller Plant
Analog Signals
PWM Signals
Figure 5: Hardware configuration for the real-time operation with two RT Boxes
The inductor current measurements can be viewed using the scope found in the “Plant” subsystem as
well as the scope in the “Controller” subsystem. The inductor current reference is toggled between
−5 A and 5 A using the “Iset” (Pulse Generator) component of the “Controller” subsystem. These ref-
erence values can be changed on the fly, in real-time, since the “Iset” component has been added to the
"Exceptions" list found in the Parameter Inlining tab of the Coder options... window, prior to build-
ing the model.
The step response of the inductor current in real-time is shown in Fig. 6.
A trigger control for a desired Trigger channel can be set from the External Mode tab.
4 Conclusion
This model demonstrates an H-bridge converter with a discrete current controller that can be run in
both offline mode, as well as in real-time. The model also demonstrates the Parameter Inlining fea-
ture using a current controller reference that can be changed in real-time.
References
[1] J. Allmeling, and N. Felderer, “Sub cycle average models with integrated diodes for real-time sim-
ulation of power converters,” IEEE Southern Power Electronics Conference (SPEC), 2017.
www.plexim.com 4

Revision History:
RT Box Target Support Package 1.8.3 First release
RT Box Target Support Package 2.1.5 Turn on Assertions in IGBT Half
Bridges and add deadtime in the
PWM Out block
How to Contact Plexim:
+41 44 533 51 00 Phone%
+41 44 533 51 01 Fax
Plexim GmbH Mail)
Technoparkstrasse 1
8005 Zurich
Switzerland
http://www.plexim.com Web
RT Box Demo Model
© 2002–2021 by Plexim GmbH
The software PLECS described in this document is furnished under a license agreement. The software
may be used or copied only under the terms of the license agreement. No part of this manual may be
photocopied or reproduced in any form without prior written consent from Plexim GmbH.
PLECS is a registered trademark of Plexim GmbH. MATLAB, Simulink and Simulink Coder are regis-
tered trademarks of The MathWorks, Inc. Other product or brand names are trademarks or registered
trademarks of their respective holders.
Other manuals for PLECS RT Box
7
This manual suits for next models
3
Table of contents
Other Plexim Media Converter manuals

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim RT Box TSP 2.0.5 User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual

Plexim
Plexim PLECS RT Box User manual