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.

DataLogger Documentation | RT-LAB v.11.3.5 and up

This document presents a general overview of the DataLogger functionality, its intended use, and its features based on an example project (rtdemo1) available in the example folder with any RT-LAB distribution/release.

Introduction To The DataLogger

The DataLogger is a feature for data acquisition provided with RT-LAB from release version 11.3 upwards.

Its intended use is to capture signals according to a trigger condition and to record them to data files for analysis during simulation or post-simulation. It records multiple signals' evolution during the simulation in order to give users the ability to validate their design during simulation or in a post-processing phase.

The acquired signals can be recorded into three file formats: MAT (Matlab), CSV (Excel) and OPREC files. Additionally, the DataLogger captures transient phenomena and anomalies when they occur, which provides options to trigger the acquisition of data.

Some of its advantages include, but are not limited to:

  • Usable with either triggered or non-triggered acquisition
  • Low impact on real-time simulation performance
  • Capable of capturing signals with trigger conditions that occur at any moment during the simulation, including the very first calculation steps
  • Capable of logging multiple signals' acquisition within the same model and from multiple models
  • Handles multiple signal groups and multiple acquisition rates based on ratios of the simulation step
  • Parametrizable recorded file characteristics (Maximum Size, File Naming, etc.) and recorded duration (seconds, minutes, hours, etc.)
  • Provides clear recorded data regarding file naming, models’ signal names, data types and their respective units, scaling, aliases of these signals, and trigger information for ease of management.

Exploring The DataLogger

This quick guide is based on the rtdemo1 example project available with any RT-LAB distribution. This guide is also based on the use of RT-LAB version 2022.1.0.348.

Opening the rtdemo1 Model

  • Open RT-LAB.
  • Click File > Quick start-up project; a dialog box appears. Rename the project if needed; otherwise, keep it as it is and click Ok.
  • The project loads and you are able to compile the rtdemo1 model as a first step: right-click the model, then Simulation > Build.

Identifying the Elements in the Global View

In the hierarchical Project Explorer tab, to the upper left, you will be able to see the Models, I/O interfaces, Panels, and Recorders.

In this quick guide, we are interested mainly in the Datalogger's Recorders and the Models sections and their corresponding subsections.

  • Expand the Models and Recorders trees in the left margin to view their contents, as above.
  • Note that the Models tree contains rtdemo1, and, if you expand it, the two main subsystems in this example; sc_user_interface (user interface) and sm_computation (the calculation part of the simulation) blocks. 
    • Note also that the Recorders tree contains a RECORDER item by default IF the model has been built.
    • If the model has not been built/compiled, do so now by right-clicking Models > Simulation > Build.
  • The recorders are named after the model name in conjunction with the subsystem block names (sm_computation in this case), and, if there is more than one recorder/subsystem, they are named after each subsequent subsystem (sm_ or ss_) block.
  • By default, each Recorder contains one SIGNAL_GROUP, named SIGNAL_GROUP_1.

Choosing Signals to Log

  • Expand the sm_computation tree node, and then expand the node down to the signal level.
  • Choose which signals you would like to log by exploring the tree nodes and sub-nodes of interest.
    • Note that users choosing to locate the signals through Simulink models need to follow the signal they want to log back to its source in the block diagram in order to discover which block it’s listed under.
  • In this example, below, we've expanded the Gain1, Gain Kd, Gain Ki, and Gain Kp blocks in order to explore the exit signals for each of the linked blocks.
  • Select multiple signals by CTRL-clicking them one by one.
    • To remove individual signals from your selection, CTRL-click them again.

Assigning Signals to a SIGNAL_GROUP

A Signal Group is a group of signals of particular interest to a user. Users may want to group signals together for logging and observation because their interaction and extended comparison to one another–and to other signal groups--is of interest.



Note: Signals should be added to signal groups when the model is neither running nor loaded.



To add signals to a signal group:

  • Right-click the group of signals you have selected in the previous step, and select Record. 

OR

  • Click SIGNAL_GROUP_1 in the left tree-view menu to open the Quick Project Recorder tab, and, with the desired signals selected, drag them into this tab.

  • For the case where you are using the first method (right-clicking the signals), you will have two options, or possible views, depending on the number of SIGNAL_GROUPs you have under the recorder associated with this model:
    • If you have just one SIGNAL_GROUP, the signals are routed automatically to the only existing SIGNAL_GROUP.
    • If you have multiple SIGNAL_GROUPs under your recorder, a dialog box appears, asking you to choose a SIGNAL_GROUP to assign the selected signals to, as in the screenshots below.

  • Select the preferred SIGNAL_GROUP and click OK.
  • The signals are added to the chosen/default SIGNAL_GROUP.

