Академический Документы
Профессиональный Документы
Культура Документы
7
Block Library Reference
Guide
CHAPTER 1: INTRODUCTION
CHAPTER 2: BLOCK REFERENCE
RTE Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
RTE Conversion OP5110-5120 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
RTE Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
RTE Events Generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
RTE Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
RTE Frequency Meter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
RTE Ground . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
RTE Insert . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
RTE Integrator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
RTE Latch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
RTE Latch Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
RTE Logical Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
RTE Period Meter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
RTE Probe Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
RTE PWM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
RTE Queue . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
RTE Rate Transition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
RTE Relational Operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
RTE Remove . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
RTE Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
RTE Signal Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
RTE SPWM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
RTE Switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
RTE Sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
RTE-Drive ABC-DQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
RTE-Drive Full Park D-Q PMSM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
RTE-Drive Park D-Q PMSM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
RTE-Drive Phase Domain PMSM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
RTE-Drive Phase Domain PMSM Inductance. . . . . . . . . . . . . . . . . . . . . . . . . . 86
RTE-Drive Quadrature Decoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
Introduction
Overview
RT-Events is a Simulink blockset for the fixed-time-step simulation of hybrid systems
involving dynamics and discrete events asynchronous with respect to the simulation clock.
As the RT-Events is designed for and works with a fixed step size, it is therefore compatible
with the Real Time Workshop (RTW) and RT-LAB, and is usually used for real-time simulation
and control.
The RT-Events blockset is the solution to the following problems encountered in the
simulation of event-based systems.
Problem 1: Very long simulation time
The simulation time of mixed mode (event triggered / discrete / continuous) is increasing
drastically with system complexity and the number of discrete events involved in the
simulations. This kind of simulations traditionally require time-consuming variable stepsolver.
The actual visual simulation tools are limited to code generators that do not support
variable-step algorithms and are also limited to run in interpretative mode on a single CPU.
Problem 2: Imprecise hard-real-time simulation
Time-consuming variable time solver are usually required to compensate for errors
introduced by event occuring between two time samples. This technique cannot be applied
for hard real-time applications requiring fixed time step solver.
The actual discrete simulation algorithms suffer of intrinsic limitations. They introduced
errors in the solutions of mixed-mode system when events occur between the sampling
instants and they require sampling periods and/or interrupt response latencies smaller than
the specified timing precision of critical events; for example, 10s for a combustion engine.
Models with sampling periods smaller than 10 s are not practical with actual commercial
processors and I/O technologies.
Features
The problems describe above justify the utilisation of RT-Events blockset. Here are the major
features of the RT-Events blockset:
RT-Events blockset allows precise simulation of event-based or mixed mode systems by
compensate for the errors introduced by events occurring between the sampling instants.
The precision obtained with the RT-Events blocks depends on the step size selected with
respect to the frequency content of the signals involved.
RT-Events blockset also allows fast simulation of event-based or mixed mode systems. The
use of a fixed step size renders the RT-Events blocks suitable for hard real-time simulations
and are faster simulations than those performed with variable step algorithms. The RTEvents blockset is also adaptable to distributed real-time simulations with RT-LAB (TM)
RT-Events is of course compatible with Simulink and with RTW code generator.
RTEVENTS-UG-37
RTEVENTS_3_7_Q042011
Block Reference
RT-Events provides two sets of blocks in Simulink stored in two libraries: RT-Events and RTEDrive. To open the RT-Events or the RTE-Drive libraries, type the following commands at the
Matlab prompt:
>> rtevents
or
>> rtedrive
These libraries are also available from the Simulink browser.
RTEVENTS-UG-37
The next section presents all block available inside the RT-EVENTS and the RTE-Drive
libraries.
RT-Events
Discrete
RTE Delay
RTE Integrator
Integrates the input signal and compensates for the discretetime error.
RTE Latch
Latchs the input signal each time an event occurs but delay it
by one step.
Math Operations
RTEVENTS_3_7_Q042011
RTE Filter
RTE Insert
RTE Queue
RTE Relational
Operator
RTE Remove
RTE Sum
Signal Attributes
RTE Conversion
RTE Conversion
OP5110-5120
Measures the frequency and the duty cycle of its input signals.
Measures the period, the frequency and the duty cycle of its
input signals.
Signal Routing
RTE Switch
Passes through the first input or the third input based on the
value of the second control input.
Sinks
RTE Scope
Sources
RTE Events Generator
RTE Ground
RTE PWM
RTE SPWM
RTE-Drive
Machines
RTE-Drive Full Park D-
Q PMSM
machine with sinusoidal flux distribution using the full park D-Q
reference frame.
PMSM
RTEVENTS_3_7_Q042011
RTE-Drive Phase
Domain PMSM
RTE-Drive Phase
Domain PMSM
Inductance
Measurements
RTE-Drive ABC-DQ
RTE-Drive Quadrature
Decoder
incremental encoder.
Power Electronics
RTE-Drive 2-Level TSB
RTEVENTS_3_7_Q042011
RTE Conversion
Library
RT-Events Signal Attributes
Block
Description
The RTE Conversion block converts an input signal to the data type specified by the block's
Data Types parameter.
The following table explains all output data type conversion available:
Double
Double with
Compensation
RTE Boolean
Compensation
RTE Double
RTEVENTS_3_7_Q042011
RTE
Compensation
Mask
Parameters
Specified the input data types of the input ports: double, RTE
Boolean or RTE Double.
RT-Events
Compensation
Maximum number of
events
during a single step. Over this number, events are ignored and
not outputed.
RTEVENTS_3_7_Q042011
RTE
Input
Input
The signal to convert. The data type of this signal must Double,
RTE Boolean or RTE Double.
Output
Output
The converted signals. The data type of this signal must match
the data type specified in the Output Data Type parameters.
Characteristics
Direct Feedthrough
Yes
Sample Time
Work offline
Yes
Dimensionalized
Yes
Example
The rte_basic1.mdl model shows how to do simple operations on RTE signals. It also
demonstrates how to use the RTE Conversion block to convert a RTE Boolean signal to a RTE
Double signal.
Related Items
RTE Conversion OP5110-5120
RTEVENTS_3_7_Q042011
RTE
Block
Description
This block converts:
Double-type signals output by the RT-LAB OP5110-5120 Event Detector block to RTE Booleantype signals or
RTE Boolean-type signals to double-type signals receive by the RT-LAB OP5110-5120 Event
Generator block.
The RT-LAB OP5110-5120 Event Detector/Generator block makes use of the Opal-RT
OP5110 or OP5120 reconfigurable digital input/output boards to read digital signals and
detect the transitions that occur on these signals during one calculation step. For more
information see RT-LAB documentation or contact Opal-RT Technologies support.
RTEVENTS_3_7_Q042011
RTE
10
Mask
Parameters
Conversion Type
Number of OP5110-
events
during a single step. Over this number, events are ignored and
not outputed.
Time Unit
Sample Time
input
RTEVENTS_3_7_Q042011
RTE
11
Input
Initial States
The initial state of each input vector. Only available when the
conversion type is RTE Boolean to OP5110-5120 Event
Generator.
Status (Double)
Output
Characteristics
Direct Feedthrough
Yes
Sample Time
Work offline
Yes.
Please note that the RT-LAB OP5110-5120 Event Generator/
Detector block doesn't receive/send events from the RT-LAB
OP5100 cards in offline simulation.
Dimensionalized
Yes
Example
The rte_event_detector.mdl and the rte_event_generator.mdl models shows how to connect
the RTE Conversion OP5110-5120 blocks to the Opal-RT OP5110-5120 event detector and
event generator blocks.
Related Items
RTE Conversion
RTEVENTS_3_7_Q042011
RTE
12
RTE Delay
Library
RT-Events Discrete
Block
Description
The RTE Delay block delays the RTE Boolean-type input by a variable amount of time. The
block accepts two inputs: the first input is the signal that passes through the block; the
second input is the time delay.
The Buffer size parameter defines the maximum number of events that can be store in the
internal buffer. The block clips events of the delay that exceed this size. The Buffer size must
be greater than or equal to zero.
During the simulation, the block stores events in an internal buffer. At the start of the
simulation, the block outputs the Initial state condition parameter until the simulation time
exceeds the time delay input. Then, at each simulation step the block outputs the signal at
the time that corresponds to the current simulation time minus the delay time.
The RTE Delay block also allows you to:
Ignore / Allow multiple output of same Event
Compensate for skipped events
Ignoring / Allowing multiple output of same event
The RTE Delay block, as mentionned above, outputs the input signal delayed by a variable
amout of time. When the time delay increase rapidly, it can occurs that some events are
output multiple time. By enabling the Ignore event output multiple times parameter, the
block can ignore events that should be output multiple time. Suppose for example a delay
block with an initial time delay of 0 second. Ater 2 seconds of simulation, the time delay
increase to 2 seconds. The following figure illustrates the effect of the parameter on the
output.
RTEVENTS_3_7_Q042011
RTE
13
Figure 6:Effect of the Ignore Events Output Multiple Time Parameter on the RTE Delay Block.
Figure 7:Effect of the Skipped Events Compensation on the RTE Delay Block.
Mask
RTEVENTS_3_7_Q042011
RTE
14
Parameters
multiple times
multiple time.
Skipped events
compensation
Initial Condition
Buffer size
Maximum number of
events
during a single step. Over this number, events are ignored and
not outputed.
Input
Delay (Double)
Delay signal
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
Yes
Output
Characteristics
Examples
The rte_encoder.mdl model demonstrates how to use RT-Events blocks to simulate an
incremental encoder connected to a rotating object. This example also shows how to use
blocks of the library to insert fault, to filter noise and to measure some characterics of RTE
Boolean signal. In this example the RTE Delay block is used to generate channel B of the
incremental encoder by delaying the channel A.
The rte_pwm_generation.mdl model demonstrates how to use RT-Events blocks to generate
PWM signals of different type. In this example the RTE Delay block is used to generate dead
time on the rising and falling edges of the two complementary signal of the PWM.
Related Items
RTEVENTS_3_7_Q042011
RTE
15
Block
Description
The RTE Events Generator block generates square pulses. At each calculation step, the block
must receive the following information about events: the number of events that occur, the
times and the values (transitions) of each event.
Mask
Parameters
RTEVENTS_3_7_Q042011
Maximum number of
events
during a single step. Above this number, events are not output.
Sample Time
RTE
16
Input
The vector of each event's time within the model sample time.
The values of time must be in the following range : [0 to
Sample Time].
Initial condition
The state of the RTE output signal before the first event.
(Double)
Number of events
(Double)
Output
Output (RTE)
Status (Double)
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
No
Characteristics
Examples
The rte_basic1.mdl model shows how to do simple operations on RTE signals. It also
demonstrates how to use the RTE Events Generator block to generate a repetitive sequence
of pulses.
Related Items
RTEVENTS_3_7_Q042011
RTE
17
RTE Filter
Library
RT-Events Math Operations
Block
Description
The RTE Filter block removes, from the input signal, pulses (pairs of opposite transitions)
that are smaller than a fixed width. The block can remove only high pulses (low-to-high and
high-to-low transitions), only low pulses (high-to-low and low-to-high transitions) or both
kinds of pulse. The following example demonstrates the effect of the filter block.
Limitation
The pulse width limit must be smaller than the inherited sample time of the block. Generally,
the filter block can correctly manage the removal of pulses with a witdh 10 times smaller
than the sample time.
When the filter block is set to remove only high pulses or low pulses, the block must delay
the first event if first event of a pulse occurs in the last T seconds of the calculation step,
where T is smaller than the pulse width, and the pulse is larger than pulse width limit.
This limitation is caused by the fact that the block cannot predict if a pulse with a transition
so close to the end of the step will be larger or smaller than the pulse width limit. The
following figure shows this effect on the output signal.
RTEVENTS_3_7_Q042011
RTE
18
Mask
Parameters
Pulse Type
Maximum Number of
Events
during a single step. Events above this number are not output.
Input (Double)
Output (Double)
Direct Feedthrough
Yes
Sample Time
Work offline
Yes
Dimensionalized
Yes
Input
Output
Characteristics
Example
The rte_encoder.mdl model demonstrates how to use RT-Events blocks to simulate an
incremental encoder connected to a rotating object. This example also shows how to use
RTEVENTS_3_7_Q042011
RTE
19
blocks of the library to insert fault, to filter noise and to measure some characterics of RTE
Boolean signal. In this example the RTE Filter block is used to remove noise that occurs on
real analog signals.
Related Items
RTEVENTS_3_7_Q042011
RTE
20
Block
Description
The RTE Frequency Meter block measures the frequency and the duty cycle of its input
signals. The duty cycle is the ratio of the time where the signal in High (Ton) on the signal
period.
The frequency and the duty cycle output signals can be measured between consecutive
rising edges or consecutive falling edges. When rising edge are selected, the measurement
starts and ends on rising edge. However, when falling edge are selected, the measurement
starts and ends on falling edge. The measurement between consecutive parameter allows to
select one of these two modes.
The minimum frequency parameter is used when the inputs signal is at very low frequency.
When the block didnt detect edges since a time greater than the specified period, the
frequency is set to zero and the duty cycle cycle.
When the frequency of the input signal is lower than the minimum frequency parameter and
the state of the input changes between Low or High value, the value of the duty cycle
change between 0 and 1 only if the input signal stay in the same state a time longer than
the minimum frequency. Moreover, depending on the Edge type for detection of minimum
frequency parameter and measurement between consecutive parameter, the reference time
tx where the inactive period start to be calculated is different:
When the edge type for detection parameter is either, the reference time is fixed at the time
of the last event of any type (rising or falling).
When the edge type for detection is automatic and the measurement is performed between
rising edge, the reference time is fixed at the time of the last rising edge.
When the edge type for detection is automatic and the measurement is performed between
falling edge, the reference time is fixed at the time of the last falling edge
In some systems this behavior can cause problem. The RTE Period Meter block has a
different algorithm to treat the duty cycle when the frequency is lower than the minimum
frequency.
RTEVENTS_3_7_Q042011
RTE
21
Mask
Parameters
Measurement between Determines if the period and frequency outputs are measure
consecutive
Minimum frequency
When the input signal frequency is lower than this value, the
frequency is 0 and the duty cycle is set to 0 or 1 depending of
the current state (Low or High) of the input signal.
detection of minimum
frequency
Input
Frequency (Double)
Output
RTEVENTS_3_7_Q042011
RTE
22
Characteristics
Direct Feedthrough
Yes
Sample time
Work Offline
Yes
Dimensionalized
Yes
Examples
None
Related Items
RTE Period Meter
RTEVENTS_3_7_Q042011
RTE
23
RTE Ground
Library
RT-Events Source
Block
Description
The RTE Ground block outputs an empty RTE Boolean-type signal. This signal contains no
events and is initialized with an undefined state.
This block can be used to connect blocks whose inport ports of RTE Boolean data type are
not connected to other blocks. If you run a simulation with blocks having unconnected input
ports, Simulink issues warning messages. Using this blocks to ground those blocks avoids
warning messages.
Mask
Parameters
Sample Time
Input
RTEVENTS_3_7_Q042011
RTE
24
Output
Direct Feedthrough
No
Sample time
Fixed discrete
Work offline
Yes
Dimensionalized
Yes
Characteristics
Example
Related Items
RTEVENTS_3_7_Q042011
RTE
25
RTE Insert
Library
RT-Events Math Operations
Block
Description
The RTE Insert block inserts N pulses in an RTE Boolean signal. The pulses are inserted
between N+1 consecutives pulses of the input signal. The offset parameter determines
where the pulses are inserted relative to the beginning of the cycle. The insertion is repeated
at every cycle of M pulses.
The pulse width and delay parameters characterize the inserted pulses. These parameters
are measured in percent of the last input signal period. The delay parameters is relative to
the end of the last pulse.
Here is a small example where the parameters N, M, width and delay are respectively
2,4,16% and 16%.
RTEVENTS_3_7_Q042011
RTE
26
The Insert block allow to choose where the pulses should be insert in the input signal. The
offset parameter determine an offset in pulses from the beginning of the cycle where the
pulse are inserted.
Reseting the cycle
The Insert block determine where the pulses should be insert relative to the first pulse of a
cycle. The external reset signal can reset the internal counter that determine the beggining
of a cycle. Each time an specified edge occur on the trigger input signal, the counter is
reseted to zero. The reset can be perform on rising edge, falling edge, or either.
Limitations
One of the limitation of this block occurs when the frequency of the input signal increases
rapidly and the next rising edge of the input signal occurs before the new pulses was
inserted. In this case, the input signal and the new pulse are combined with a logical AND.
Example:
Figure 21:Limitation of the RTE Insert Block When Frequency Increase Rapidly
In the extreme case where the time of the events of the new pulses exceed the time of the
falling edge of the next input pulse, the events are skipped.
Example:
Figure 22:Limitation of the RTE Insert Block When Frequency Increase Extremely Rapidly
RTEVENTS_3_7_Q042011
RTE
27
Mask
Parameters
Trigger type
Number of pulses to
insert
Number of pulses by
cycle
Offset
Pulse width
Delay
External Reset
Maximum Number of
events
Input
RTEVENTS_3_7_Q042011
RTE
28
External Reset
(Double)
Output
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
Yes
Characteristics
Example
The rte_encoder.mdl model demonstrates how to use RT-Events blocks to simulate an
incremental encoder connected to a rotating object. This example also shows how to use
blocks of the library to insert fault, to filter noise and to measure some characterics of RTE
Boolean signal. In this example the RTE Insert block is used to insert fault in the generated
pulse of the encoder.
Related Items
RTE Remove
RTEVENTS_3_7_Q042011
RTE
29
RTE Integrator
Library
RT-Events Discrete
Block
Description
The RTE Integrator block integrates the input signal and compensates for the discrete-time
error that takes place because of the occurrences of discrete reset events between the
sampling points. The output of the integrator is the result of the integration.
The integrator block also allows you to:
Select the integration methods.
Reset the integrator depending on a reset input.
Define the initial conditions and the source of the initial conditions in the
block dialog box.
Define upper and lower limits on the integral.
Selecting the integration methods
The block can integrate using these methods: Trapezoidal or RT-Events. For a given step k,
Simulink updates its output y(k) and state x(k+1). Ts is the sampling period. Values are
clipped according to upper or lower limits. In all cases, the initial output of the block is
always the initial condition.
Trapezoidal method. For this method, the integration 1/s is approximated by Ts/2*(z+1)/(z-1)
and the input ports have a direct feedthrough.
RT-Events method. For this method, the integration 1/s is approximated using a proprietary
relation. With this method, input ports have non-direct feedthrough. This method allows the
block to directly connect its outputs to inputs without using another block that has non-direct
feedthrough in the loop.
Resetting the State
The block can reset its state to zero (or to initial condition) based on an RTE Boolean reset
signal. To cause the block to reset its state, select one of the reset choices available in the
block dialog box.
Select rising to trigger the state reset when the reset signal has a rising edge. Select falling
to trigger the state reset when the reset signal has a falling edge. Select either to trigger the
reset when either a rising or a falling signal occurs.
RTEVENTS_3_7_Q042011
RTE
30
Mask
Parameters
Integrator Method
External Reset
RTEVENTS_3_7_Q042011
RTE
31
Initial Condition
Source
Initial Condition
Limit Output
Upper Saturation Limit The upper limit for the integral. The default is inf.
Lower Saturation Limit The lower limit for the integral. The default is -inf.
Sample time
Input (Double)
Signal to integrate.
Initial Condition
(Double)
Output (Double)
Direct Feedthrough
Sample Time
Fixed discrete.
Work offline
Yes
Dimensionalized
Yes
Input
Output
Characteristics
Example
The rte_resetwalk.mdl model shows the difference between a compensated event-based
discrete system, an uncompensated simulated event-based discrete system and a
continuous system and demonstrates the accuracy of the RTE blocks compare to the
equivalent discrete block.
Related Items
RTEVENTS_3_7_Q042011
RTE
32
RTE Latch
Library
RT-Events Discrete
Block
Description
The RTE Latch block stores in memory the value of the input signal each time an event
occurs in the trigger signal. The latch block outputs the last value stored in memory. The
value is held until the occurence of the next trigger event. The block compensates the error
due to events occuring between two samples.
The RTE Latch block enables you to:
Define initial condition of the output signal.
Latch on a rising, a falling or either edge.
Defining Initial Conditions
You can define initial condition as a parameter in the block dialog box or you can input them
from an external signal. To define the initial condition as a block parameter, specify the
Initial condition source parameter as internal and enter the value in the Initial condition
parameter field. To provide the initial condition from an external source, specify the Initial
condition source parameter as external. An additional input port appears under the block
input.
Trigger Type
The block can stores in memory its inputs only when specific event occur in the trigger
signal. The trigger type parameter allow to select the type of edge that cause the block to do
the storage:
Select rising to store the input when rising edges are detected.
Select falling to store the input when falling edges are detected.
Select eitherto store the input when rising or falling edges are detected.
RTEVENTS_3_7_Q042011
RTE
33
Mask
Parameters
Trigger Type
Initial condition
source
external.
Initial Condition
Sample Time
Input (Double)
Initial Condition
Input
(Double)
Output
Output (Double)
Latched signal.
Direct Feedthrough
Yes
Sample time
Fixed discrete
Work offline
Yes
Dimensionalized
Yes
Characteristics
RTEVENTS_3_7_Q042011
RTE
34
Example
The rte_engine.mdl model demontrates the precision of the RTE blocks compare to the
Simulink discrete blocks in the context of a combustion engine. The firing of the combustion
is an events based behaviour and necessitate the use of RT-Events to be simulated correctly
in discrete sample time.
In this example the RTE Latch block is used to simulated the compression phase of the
combustion cycle of the engine.
Related Items
RTE Latch Delay
RTEVENTS_3_7_Q042011
RTE
35
Block
Description
The RTE Latch Delay block stores in memory the value of the input signal each time an event
occurs in the trigger signal. The latch block outputs the value stored in memory when the
events that preceds the last event occurs. The output value is held until the occurence of the
next trigger event. The block compensates the error due to events occuring between
samples.
The RTE Latch Delay block enables you to:
Define initial conditions in the block dialog box or as an input to the block.
Latch on rising, falling or either edge.
Defining Initial Conditions
You can define initial conditions as parameters in the block dialog box or you can input them
from an external signals. To define the initial condition as block parameters, specify the
Initial condition source parameter as internal and enter the value in the Initial condition
parameter fields. To provide the initial condition from external sources, specify the Initial
condition source parameter as external. Additional input ports appears under the block
input.
Trigger Type
The block can stores in memory its inputs only when specific edge occur in the trigger signal.
The trigger type parameter allow to select the type of edge that cause the block to do the
storage:
Select rising to store the input when rising edges are detected.
Select falling to store the input when falling edges are detected.
Select eitherto store the input when rising or falling edges are detected.
RTEVENTS_3_7_Q042011
RTE
36
Mask
Parameters
Trigger Type
Initial condition
source
external.
Initial Condition 1
Initial Condition 2
Values outputs after the first edge is detected and before the
second edge is detected.
Sample Time
Input (Double)
Initial Condition 1
Input
(Double)
Initial Condition 2
Value outputs after the first edge is detected and before the
(Double)
Ouput (Double)
Latch signal.
Output
RTEVENTS_3_7_Q042011
RTE
37
Characteristics
Direct Feedthrough
Yes
Sample time
Fixed discrete
Work offline
Yes
Dimensionalized
Yes
Example
The rte_engine.mdl model demontrates the precision of the RTE blocks compare to the
Simulink discrete blocks in the context of a combustion engine. The firing of the combustion
is an events based behaviour and necessitate the use of RT-Events to be simulated correctly
in discrete sample time.
In this example the RTE Latch block is used to simulated the compression phase of the
combustion cycle of the engine.
Related Items
RTE Latch
RTEVENTS_3_7_Q042011
RTE
38
Block
Description
The RTE Logical Operator blocks performs the following logical operations on their inputs
with compensation for transitions occurring between the time steps: and, or, not, nand, nor,
xor.
The number of input ports is specified with the Number of input ports parameters. The size
of the output depends on input vector size and the selected operator:
If the block has more than one input, any nonscalar inputs must have
the same dimensions. For example, if any input is a 2-by-1 vector, all
other inputs must also be 2-by-1 vectors.
If the block has more than one input, the output has the same
dimensions as the inputs and each output element is the result of
applying the specified logical operation to the corresponding input
elements. For example,if the specified operation is AND and the inputs
are 2-by-1 vector, the output is a 2-by-1 vector whose first element is
the result of applying the AND to the first elements of the inputs, etc.
For a single vector input, the block applies the operation (except the
NOT operator) to all element of the vector. The output is always a
scalar.
The NOT operator accepts only one input, which can be a scalar or a
vector. If the input is a vector, the output is a vector of the same size
containing the logical complements of the input vector elements.
The Maximum number of events parameter is used to determine the maximum number of
transition that can occurs during one calculation step and that can be store in the output
signals. For example, if the specified operations is OR and the number of ports is 2 and the
port widths are 1. Also suppose that both input signals contain two events during one
calculation step as in the following figure:
By specifying a maximum number of four events, all transition above
will be output.
RTEVENTS_3_7_Q042011
RTE
39
Mask
Parameters
Operator
Maximum Number of
events
Input
Output
Characteristics
RTEVENTS_3_7_Q042011
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
Yes
RTE
40
Example
The rte_basic1.mdl model shows how to do simple operations on RTE signals. It also
demonstrates how to use the RTE Logical Operator block.
The rte_pwm_generation.mdl model demonstrates how to use RT-Events blocks to generate
PWM signals of different type. In this example the RTE Logical Operator block is used to
generate PWM signals by comparing two signals : the carrier and the modulation signal.
Related Items
RTEVENTS_3_7_Q042011
RTE
41
Block
Description
The RTE Period Meter block measures the period and frequency of its input signals. It can
also measures the duty cycle and the duration of its high state (Ton) or low state (Toff).
The period and frequency output signals can be measured between consecutive rising edges
or consecutive falling edges. The measurement between consecutive parameter allows to
select one of these two modes.
The duty cycle, Ton and Toff outputs can be calculated during one calculation step or during
one signal period interval. When calculation step is selected, the times Ton and Toff are
values between 0 and the calculation step. The duty cycle is the ratio of the time Ton on the
calculation step. When signal period interval is selected, the Ton and Toff outputs are values
between 0 and the signal period. The duty cycle is the ratio of the time Ton on the signal
period. The measurement during one parameter allows the selection of these two modes.
The following two figures present the difference between Signal Period and Calcultaiton Step
modes.
Figure 33:Signal Period Operation Mode of the RTE Period Meter Block
Figure 34:Calculation Step Operation Mode of the RTE Period Meter Block
The minimum frequency parameter is used when the inputs signal is at very low frequency.
When the block has not detect edges since a time greater than the inactive period condition,
the measured period and frequency are set respectively to infinite and zero.
RTEVENTS_3_7_Q042011
RTE
42
When the frequency of the input is lower than the minimum frequency parameter, also note
that the value of the duty cycle changes instantaneously between 0 and 1 depending of the
logic level (Low or High) of the input signal. In some systems this behavior can cause
problem. The RTE Frequency Meter block has a different algorithm to treat the duty cycle
when the frequency is lower than the minimum frequency.
Mask
Parameters
Display Period
Display Frequency
Measurement between Determines if the period and frequency outputs are measure
consecutive
Display Ton
Display Toff
Measurement during
one
Minimum frequency
When the input signal frequency is lower than this value, the
output frequency and period are 0 and Inf.
RTEVENTS_3_7_Q042011
RTE
43
Input
Period (Double)
Frequency (Double)
Ton (Double)
Toff (Doule)
Direct Feedthrough
Yes
Sample time
Work Offline
Yes
Dimensionalized
Yes
Output
Characteristics
Examples
The rte_encoder.mdl model demonstrates how to use RT-Events blocks to simulate an
incremental encoder connected to a rotating object. This example also shows how to use
blocks of the library to insert fault, to filter noise and to measure some characterics of RTE
Boolean signal. In this example the RTE Period Meter block is used to measure the frequency
of the incremental encoder.
Related Items
RTE Signal Attributes, RTE Probe Events, RTE Frequency Meter
RTEVENTS_3_7_Q042011
RTE
44
Block
Description
The RTE Probe Events block outputs event's attributes, including time, state, initial state,
number of events and status.The outputs of this block are the information from RTE signals
in the last calculation step.
The block allows displaying the state and time of any events that occur during a calculation
step. The element indices specify which events will be output. This output is a vector with a
dimension ranging from 1 to the maximum number of events contained in an RTE signal.
Mask
Parameters
Source of element
indices
Element Indices
RTEVENTS_3_7_Q042011
RTE
45
Input
Inputs (RTE)
Element Indices
(Double)
of element is external.
Output
Initial Condition
(Double)
calculation step.
Number of events
(Double)
Status (Double)
Direct Feedthrough
Yes
Sample Time
Work offline
Yes
Dimensionalized
No
Characteristics
Example
The rte_basic1.mdl model shows how to do simple operations on RTE signals. It also
demonstrates how to use the RTE Probe Events to display some event properties of an RTE
signal.
Related Items
RTE Signal Attributes, RTE Period Meter
RTEVENTS_3_7_Q042011
RTE
46
RTE PWM
Library
RT-Events Source
Block
Description
The RTE PWM block generates square wave pulses at regular time intervals. The frequency
and duty cycle input signals determine the shape of the output waveform.
The RTE PWM block can output scalar, vector, or matrix signals. To cause the block to output
a scalar signal, use scalars input signals. To cause the block to output a vector or matrix
signal, use vectors or matrices inputs signals, respectively. Each element of the input signals
affects the corresponding element of the output signal. All the input signals must have the
same dimensions after scalar expansion. The following figure presents the main
characteristics of the generates square wave pulses.
Figure 39:Square Wave Characteristics of the Generated Signals of the RTE PWM Block
The Maximum number of events parameter is used to determine the maximum number of
transition that can occurs during one calculation step and the maximum frequency that can
be output. The following formula determine the maximum frequency:
Fmax = Num / ( 2 *Ts),
where Num and Ts are the maximum number of events and the block sample time.
Shifted transitions
In normal operation, the frequency changes will be update from the previous value when the
active period (cycle) is completed. This gives very precise results without frequency spikes.
However, at low frequencies, this slows down the update time as we need to wait for the first
(slow) period to finish before moving to the next frequency value.
When shifting is enabled, the output of the RTE PWM block will be similar to real-world
sensors in that the transition will happen as soon as possible in order to move to the new
RTEVENTS_3_7_Q042011
RTE
47
frequency value. This might be interpreted as a shift from the old value to the new one with
a half period at one intermediate frequency. This is closer to the behavior of real sensors and
provides faster updates at low frequency, but can confuse some hardware devices.
As an example, suppose a Simulink model containing a pulse generator with a frequency of
250 Hz running at a sample time of 1ms. When the shifted transition is disabled and the
frequency is increased to 1000 Hz, the block waits until the next transition at 250 Hz to
update the frequency. The next transition is set as the reference. If the shifted transition is
enabled, the blocks use instead the previous transition as reference.
Figure 40:Effect of the Shifted Transition Parameter of the RTE PWM block
Mask
Parameters
Shifted transition
Maximum number of
events
Sample time
Frequency (Double)
Input
RTEVENTS_3_7_Q042011
RTE
48
Output
Direct Feedthrough
No
Sample Time
Fixed discrete.
Work Offline
Yes
Dimensionalized
Yes
Characteristics
Examples
The rte_pwm_generation.mdl model demonstrates how to use RT-Events blocks to generate
PWM signals of different type. This example also shows how to add dead time to the PWM
and also shows how to generate Space Vector PWM using this block. It also compares many
method to generate PWM using RTE Logical Operator block, or RTE SVPWM block.
Related Items
RTE SPWM
RTEVENTS_3_7_Q042011
RTE
49
RTE Queue
Library
RT-Events Math Operations
Block
Description
The RTE Queue block stores in memory the times and states of all events that occur on the
RTE Boolean-type input signal. It can also stores values of Double-type input signals when
events occur on the RTE Boolean signal. The block capacity is set by Queue size.
When a value of 1 is received at the Pop port, the block pops all elements off the queue at
the next simulation step and holds the outports at that values until the next pop trigger.
The following figure shows how the queue works.
RTEVENTS_3_7_Q042011
RTE
50
A value of 1 at the optional Clr port (enabled by the Clear queue input check box) empties
the queue contents at the next simulation step.
When two or more of the control input ports are triggered at the same time step, the
operations are executed in the following order: Push, Clr, Pop.
The block allows to output signals indicating the states of the queue. When the Empty Queue
Output parameter is selected the block output 1 when the queue is empty. When the Full
Queue Output parameter is selected the block output 1 when the queue is full. When the
Output Number of Queued Events is selected the block output the number of events store in
the queue.
The block can stores the values of Double-type input signals when the value of the Number
of Input parameter is greather than 0. The block can interpolate the inputs at the time that
occurs the events (enabled by the Interpolate Input check box). If this option is not selected
the block store the value of the input signal at the beginning of the time step.
Mask
Parameters
RTEVENTS_3_7_Q042011
Queue Size
Full QueueOutput
RTE
51
Number of queued
events
queue.
Number of Inputs
Interpolate Inputs
Input
Pop (Double)
Trigger signal used to pop out all events of the queue (1=Pop,
0=No effect).
Clr (Double)
Signal N (Double)
Times (Double)
States (Double)
Empty (Double)
Full (Double)
Num (Double)
Signal N (Double)
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
No
Output
Characteristics
Examples
Related Items
RTEVENTS_3_7_Q042011
RTE
52
Block
Description
The RTE Rate Transition block handles transfer of data between blocks operating at different
rates. It transfers data from the output of a block operating at one rate to the input of
another block operating at a different rate. This block is used to exchange data between two
real-time subsystems working at different rates in RT-LAB simulator. See the first two
examples in the example section.
The behaviour of the Rate Transition block depends on the sample times of the ports
between which it is connected. The block acts as a zero-order hold block or acts as a unit
delay block. In the zero-order hold block mode, the block transfers data from a fast rate to a
slow rate. In the unit delay mode, the block transfers data from a slow rate to a fast rate.
The following figure illustrates the two general cases.
The color scheme in Figure 46 comes from Simulink software's sample-time colors feature
(select Sample Time Colors from the Format menu). When the option is activated, the blocks
and lines in the model are colored according to the sample rates at which the blocks operate.
The table below lists this color code:
RTEVENTS_3_7_Q042011
Color
Use
Black
Continuous blocks
RTE
53
Magenta
Constant blocks
Yellow
Red
Green
Blue
Light Blue
Dark Green
Orange
Cyan
Grey
Figure 47:Effect of the Skipped Events Compensation on the RTE Delay Block.
Suppose now a "Slow to Fast" transition with the MaxEvent parameter set to 3. The fast rate
is set to 1 second and the slow rate is set to 2 seconds. The following figure illustrates the
effect of the compensation. When the compensation is enabled, the sixth event (falling
edge) of the input (corresponding to fourth event of the of the second step of the output) is
compensated at the beginning of the third "fast" time step. When the compensation is
disabled, note also that the block skips the first event to be output in the third step since the
output is already in this state.
RTEVENTS_3_7_Q042011
RTE
54
In Slow-to-Fast transition, data transfers occur as soon as new data is available from the
source block and the receiving block is ready to receive the data. Data are available at the
next fast step.
Mask
Parameters
Skipped events
compensation
Maximum number of
events
RTEVENTS_3_7_Q042011
RTE
55
Input
Output
Characteristics
Direct Feedthrough
Sample time
Fixed discrete
Work offline
Yes
Dimensionalized
Yes
Examples
The next two examples show how to exchange RT-Events signals between two real-time
subsystems running with RT-LAB. The example illustrates data exchange from fast-to-slow
rate and slow-to-fast rate respectively.
Fast to Slow transition
The following example illustrates Fast-to-Slow transition between 2 subsystems (Also
available on MatLab demos). Consider the model below:
RTEVENTS_3_7_Q042011
RTE
56
In this figure, the Master sample time is set to 1 seconds and the Slave sample time is set to
2 second.
RTEVENTS_3_7_Q042011
RTE
57
In the first figure, the Master sample time is set to 2 seconds and the Slave sample time is
set do 1 second.
Figure 52:RTE Rate Transition - Slow to Fast in nominal case (TsMaster = 2TsSalve)
In the second figure, the Master sample time is set to 3 seconds and the Slave sample time
is set do 1 second.
Figure 53:RTE Rate Transition - Slow to Fast in nominal case (TsMaster = 3TsSalve)
RTEVENTS_3_7_Q042011
RTE
58
Related Items
N/A
RTEVENTS_3_7_Q042011
RTE
59
Block
Description
The RTE Relational Operator block performs a relational operation on its two inputs and
outputs the results as an RTE Boolean-type signal. The logical operation on the inputs can be
selected, e.g. one can choose among <, >, >= and <=. It should be noted that the output
signal is high when the condition is true. The RTE Boolean signal contains information to
allow the blocks to compensate the discrete-time error that takes place because discrete
events occur between the sampling instants.
Mask
Parameters
Operator
RTEVENTS_3_7_Q042011
RTE
60
Maximum Number of
events
Sample Time
Inputs (Double)
Input
Output
Outputs (RTE Boolean) RTE logical signal which is high when the condition is true.
Characteristics
Direct Feedthrough
Yes
Sample time
Fixed discrete.
Work offline
Yes
Dimensionalized
Yes
Example
The rte_resetwalk.mdl model shows the difference between a compensated event-based
discrete system, an uncompensated simulated event-based discrete system and a
continuous system and demonstrates the accuracy of the RTE blocks compare to the
equivalent discrete block.
Related Items
RTEVENTS_3_7_Q042011
RTE
61
RTE Remove
Library
RT-Events Math operations
Block
Description
The RTE Remove block removes N pulses of an RTE Boolean-type signal. The deletion is
repeated at every cycle of M pulses.
Here is a small example where the parameters N and M are respectively 2 and 4.
RTEVENTS_3_7_Q042011
RTE
62
The RTE Remove block determines which pulses it should remove relative to the first pulse of
a cycle. The external reset signal can reset the internal counter that determine the beggining
of a cycle. Each time an specified edge occur on the trigger input signal, the counter is
reseted to zero. The reset can be perform on rising edge, falling edge, or either.
Mask
Parameters
Trigger type
Number of pulses to
remove
Number of pulses by
cycle
Offset
External Reset
Maximum Number of
events
External Reset
Input
(Double)
RTEVENTS_3_7_Q042011
RTE
63
Output
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
Yes
Characteristics
Example
The rte_encoder.mdl model demonstrates how to use RT-Events blocks to simulate an
incremental encoder connected to a rotating object. This example also shows how to use
blocks of the library to insert fault, to filter noise and to measure some characterics of RTE
Boolean signal.
The RTE Insert block is very similar to the RTE Remove block and is used to insert fault in
the generated pulse of the encoder.
Related Items
RTE Insert
RTEVENTS_3_7_Q042011
RTE
64
RTE Scope
Library
RT-Events Sink
Block
Description
The RTE Scope block displays signals generated during a simulation. The block can have
multiple axes (one per port); all axes have a common time range with independent y-axes.
The scope allows you to adjust the amount of time and the range of input values displayed.
You can move and resize the scope window.
If the signal is continuous, the scope produces a point-to-point plot. If the signal is discrete,
the Scope produces a stair-step plot.
To provide a more stable display, the block has an option called the trigger. This options
causes the scope to pause after reaching the right hand side of the screen, and wait for a
specified event before returning to the left hand side of the screen and drawing the next
trace. The effect is to resynchronise the timebase to the input signal, preventing horizontal
drift of the scope. Trigger scope allow the display of nonperiodic signals such as single
pulses, as well as periodic signals such as sine waves and square waves.
The Scope provides toolbar buttons that enable you to zoom in on displayed data, display all
the data input to the Scope, preserve axis settings from one simulation to the next, limit
data displayed, save data to the workspace and select and display specific time range. The
toolbar buttons are labeled in this figure, which shows the Scope window as it appears when
you open a Scope block. For more help on these features see the Simulink Scope
documentation.
RTE
65
Mask
Parameters
External Trigger
Set the kind of trigger use to trigger the scope. Select None to
disable this feature or any other values to activate this feature.
Double or RTE Boolean signal can be use to trigger the scope.
When RTE Boolean signal is used to trigger the scope, the
synchronization can occur anywhere in the calculation step.
Number of Axes
Time Range
Save Data to
Workspace
RTEVENTS_3_7_Q042011
RTE
66
Variable Name
Format
You can limit the number of data points saved to the workspace
Last Events
Number of Points
Discretization of
Continuous Signals
Inputs
Signals to display.
External Trigger
Direct Feedthrough
No
Sample Time
No
Work Offline
Yes
Dimensionalized
Yes
Input
Output
Characteristics
Example
The rte_encoder.mdl model demonstrates how to use RT-Events blocks to simulate an
incremental encoder connected to a rotating object. This example also shows how to use
blocks of the library to insert fault, to filter noise and to measure some characterics of RTE
Boolean signal.
In this example, the RTE Scope block is used to display simulated signals. For more
examples consult RT-Events demos.
Related Items
RTEVENTS_3_7_Q042011
RTE
67
Block
Description
The RTE Signal Attributes block outputs the specified attribute of the input signal. The
available attributes are: width, size, number of events, maximum number of events, initial
state, final state and status.
Mask
Parameters
Attribute
Input
RTEVENTS_3_7_Q042011
RTE
68
Output
Attribute (Double)
Direct Feedthrough
Yes
Sample Time
Work offline
Yes
Dimensionalized
Yes
Characteristics
Example
The rte_basic1.mdl model shows how to do simple operations on RTE signals. It also
demonstrates how to use the RTE Signal Attributes block to display the number of events
that occur on an RTE signal.
Related Items
RTE Period Meter, RTE Probe Events
RTEVENTS_3_7_Q042011
RTE
69
RTE SPWM
Library
RT-Events Source
Block
Description
The RTE SPWM block generates square wave pulses at regular time intervals. The frequency
and duty cycle of the input signals determine the shape of the output waveform.
The figure below shows the main characteristics of the generated square wave pulses. T,
Ton, Toff, D and f are the period, the time on, the time off, the duty cycle, and the frequency
of the PWM signal respectively.
The RTE SPWM block outputs scalar or vector signals depending on the number of phases
selected in the parameters dialog box. When multiple phases are selected, the duty cycle
must be provided for all the phases, and the duty cycle inport takes a vector of the same
width as the number of phases. Also note that the frequency input is applied to all the
phases.
Center alignement mode
The RTE SPWM block lets you specify to choose the PWM pulses alignement. Depending on
the application, it may be important to output the pulse at the beginning of the period, or to
output the pulse centered relatively to the PWM period. The figure below shows the 2
supported modes. The parameters dialog box allows to select the alignment mode using the
Center alignment mode parameter.
RTEVENTS_3_7_Q042011
RTE
70
Note that this option is only available when complementary mode is selected.
Maximum number of events
The Maximum number of events parameter is used to determine the maximum number of
transitions that can occur during one calculation step and the maximum frequency that can
be output by the PWM block. The following formula determines the maximum frequency:
Fmax = Num / ( 2 * Ts),
where Num and Ts are the maximum number of events and the block sample time.
RTEVENTS_3_7_Q042011
RTE
71
Mask
Number of phases
Center alignment
mode
Maximum frequency
Minimum frequency
Complementary PWM
RTEVENTS_3_7_Q042011
RTE
72
Maximum Number of
events
Sample time
Frequency (Double)
Input
phases.
Duty Cycle (Double)
The enable port controls when the block is executed. See Show
enabling port parameter above.
Output
Complementary PWM
(RTE Boolean)
block.
Direct Feedthrough
No
Sample Time
Fixed discrete.
Work Offline
Yes
Dimensionalized
No
Characteristics
Examples
The rte_pwm_generation.mdl model demonstrates how to use RT-Events blocks to generate
PWM signals of different type. This example also shows how to add dead time to the PWM
and also shows how to generate Space Vector PWM using this block. It also compares many
method to generate PWM using RTE Logical Operator block, or RTE PWM block.
Related Items
RTE PWM
RTEVENTS_3_7_Q042011
RTE
73
RTE Switch
Library
RT-Events Signal Routing
Block
Description
The RTE Switch block passes through the first input or the third input based on the value of
the second control input. When the control input is an RTE signal, the switch also
compensates for events that occur during calculation step.The second input is called the
control input.
You select the conditions under which the first input is passed with the Criteria for passing
first input parameter. You can make the block check whether the control input is greater
than or equal to the threshold value, purely greater than the threshold value, or nonzero. If
the control input meets the condition set in the Criteria for passing first input parameter,
then the first input is passed. Otherwise, the third input is passed.
Mask
RTEVENTS_3_7_Q042011
RTE
74
Parameters
Select the conditions under which the first input is passed. You
first input
can make the block check whether the control input is greater
than or equal to the threshold value, purely greater than the
threshold value, or nonzero. If the control input meets the
condition set in this parameter, then the first input is passed.
Otherwise, the third input is passed.
Threshold
Interpolate
Maximum number of
events
during a single step. Over this number, events are ignored and
not outputed.
Input
u1
u2
u3
Output
Output signal
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
Yes
Output
Characteristics
Examples
The rte_resetwalk.mdl model shows the difference between a compensated event-based
discrete system, an uncompensated simulated event-based discrete system and a
continuous system and demonstrates the accuracy of the RTE blocks compare to the
equivalent discrete block.
In this example, the RTE Switch block is used to activate or desactivate the RT-Events
compensation. When the compensation is enabled, the RT-Events system give the same
result as the continuous system. When the compensation is disabled, the RT-Events system
give the same erronous result as the discrete system.
Related Items
RTEVENTS_3_7_Q042011
RTE
75
RTE Sum
Library
RT-Events Math Operations
Block
Description
The RTE Sum blocks adds or substracts inputs. This block can add or subtract scalar or
vector. You specify the operations of the block with the List of Signs parameter. Plus (+) and
minus (-) characters indicate the operations to be performed on the inputs:
If there are two or more inputs, then the number of characters must equal the number of
inputs. For example, "+-+" requires three inputs and configures the block to subtract the
second (middle) input from the first (top) input, and then add the third (bottom) input.
All nonscalar inputs must have the same dimensions.
If only one vector is input, then a single "+" or "-" will collapse the vector using the specified
operation.
Mask
Parameters
List of signs
Enter as many plus (+) and minus (-) characters as there are
inputs.
RTEVENTS_3_7_Q042011
RTE
76
Maximum number of
events
during a single step. Over this number, events are ignored and
not outputed.
Input
Direct Feedthrough
Yes
Sample time
Work offline
Yes
Dimensionalized
Yes
Output
Characteristics
Examples
The rte_basic1.mdl model shows how to do simple operations on RTE signals. It also
demonstrates how to use the RTE Sum block to perform a sum of two RTE Double signal.
Related Items
RTEVENTS_3_7_Q042011
RTE
77
RTE-Drive ABC-DQ
Library
RTE-Drive Measurements
Block
Description
The RTE-Drive ABC-DQ block performs the abc to dq transformation on a set of three-phase
signals. It computes the direct axis Vd and quadratic axis Vq quantities in a two axis rotating
reference frame according to the following transformation:
Vd = [ cos() * (2*Vab+Vbc) + sqrt(3) * Vbc *sin()] / 3
Vq = [ sin() * (2*Vab+Vbc) - sqrt(3) * Vbc *cos()] / 3
The transformation is the same for the case of a three-phase current; you simply replace the
Va, Vb, Vc, Vd and Vq variables with the Ia, Ib, Ic, Id, and Iq variables.
Mask
Parameters
RTEVENTS_3_7_Q042011
RTE
78
Input
(Double)
q,d (Double)
Direct Feedthrough
Yes
Sample Time
Work Offline
Yes
Dimensionalized
Yes
Output
Characteristics
Example
Related Items
RTEVENTS_3_7_Q042011
RTE
79
Block
Description
This block implements a 3-phase permanent magnet synchronous machine with sinusoidal
flux distribution. The machine is modelled in the park D-Q rotor reference frame. Stator
windings are connected in wye to an internal neutral point.
Mask
Parameters
Vabc [V]
Input
we (rad/s)
Electrical speed
(= mechanical speed x number_of_poole_pair).
the (rad)
RTEVENTS_3_7_Q042011
RTE
80
Iabc (A)
Motor currents.
Iq, Id (H)
Vq, Vd (V)
Direct Feedthrough
No
Sample Time
Work Offline
Yes
Dimensionalized
No
Output
Characteristics
Example
None
Related Items
RTE-Drive Park D-Q PMSM
RTEVENTS_3_7_Q042011
RTE
81
Block
Description
This block implements a 3-phase permanent magnet synchronous machine with sinusoidal
flux distribution. The machine is modelled in the park D-Q rotor reference frame. Stator
windings are connected in wye to an internal neutral point.
Note that the mathematical model is valid for fixed Lq and Ld parameters. The RTE-Drive
Full Park D-Q PMSM provided a mathematical model that solves this problem.
Mask
Parameters
RTEVENTS_3_7_Q042011
RTE
82
Input
Vabc [V]
we (rad/s)
the (rad)
Iabc (A)
Motor currents.
Iq, Id (H)
Vq, Vd (V)
Direct Feedthrough
No
Sample Time
Work Offline
Yes
Dimensionalized
No
Output
Characteristics
Example
None
Related Items
RTE-Drive Full Park D-Q PMSM
RTEVENTS_3_7_Q042011
RTE
83
Block
Description
This block implements a permanent magnet synchronous machine model using a phase
domain representation model.
Mask
Parameters
84
Electric frequency
The model base frequency. Note that the base choice will not
base [Hz]
Number of Pair of
Poles
Open phase resistance
[ohms]
Vabc [V]
Bemf [V]
Input
Rstator [ohms]
OpenStator
Output
Iabc [A]
Vneutral [V]
Direct Feedthrough
No
Sample Time
Work Offline
Yes
Dimensionalized
No
Characteristics
Example
None
Related Items
RTE-Drive Phase Domain PMSM Inductance
RTEVENTS_3_7_Q042011
RTE
85
Block
Description
This block computes the phase domain time varying inductance matrix of a permanent
magnet synchronous machine corresponding to the Ld Lq Park transform inductances and
rotor angle.
Mask
Parameters
RTEVENTS_3_7_Q042011
RTE
86
Electric frequency
The model base frequency. Note that the base choice must be
base [Hz]
Number of Pair of
Poles
Sample Time [s]
Lq [H]
Ld [H]
SinCos
Input
Note: The Ld and Lq value correspond to the Krause Park transformation in which, for
positive speed, the q-axis is ahead of the d-axis and the Park transform has 2/3 factor and
all positive sign (no negative row).
Output
Lx [pu]
Characteristics
Direct Feedthrough
Yes
Sample Time
Work Offline
Yes
Dimensionalized
No
Example
None
Related Items
RTE-Drive Phase Domain PMSM
RTEVENTS_3_7_Q042011
RTE
87
Block
Description
The RTE-Drive Quadrature Decoder block outputs the relative angular position of a
quadrature incremental encoder using its signals A and B. This block also outputs the
direction of rotation of the rotating object.
The optional Z input signals is an indication that the rotating object has passed through a
reference point. This signal is used to reset the relative angular position to zero degree. This
signal is not yet available.
RTEVENTS_3_7_Q042011
RTE
88
Mask
Parameters
Number of pulses by
revolution
complete revolution.
Angle units
Use channel Z
Input
Channel A (RTE
Boolean)
Channel B (RTE
Boolean)
Channel Z (RTE
Boolean)
Output
Position (Double)
Direction (Double)
Direct Feedthrough
Yes
Sample Time
Work Offline
Yes
Dimensionalized
Yes
Characteristics
RTEVENTS_3_7_Q042011
RTE
89
Example
The rte_basic_quadrature_decoder.mdl model simulated the behaviour of an incremental
encoder and shows the relative position of the rotating object.
Related Items
The rte_encoder.mdl model demonstrates how to use RT-Events blocks to simulate an
incremental encoder connected to a rotating object. This example also shows how to use
blocks of the library to insert fault, to filter noise and to measure some characterics of RTE
Boolean signal. In this example the RTE Quadrature decoder block is used to measure the
angular position and direction of the rotating object.
RTEVENTS_3_7_Q042011
RTE
90
Block
Description
The RTE-Drive 2-Level Time Stamped Bridge (TSB) block implements a 2-level (2-switch)
bridge for which the gates are controlled by RTE Boolean signals. The number of arms in
parallel can by selected from 1 to 3. The bridge models IGBT/GTO/MOSFET devices
controlled by ideal switch with their anti parallel diode. The following figure presents the
equivalent electrical circuit of the RTE-Drive TSB 2- Level block.
The switch model is simulated as a resistor Ron and a DC voltage source Vf, connected in
series with a switch. The switch is controlled by the gate signal g.
When the upper switch or upper anti-parallel diode conducts, the Vabc output equals the Vdc
input (minus internal voltage drops). When the lower switch or diode of the leg conducts,
the Vabc output is equal to 0 (plus internal voltage drops). This load, that has a voltage-input
current-output causality (like an inductance), outputs a current which in fed to the Iabc
input.
The Idc output is computed from all the upper switches or diodes conduction times.
RTEVENTS_3_7_Q042011
RTE
91
Mask
Parameters
Number of bridge
arms
Voltage output data
type
Ron
Forward voltage Vf
Maximum number of
events
Input
The following table presents the input signals of the block when the voltage output data type
parameter is Simulink.
Vdc (Double)
RTEVENTS_3_7_Q042011
RTE
92
Iabc(Double)
The following table presents the input signals of the block when the voltage output data type
parameter is SimPowerSystems.
dc + (SPS)
Positive DC-link.
dc - (SPS)
Negative DC-link
Output
The following table presents the input signals of the block when the voltage output data type
parameter is Simulink.
Vabc (Double,
RTE Double)
The voltage at the middle point of the bridge which feeds the
load. The signal data type depends on the output data type
parameter.
Idc (Double)
The following table presents the input signals of the block when the voltage output data type
parameter is SimPowerSystems.
A, B, C (SPS)
Characteristics
Direct Feedthrough
Yes
Sample Time
Work offline
Yes
Dimensionalized
Yes
Limitations
Absence of switch gate signals
The block is not accurate when simulating the effect of completely shutting off all IGBT gate
pulses, like in emergency shutdown for example. This has the effect of letting the antiparallel diode turn on/off naturally, a case for which the Time Stamped Bridge is not
designed.
Input to output delay
RTEVENTS_3_7_Q042011
RTE
93
Since RT-Events version 3.3.x, optimizations in Time-Stamp Bridges have been made to
reduce the input to output delay due to Simulink-SPS interfacing. This optimization does
concern the TSB when the Output Data Type parameter is SimPowerSystems.
Because the Time-Stamp Bridge has a switching function for which the outputs are directly
dependant on the inputs, algebraic loops need to be broken when connecting it in the
SimPowerSystems mode, which is obtained through forcing single time-step delays at the
input(s) or the output(s) of the model. The optimization implies the displacement of the
simulation delays from the output AC voltage(s) and DC current(s) to the input DC
voltage(s) and AC current. This modification allows for better simulation of a strong majority
of applications where a constant voltage is found on the DC bus(ses) (or the time constant
of the DC voltage is small compare to the time step), due to a fixed voltage source or control
actions.
Example
The following figures presentes a simple 2-level chopper circuit and its Simulink
implementation. Refer to the rte_2level_chopper.mdl example file. The IGBT are driven at
fixed frequency of 10kHz and the simulation time step is 10 s. The upper part of the
Simulink model is the time stamped bridge implementation of the chopper while the bottom
part is the SimPowerSystem implementation.
RTEVENTS_3_7_Q042011
RTE
94
With those parameters, the duty cycle of the chopper has been scanned, that is the ratio of
the upper IGBT conduction time by the chopper frequency. The following figure shows the
result of scanning the duty-cycle of the chopper for the time stamping technique vs.
SimPowerSystem blockset technique. While both techniques have the same response at 0.1
s simulation time step, they differ a lot at 10 s: the SimPowerSystem exhibits strong nonlinearity (red curve) while the time stamped bridge model is still linear (blue curve). The
time stamped bridge is as precise as reference simulations made at 0.1 s.
RTEVENTS_3_7_Q042011
RTE
95
Figure 91:Current Load versus Duty Cycle of the 2-Level Chopper Circuit
Related Items
RTE-Drive 3-Level TSB
RTEVENTS_3_7_Q042011
RTE
96
Block
Description
The RTE-Drive 3-Level Time Stamped Bridge (TSB) block implements a 3-level (3-switch)
bridge for which the gates are controlled by RTE Boolean signals. The number of arms in
parallel can by selected from 1 to 3. The bridge models IGBT/GTO/MOSFET devices
controlled by ideal switch with their anti-parallel diode. The following figure presents the
equivalent electrical circuit of the RTE-Drive TSB 3- Level block with 3 arms.
The switch model is simulated as a resistor Ron and a DC voltage source Vf, connected in
series with a switch. The switch is controlled by the gate signal g.
RTEVENTS_3_7_Q042011
RTE
97
When the upper switch or upper anti-parallel diode conducts, the Vabc output equals the V+
input (minus internal voltage drops). When the lower switch or diode of the leg conducts,
the Vabc output is equal to V- (plus internal voltage drops). This load, that has a voltageinput current-output causality (like an inductance), outputs a current which in fed to the Iabc
input.
The I+ output is computed from all the upper switches or diodes conduction times. The Ioutput is computed from all the lower switches or diodes conduction times.
Mask
Parameters
Number of bridge
arms
Voltage output data
type
Ron
RTEVENTS_3_7_Q042011
RTE
98
Forward voltage Vf
Maximum number of
events
Input
The following table presents the input signals of the block when the voltage output data type
parameter is RT-Events or Simulink.
Pulses g (RTE
Boolean)
V+ (Double)
V- (Double)
Iabc(Double)
The following table presents the input signals of the block when the voltage output data type
parameter is SimPowerSystems.
Pulses g (RTE
Boolean)
dc + (SPS)
Positive DC-link.
dc - (SPS)
Negative DC-link
N (SPS)
Neutral.
Output
The following table presents the input signals of the block when the voltage output data type
parameter is RT-Events or Simulink.
Vabc (Double,
RTE Double)
The voltage at the middle point of the bridge which feeds the
load. The signal data type depends on the output data type
parameter.
I+ (Double)
I- (Double)
The following table presents the input signals of the block when the voltage output data type
parameter is SimPowerSystems.
A, B, C (SPS)
RTEVENTS_3_7_Q042011
RTE
99
Characteristics
Direct Feedthrough
No
Sample Time
Work offline
Yes
Dimensionalized
Yes
Limitations
Absence of switch gate signals
The block is not accurate when simulating the effect of completely shutting off all IGBT gate
pulses, like in emergency shutdown for example. This has the effect of letting the antiparallel diode turn on/off naturally, a case for which the Time Stamped Bridge is not
designed.
Input to output delay
Since RT-Events version 3.3.x, optimizations in Time-Stamp Bridges have been made to
reduce the input to output delay due to Simulink-SPS interfacing. This optimization does
concern the TSB when the Output Data Type parameter is SimPowerSystems.
Because the Time-Stamp Bridge has a switching function for which the outputs are directly
dependant on the inputs, algebraic loops need to be broken when connecting it in the
SimPowerSystems mode, which is obtained through forcing single time-step delays at the
input(s) or the output(s) of the model. The optimization implies the displacement of the
simulation delays from the output AC voltage(s) and DC current(s) to the input DC
voltage(s) and AC current. This modification allows for better simulation of a strong majority
of applications where a constant voltage is found on the DC bus(ses) (or the time constant
of the DC voltage is small compare to the time step), due to a fixed voltage source or control
actions.
Example
The following figures presentes a simple 3-level chopper circuit and its Simulink
implementation. Refer to the rte_3level_chopper.mdl example file. The IGBT are driven at
fixed frequency of 2 kHz and the simulation time step is 50s. The upper part of the Simulink
model is the RTE-Drive TSB implementation of the chopper while the bottom part is the
SimPowerSystem implementation.
RTEVENTS_3_7_Q042011
RTE 100
With those parameters, the duty cycle of the chopper has been scanned, that is the ratio of
the upper IGBT conduction time by the chopper frequency. The duty cycle concept is the
same then for the 2-Level bridge except that the modulation index goes from 0 [%] to 100
[%] for the 2-level modulation while it goes from -100 [%] to 100 [%] in the 3-level
modulation. This is possible with back-to-back (one positive and one negative) PWM
carriers upper and lower IGBTs of chopper circuit.
The following figure shows the result of scanning the duty-cycle of the chopper for the time
stamping technique vs. SimPowerSystem blockset technique. While both techniques have
the same response at 0.5 s simulation time step, they differ a lot at 50 s: the
SimPowerSystem exhibits strong non-linearity (red curve) while the time stamped bridge
model is still linear (blue curve). The time stamped bridge is as precise as reference
simulations made at 0.5 s.
RTEVENTS_3_7_Q042011
RTE 101
Figure 97:Current Load versus Duty Cycle of the 3-Level Chopper Circuit
Related Items
RTE-Drive 2-Level TSB
RTEVENTS_3_7_Q042011
RTE 102
Block
Description
The RTE-Drive 2-Level Time Stamped Bridge (TSB) block implements a 2-level bridge. The
bridge models IGBT/GTO/MOSFET devices controlled by ideal switch with their anti-parallel
diode. The following figure presents the equivalent electrical circuit of one phase of the RTEDrive TSB 2- Level block.
Figure 99:Equivalent Electrical Circuit of one arm the RTE-Drive 2-Level TSB Block
NOTE: The model is only available for 3-phase output. If less phases are required, the user
can leave the unused phases open.
The working principle of the model is the one of an average model. In the normal continuous
conduction mode, the output voltage of each phase is set equal to either V+ or V- input
voltage multiplied by the conduction time of the gate signal at each time step.
RTEVENTS_3_7_Q042011
RTE 103
When no pulse are present for BOTH IGBT, the output of the model is set in high-impedance
mode at the next current zero-crossing.
In this high-impedance mode, if the load voltage becomes higher/lower than the DC-link
voltages, the model enters into rectification mode, that is it will simulate the effect of the
anti-parallel diodes.
Mask
RTEVENTS_3_7_Q042011
RTE 104
Parameters
Number of bridge
Currently set to 3.
arms
Ron (ohms)
Forward Voltage (V)
High impedance in
non-conducting
state(Ohms)
Nominal DC link
voltage
Disable natural
rectification mode
Disable DC-link
current calculations
V + (SPS)
V- (SPS)
OpenPhase (size 3)
A,B,C (SPS)
sw (size 3)
This signal indicates that the inverter phase is open when equal
to one. The signal can be used to compensate for the noninfinite high-impedance value by forcing load current to zero
for example.
Vabc_inv (size 3)
Characteristics
RTEVENTS_3_7_Q042011
RTE 105
Direct Feedthrough
No
Sample Time
Work offline
Yes
Dimensionalized
No
Limitations
Fault insertion
The RTE-Drive 2-Level TSB Block internal model allows certain faults to be made with it. In all cases,
the fault impedance can be limited by numerical stability issues because of the RTE-Drive 2-Level TSB
Block introduces a delay between the input and the output of the model.
Fault type
AC-side open phase
AC-side short-circuit
Not supported.
phase fault
Internal IGBT short-
Not supported.
circuit.
Diode opencircuit/short-circuit
Example
Related Items
RTEVENTS_3_7_Q042011
RTE 106
Not supported.
Block
Description
The RTE-Drive 3-Level Time Stamped Bridge (TSB) block implements a 3-level NeutralClamped bridge with support for high-impedance and free-wheeling diode rectification
modes. The bridge models IGBT/GTO/MOSFET devices controlled by ideal switch with their
anti-parallel diode. The following figure presents the equivalent electrical circuit of the RTEDrive TSB 3- Level block with 3 arms.
RTEVENTS_3_7_Q042011
RTE 107
The working principle of the model is the one of an average model. In the normal continuous
conduction mode, the output voltage of each phase is set equal to either V+, Vneutral or Vinput voltage multiplied by the conduction time of the gate signal at each time step.
High-Impedance mode:
When no pulses are present for the TWO middle IGBT, the output of the model is set in highimpedance mode at the next current zero-crossing.
Anti-parallel diode Rectifying mode:
In this high-impedance mode, if the load voltage becomes higher/lower than the DC-link
voltages, the model enters into rectification mode, that is it will simulate the effect of the
anti-parallel diodes.
Mask
RTEVENTS_3_7_Q042011
RTE 108
Parameters
Number of bridge
Currently set to 3.
arms
Active Switch Ron
(ohms)
(Ohms)
DC link current
Common Mode
Removal
Threshold (A)
V + (SPS)
Vn (SPS)
V- (SPS)
gnd_in (SPS)
gnd_out (SPS)
A,B,C (SPS)
RTEVENTS_3_7_Q042011
RTE 109
Vn_delay (SPS)
Ineut_meas (size 1)
Characteristics
Direct Feedthrough
No
Sample Time
Work offline
Yes
Dimensionalized
No
Limitations
Fault insertion
The RTE-Drive 3-Level TSB Block internal model allow certain faults to be made with it. In all cases, the
fault impedance can be limited by numerical stability issues because of the RTE-Drive 3-Level TSB
Block introduces a delay between the input and the output of the model.
Fault type
AC-side open phase
AC-side short-circuit
Not supported.
phase fault
Internal IGBT short-
Not supported.
circuit.
Diode opencircuit/short-circuit
Example
Related Items
RTEVENTS_3_7_Q042011
RTE 110
Not supported.
RTE STATUS
Description
Contains RT-Events Status information.
Usage
See Elements.
Elements
eRTE_NoError (0)
No Error.
eRTE_ExceedMax_Ev0 (1)
eRTE_ExceedMax_Ev1 (2)
eRTE_InvalidIndex (4)
eRTE_InvalidTimeVector (8)
eRTE_InvalidIC (16)
eRTE_EventInThePast (64)
eRTE_MaxFrequency (128)
eRTE_HW_InitializeError
(67592)
not found.
eRTE_HW_OverrunError
(66048)
overrun.
eRTE_HW_DataLostError
(66560)
eRTE_HW_InvalidDataError
(67584)
eRTE_HW_TSBData (69632)
eRTE_UndefinedError
(4294967295)
Examples
None
Related Items
RTE Probe Events , RTE Events Generator
RTEVENTS_3_7_Q042011
RTE 111