Documentation Home Page RT-LAB Home Page
Pour la documentation en FRANÇAIS, utilisez l'outil de traduction de votre navigateur Chrome, Edge ou Safari. Voir un exemple.

OP5110-5120 Event Detector




The OP5110-5120 Event Detector controls the digital input pins of an Opal-RT OP5110 or OP5120 board (formerly named OPHSDIO board). The block is used to read in digital signals and to detect the transitions that occur on these signals during one calculation step.

On OP5110 or OP5120 cards, DIO lines are grouped in ports of 8 DIO lines. For example, the OPHSDIO64 card features 7 ports of 8 lines. The OP5110-5120Event Detector block can monitor any number of these lines simultaneously, each line being connected to its own digital signal.

During each time step, input lines are sensed for the transition. The hardware reports the moment of a state change relative to the start of the computation step. Rising, falling or both transitions can be reported as configured by the user. During one calculation step, all captured events are stored on the card and they are uploaded by the block during the next calculation step. The OP5110-5120 Event Detector block then returns to the model the transition times and the associated pin states at the time of these transitions.

The event detection feature of the OP5110 or OP5120 card can detect as many as 511 transitions per port, however, the number of events returned to the model is limited by the size of the output vectors as defined by the user in the model. If the size of the times and pin states vectors defined at initialization is smaller than the actual number of event detected, the status output pin returns an error value.

One of the block parameters allows the user to define the list of line numbers monitored by the block. When only one line is selected, the block has three outputs: the vector of pin states, the vector of associated transition times and the status output. When the user specifies a vector of N line numbers the block has N*3 outputs. The first three outputs return information relative to the first line of the list, the next three to the second line, etc.

The drawing below is an example of signal waveforms and returnedStates and Times vectors, assuming these vectors have a maximum size of of two elements.
All possible output values for States and Times are presented in the outputs section below.

Synchronization with the model calculation step: In order to ensure proper synchronization with the model clock, the OP5110-5120 Event Detector block must be used in conjunction with an OP5110-5120 OpSync block. The OP5110-5120 OpSync block is a hardware synchronization block. It ensures the stability of the calculation time-step and serves as a time reference for other OP5110-5120 blocks (such as OP5110-5120Event Detector, OP5110-5120 Event Generator). For more information, please refer to the documentation of the OP5110-5120 OpSync block.


Target environmentSelect between RT-LAB and xPC Target.
Bus TypeSelect the bus type of the target node in this list.
Card Type

Select the board type in this list. Each entry of the list specifies a board number, a device ID, and when applicable, the former name of the board. The device ID of the board selected must match a board installed on the target computer otherwise an error is returned.

On a Red Hat system, the deviceID of a board is specified in the name of the bitstream programmed in this board.

On a xPC Target, the device ID is obtained with the command getxpcpci all.

PCI slot (-1:autosearch)

This option is only available for xPC Target environment.

If only one OP5110 board is present in the xPC target PC, enter


to automatically locate the board.

If two or more boards of this type are in the target PC, enter the bus number and the PCI slot number of the board associated with this driver block.Use the format [BusNumber, SlotNumber]. To determine the bus number and thePCI slot number, in the MATLAB command window, type:

getxpcpci all

Board indexEnter the board index of the card [see board index limitations in the characteristics section below].
PortThis popup allows the user to specify which I/O port of the OP5110 or OP5120 board is used. A different OP5110-5120Event Detector block must be used for each I/O port.
Input line numbersEnter the vector of input line numbers to be monitored by this block. The input line numbers, in the range [0-7], can be entered in any order and must appear only once in the list.
Signal PolarityThis popup enables the user to specify the polarity, High or Low, of the input signals of the lines selected in the Input line numbers parameter. If some lines have a different polarity than others, two different OP5110-5120 Event Detector blocks must be used, one of them will specify the line numbers having High polarity, and the other one will specify the line numbers having Low polarity.
Signal Edge DetectedThis popup enables the user to choose whether rising edges, falling edges or both of the signal will be taken into account by the block.
Output TypeSelect whether the time values returned by the block will be specified as a ratio of the transition time over the duration of the step, or in seconds.
Apply Digital FilterWhen this checkbox is checked, the digital input signals are digitally filtered to remove noise. Pulses on the input signals that last less than 50ns are considered as noise.
Show current state outputWhen this checkbox is checked, the output Cur State is added to the block before the States, Times and Status outputs. See the description of this output in the Outputs section below.


This block has no inputs.


At each calculation step, the block returns three outputs for each line monitored by the block named States, Times and Status. The first two outputs are the vectors of pin state values and associated transition times, and the third output is a status output. When the size of the Times and States vectors defined in the model is smaller than the actual number of event detected, and an error is raised at the Status output.

An example of input waveform signals and the resulting States and Times values was presented in the functional description section above. The possible values of the States, Times and Status outputs are summarized in the following tables.


Possible Values Description 
1Pin state is high level (polarity is taken into account)
0Pin state is low level (polarity is taken into account)
-1No transition occurred


Possible Values (ratio) Description 
0 <= x < 1 Time ratio of transition occurrence over duration of the calculation step 
1No transition occurred 
Possible Values (seconds) Description 
0 <= x < Ts Time elapsed between beginning of calculation step and occurrence of transition
Ts No transition occurred 


Possible Values Description 
0No error. This status is also reported if fewer events are detected than the width of the States and Times output vectors.
1Number of events detected in the previous time step exceeds the width of the States and Times output vectors. The last event detected was 0. 
2Number of events detected in the previous time step exceeds the width of the States and Times output vectors. The last event detected was 1.
-1When several Event Detector blocks are used in the model, this status appears on the blocks that do not perform the DMA buffer reception. Only one Event Detector per OP5110 card actually accesses the DMA buffer, this is the first Event Detector block that gets executed in the calculation step. 
-2Device Id < 0x26 : More than 511 events were detected in the previous time step;
Device Id > 0x26: Block initialization error 

< -3Internal - DMA buffer reception errors

When the checkbox Show current state output is checked, the output Cur State is added to the block and returns the states of the I/O lines monitored by the block at the time when the block was executed. The output size is thus equal to the number of channels entered in the Input line numbers parameter. The values returned are not synchronized with the calculation step, they are sampled when the block gets executed and this time may vary with respect to the beginning of the calculation step. This output allows the user to use the OP5110-5120 Event Detector block as a static digital I/O block.

Characteristic and Limitations

Board Index Limitations

On the OP5120 boards (PC-104 format), the board index is user-selectable in the range [0-15] via a connector on the board. However, boardsOPHSDIO64 labeled v0.01 do not implement this feature, and the board index of these boards is set to the default value 15.

On the PCI boards (OP511x family), the board index is user-selectable in the range [12-15], via the jumpers JP8 on the board:

Connector Pin Assignments

OP5110-5120 boards usually ship with custom-made cables adapted to the signal conditioning required by the system they are to be connected to. Please refer to the documentation of your system for your specific connector pin assignment. If you need to prepare your own custom cable, please refer to the connector pin assignment table.

Direct FeedthroughNo
Discrete sample timeNo
XHP supportYes
Work offlineNo

OPAL-RT TECHNOLOGIES, Inc. | 1751, rue Richardson, bureau 1060 | Montréal, Québec Canada H3K 1G6 | | +1 514-935-2323