Verify that the assignment was properly set by:

  • Expand the Recorders tree node, then your recorder to reveal the SIGNAL_GROUP_1, where you just added these signals. 
  • Double-click SIGNAL_GROUP_1 to open the associated variable table which lists all the signals associated to this signal group.
  • Examine the properties of this signal group in the lower right window.

Using the Recorder Tab Controls

To the upper right of the RT-LAB interface, you will find a Recorder window as shown below.



Note: There is no practical predefined limit to the number of signals per signal group, nor is there any practical predefined limit to the number of signal groups used.



If it is not currently visible, double-click Recorder_[Subsystem_name] in the Recorders list.

By default, the Recorder tab has one SIGNAL_GROUP listed for each Subsystem sm_ or ss_ block, and a display panel to the right. You will notice the addition of SIGNAL_GROUP_1.


Managing the Recorder Configuration

Settings available when General is selected in the Folders column of your recorder configuration panel:

  • The checkmark to the right provides a Configuration Check dialog function that gives feedback about whether the actual recorder configuration is correct or not.
  • The + and - marks to the right of the Folders tab expand and collapse the tree structure and all nodes downstream.

Recording Mode

The default recording mode. The recording mode can be set independently for each signal group. This general setting is used when the signal group recording mode is set to "inherit".

  • Automatic: data recording starts automatically according to trigger configuration
  • Manual: recording start on demand, as an example from an API call.

No data loss mode

The No data loss mode guarantees that there are no samples lost between adjacent acquisition frames. This model is available if the Real-Time simulation mode is set to "Simulation" (non real-time simulation). See also Executing Models

The General Tab

The General tab has a list of Parameters and Values. The values column is editable, and you can choose between the Basic and the Advanced modes, both shown below:

  • In Basic mode, you have only one option: whether to activate the No data loss mode or not, by selecting/unselecting the checkbox.

  • To select Advanced mode, click the pull-down to the right of the Mode label:

  • In Advanced mode, you will notice an additional option;
    • Show console for DataLoggerTool process: If checked, launches a console showing the DataLogger process messages, visible only when the model is loaded or running (Windows only). Target console is not shown.

Managing Recorder Configuration (Signal Groups)

Having multiple groups provides the capacity for storing various sets of signals with different acquisition configurations. Users can add/remove groups so that they can easily store various signals with different properties such as sampling rate, trigger, etc.

When the Signal Groups tree node is selected, you can manage the SIGNAL_GROUPs under the subsystem named in the Associated subsystem field.

The settings available when Signal Groups is selected in the Folders column of your recorder configuration panel are listed below:

From left to right:

Plus sign with up arrow

Adds next sequentially numbered signal group one spot above the selected row in current list

(Pull-down from the above item)

  • Add 1 item (Duplicate): Add a duplicate item above
  • Add N items: Add a number of items above
  • Add N items (Duplicate): Add a number of items, which are duplicates, above

Plus sign with down arrow

Adds next sequentially numbered signal group one spot below selected row in current list

(Pull-down from the above item)

  • Add 1 item (Duplicate): Add a duplicate item below
  • Add N items: Add a number of items below
  • Add N items (Duplicate): Add a number of items, which are duplicates, below

Red minus sign

Removes currently selected SIGNAL_GROUP

Blue arrow pointing up

Moves currently selected SIGNAL_GROUP one row up in the table

Down-facing arrow to the right of the above

Moves selected SIGNAL_GROUP to the first row of the table

Blue arrow pointing down

Moves currently selected SIGNAL_GROUP one row down in the table

Down-facing arrow to the right of the above

Moves selected SIGNAL_GROUP to the last row of the table

Managing the Recorder Configuration (SIGNAL_GROUP level)

When one SIGNAL_GROUP tree node is selected, you can manage the settings associated with that particular SIGNAL_GROUP.

Settings available by default when a particular SIGNAL_GROUP is selected in the Folders column of your recorder configuration panel are listed below:

PARAMETER

VALUE

Recording mode
  • Inherit (from the General tab): Inherits the recording mode
  • Manual: Leaves the recording mode at the user's discretion for manual data logging
  • Automatic (automatic logging from the run to the reset of the model)

This depends on the configured parameter. Recording may stop before the reset of the model.

Export format

OPREC (native format), Comma-Separated Values (CSV EXCEL), or MATLAB

Output file auto naming

[selector] 

When selected, new parameter Output file name [String] is available to provide a specific file name.

Check this checkbox to avoid naming collisions as it ensures naming uniqueness by appending the timestamp to the filename.

It also, if checked, names the output files based on a combination of the model name, the subsystem name, the date and hour for ease of management.

