Main Content

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:

  1. On the Simulink model toolbar, set the Simulation stop time, located to the left of Simulation mode. The signals are logged for the time period specified in the Simulation stop time parameter. The default value is 10.0 seconds. Enter Inf to log signals indefinitely.

  2. In the Simulink 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:

  1. Double-click the block, and specify these parameters in the Block Parameter dialog box.

    ParameterDescription
    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 is 0.1 and Decimation is 5, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Simulation 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, or Structure.

    • 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:

  1. Double-click the block, and click the Configuration Properties button.

  2. 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.

  3. In the Logging tab, set the block parameters listed in this table.

    ParameterDescription
    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 is 0.1 and Decimation is 5, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Simulation 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, or Structure.

    • 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:

  1. 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.

  2. In the model window, open the Configuration Parameters dialog box and select Data Import/Export.

  3. Set the block parameters listed in this table:

    ParameterDescription
    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, or Structure.

    • 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 is 0.1 and Decimation is 5, the data points at 0, 0.5, 1, 1.5, ... seconds are logged. The data points are logged until the Simulation stop time is reached.