Configure Model to Log Signals on SD Card
SD card logging is supported in models containing To Workspace, Scope, or Outport blocks. You must specify the values for several block parameters.
To configure a Simulink® model to run on the target hardware, perform these steps:
On the Simulation tab of the toolstrip, set the Stop time. The signals are logged for the time period specified in the Stop time parameter. The default value is
10.0
seconds. EnterInf
to log signals indefinitely.In the model, set the parameter values of To Workspace, Scope, and Outport blocks.
To Workspace Block
To set the parameter values of the To Workspace block:
Double-click the block, and specify these parameters in the Block Parameter dialog box.
Parameter Description Variable name Specify a variable name for the logged data.
Limit data points to last Specify the number of data points to be logged in the MAT-file. The maximum number of data points that a MAT-file can contain is 512.
Decimation Use this parameter for the block to write data points at every nth sample, where n is the decimation factor. The default decimation,
1
, writes data at every time sample.For example, if you specify Decimation as
5
, the block writes data at every fifth sample. For example, if the block sample time is0.1
and Decimation is5
, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Stop time is reached.Save format Select a format of the variable to which you save data. SD card logging supports only these three formats:
Array
,Structure with Time
, orStructure
.Array
: Save data as an array with associated time information. This format does not support variable-size data.Structure with Time
: Save data as a structure with associated time information.Structure
: Save data as a structure.
Sample time (–1 for inherited) Specify an interval at which the block reads data. When you specify this parameter as
–1
, the sample time is inherited from the driving block.
Scope Block
To set the parameter values of the Scope block:
Double-click the block, and click the Configuration Properties button.
In the Main tab, specify the Sample time parameter. When you specify this parameter as
–1
, the sample time is inherited from the driving block.In the Logging tab, set the block parameters listed in this table.
Parameter Description Limit data points to last Specify the number of data points to be logged in the MAT-file. The maximum number of data points that a MAT-file can contain is 512.
Decimation Use this parameter for the block to write data points at every nth sample, where n is the decimation factor. The default decimation,
1
, writes data at every time sample.For example, if you specify Decimation as
5
, the block writes data at every fifth sample. For example, if the block sample time is0.1
and Decimation is5
, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Stop time is reached.Log data to workspace Select this parameter to enable data logging. When you select this parameter, the Variable name and Save format parameters become available.
Variable name Specify a variable name for the logged data.
Save format Select a format of the variable to which you save data. SD card logging supports only these three formats:
Array
,Structure with Time
, orStructure
.Array
: Save data as an array with associated time information. This format does not support variable-size data.Structure with Time
: Save data as a structure with associated time information.Structure
: Save data as a structure.
Outport Block
To set the parameter values of the Outport block:
Double-click the block, select the Signal Attributes tab, and specify the Sample time parameter. When you specify this parameter as
–1
, the sample time is inherited from the driving block.In the model window, open the Configuration Parameters dialog box and select Data Import/Export.
Set the block parameters listed in this table:
Parameter Description Time Saves time data to the specified variable.
Output Saves signal data to the specified variable.
Format Select a format of the variable to which you save data. SD card logging supports only these three formats:
Array
,Structure with Time
, orStructure
.Array
: Save data as an array with associated time information. This format does not support variable-size data.Structure with Time
: Save data as a structure with associated time information.Structure
: Save data as a structure.
Limit data points to last Specify the number of data points to be logged in a MAT-file. The maximum number of data points that a MAT-file can contain is 512.
Decimation Use this parameter for the block to write data points at every nth sample, where n is the decimation factor. The default decimation,
1
, writes data at every time sample.For example, if you specify Decimation as
5
, the block writes data at every fifth sample. For example, if the block sample time is0.1
and Decimation is5
, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Stop time is reached.