Note that the seconds in the generated file name corresponding to the time at which the DataLogger prepares the recorded/saved file. This may occur just before the recording starts, or at some time before when a trigger is configured.

When unchecked, no timestamp is appended to the name. So multiple simulation runs will overwrite the output file if it has not been renamed/moved between each simulation start

Decimation factor

[long value] 

Specifies the logging frequency based on a factor of the simulation time step.

For instance, if decimation factor = 1 the data is saved every step. If decimation factor = 2, the data is saved every 2 steps. And so on.

Frame length

[long value] 

A frame corresponds to the number of consecutive steps without any loss. Depending on the hardware configuration, some steps may be lost between two frames.

This zone of possibly lost data is called the blind area. This area is not visible and is thus not captured by the data logging system. Because the data are stored to a file, users may see missing samples between these frames. 

The size of the blind area depends on many factors such as the number of signals stored, the sampling frequency, the speed of the simulator, the disk speed, etc.

The 'Frame length' parameter specifies how many steps are to be recorded without any data loss (default 1000 steps).

Default value is 1 second (default frame length unit).

Frame length unit

Defines the unit of the Frame length parameter.

Default unit is in Seconds.

Number of frames to record

[long value] Specifies how many frames to record. Note that there is no data loss within a frame but it may happen between frames.

Trigger level

[double value] Level value that activates trigger. If a value of, say, 80 is set then recording starts when the trigger-signal rises past 80.

Trigger function

Signal function that will cause a trigger event (Edge, Level)

NOTE:

  • EDGE-triggered means recording starts as soon as the the signal moves from into the polarity region specified in the Trigger polarity box(which takes place, conceptually, in an instant)
  • LEVEL-triggered means whenever the signal crosses the value set in the Trigger level box (which will be true over a period of time).

Trigger polarity

Triggers when the trigger signal is greater (Positive) or less (Negative) than the parameter Trigger Level.

Together with the Trigger function and level, this parameter determines the trigger condition:

When the Trigger function is set to EDGE:

  • POSITIVE polarity: the trigger condition is met when the trigger signal becomes higher or equal to the Trigger level
  • NEGATIVE polarity: the trigger condition is met when the trigger signal becomes lower or equal to the Trigger level

When the Trigger function is set to LEVEL:

  • POSITIVE polarity: the trigger condition is met whenever the trigger signal is higher than the Trigger level
  • NEGATIVE polarity: the trigger condition is met whenever the trigger signal is lower than the Trigger level

Pre-trigger percentage

Percentage of frame length allocated to values before trigger i.e. no start of recording till this percentage of the frame length, after the trigger event has passed.

Trigger holdoff

[long value] Number of steps to ignore after a record is completed before re-arming trigger detection


To the lower right of the RT-LAB interface you will find a Recorder window.

The columns in this view indicate the parameters explained in the following table:


Save

When checked, the corresponding signal values are saved as logged data as part of the Recorder

Checked by default when a new signal is added to the signal group

Trigger

When selected, the signal in this row is considered as the trigger for the beginning of the acquisition

Name

Signal name as it appears in the original model

Path

Path to signal origin (same as the corresponding element's path inside the simulink model)

Alias

Alternate names for signal if any

Value

Dynamically-updating value of the signal. It can be visualized when the simulation is running; otherwise, it shows only question marks when the model is in a non-running state.

Comments on configuring trigger signals

  1. Using the Edge type of Trigger function, the user should be aware that the signal which is selected as the trigger inside the signal group, should actually change it's polarity and acquire a value that is of the polarity specified inside the Trigger polarity box. If, for example, the Positive option for Trigger polarity  is chosen, but the trigger signal starts with a positive value and stays positive till the simulation ends, there will be no recording triggered.

  2. If a value of 50 is chosen for Pre-trigger percentage, along with Frame length value of 10 (Frame length unit as seconds) then the recording will start only after 5 seconds (50% of the 10s) when the trigger signal meets its condition (depending on the Trigger function chosen) .

Starting, Recording & Retrieving Recorder Files

  • After the acquisition settings are set properly in the DataLogger Recorder parameters, the simulation model can be loaded onto the simulation target and the simulation can be executed.
  • The data logging feature is launched at the same time as the model and can be used while the simulation is running: manual acquisition start, signal visualization, logging files retrieval can all be recorded for post-simulation analysis.

    A red -dot appears on the icon preceding the signal group name which are configured properly and records data as and when the requirements set inside the signal configuration settings is met.
  • Users may choose to use the checklist below to ensure the DataLogger is correctly configured and ready to start.

Check if your model has compiled successfully

Check your General parameters for recorders

Check that you have all the SIGNAL_GROUPs you need

Check each SIGNAL_GROUP's parameters and that they suit your needs

Check if all the signals that you want to log are selected and assigned to the right SIGNAL_GROUP

Check that all your triggers are activated, if any

  • When all the actions above are checked, load (CTRL + Alt + L) your model and execute (CTRL + Alt + S) it.
  • After simulation completion and model reset, a new tree node, named data, appears after the Recorders tree node at the same level.
  • This tree node contains the files generated by each recorder. If you have multiple recorders and/or multiple SIGNAL_GROUPs with signals assigned to them, you will have the corresponding number of files.
  • Otherwise, if you have only one recorder and one SIGNAL_GROUP with assigned signals to log, as in the case below, you will have only one generated file in the format specified in your parameters.  

At this point, if users double-click the OPREC file, it opens in ScopeView and they can examine the contents of the file obtained during simulation.

If the file has several frames, ScopeView enables the viewing of all frames.

Users can also manually open ScopeView files with the suffixes .mat, .csv and .oprec. 



Note: the generation of a named file makes reference in its filename to the model name, subsystem name, date (YearMonthDay format) and hour (HourMinuteSecond format), or users can choose to explicitly name SIGNAL_GROUP configurations

If the file naming is set to auto-naming, the generated files are not overwritten if you proceed with a second simulation with the same recorder. The subsequently-generated files, however, will be named with new Date and Time values.



Recording in Manual Mode

  • Recording in Manual mode is equivalent to recording when using a trigger, except that the trigger is based on a human intervention through the GUI, and more specifically on the signal_group or on the recorder levels on the Recorders tree.
  • When the model is running and being manually recorded, the user can right-click on the recorder/signal_group, and a menu appears containing two options; start recording and stop recording as shown in the two screenshots below.
  • If the user right-clicks the recorder, an equivalent menu appears, except that the action applies to all the signal_groups configured in Manual mode under that particular recorder, as shown in the third screengrab.



Note: You can also start/stop the recording for signal_groups configured in Automatic mode.

The main difference is that in Automatic mode, users can ensure the first simulation steps are recorded, whereas in Manual mode you never know exactly when the recording starts.



File-naming with Multi-model Simulation and/or Multiple Recorders/SIGNAL_GROUPs

When you are performing a multi-model simulation with logging, or you have multiple slave/master subsystems and you are also using the DataLogger, ensure that;

  • All the ss_ and sm_ blocks have unique names, otherwise, you will not be able to correctly assign signals to log to the appropriate SIGNAL_GROUPs, and these signals will be not logged.
    If you choose to name your logs without using the auto-naming feature, ensure they have unique names to avoid overwriting data and/or data loss,

Known Limitations

  • Recording of Real-Time simulation data is limited to 2GB for real-time simulation on real-time targets (32bit). When using localhost targets, there is no known limitation to the logging file size.
  • Occasional freezes in RT-LAB software may be experienced, especially with a high number of signals/signals_groups to log.
  • When logging using vectors, all the elements of the vector are logged and there is no possibility to select only a subsection of the vector for recording.
  • The export format to .mat file is very limited for now. A workaround is to use the .csv export format or to exploit .oprec files with MATLAB functions (cf. next section).


Exploiting OPREC files with MATLAB

Two MATLAB functions : OpRecInfo and OpRecRead are available to retrieve information and/or read data from OPAL Record files (.oprec).

Script usage

OpRecInfo

This script allows retrieving metadata from .oprec files.

Parameter

  • Full Oprec file path

Usage

OpRecInfo('C:\Data\SignalGroup_1.oprec');

Just provide a full path to the .oprec file to retrieve the following information:

  • Time step (in seconds)
  • Minimal timestamp (in seconds): first simulation step recorded.
  • Maximum timestamp (in seconds): last simulation step recorded.
  • The count and the list of all recorded signals.

Output example

OpRecRead

This script allows retrieving data for all recorded signals.

Parameters

  • Full Oprec file path
  • [optional] the first timestamp to read. By default, this corresponds to the timestamp of the first recorded step.
    This value is adjusted in case the specified timestamp is lower than the timestamp of the first recorded step.
    This parameter is mandatory when the last timestamp is specified (see below).
  • [optional] the last timestamp to read. By default, this corresponds to the timestamp of the last recorded step.
    This value is adjusted in case the specified timestamp is greater than the timestamp of the last recorded step.

Usage

[header, data] = OpRecRead('C:\Data\SignalGroup_1.oprec');

Provide two output variables to store the data read from the .oprec file:

  • The first variable will store the signal names and types.
  • The second variable will store all the step data for the signals in the exact same order as in the first variable.

Output examples

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