Main Content

Add I/O Blocks to Simulink Model

You can transform a Simulink® model into a Simulink Real-Time™ model that accesses I/O drivers either by using the Simulink Real-Time block library or the Simulink Real-Time: Speedgoat I/O Blockset. In the Simulink Real-Time block library, the highest hierarchical level in the library lists I/O function groups. The second level lists board manufacturer groups. The manufacturer groups contain the driver blocks for specific boards.

This example uses the Simulink model slrt_ex_osc to show how to replace Simulink blocks with Simulink Real-Time I/O blocks. For examples, at the MATLAB command prompt, type:

open_system(fullfile(matlabroot, 'toolbox', 'slrealtime', ...
'examples', 'slrt_ex_osc'))
  1. To browse the Simulink Real-Time block library, open the Library: slrealtimelib window. In the Command Window, type:

    slrealtimelib
  2. To browse the Simulink Real-Time: Speedgoat I/O Blockset, open the Library: speedgoatlib window. In the MATLAB Command Window, type:

    speedgoatlib
  3. In the MATLAB Command Window, type:

    open_system(fullfile(matlabroot, 'toolbox', 'slrealtime', ...
    'examples','slrt_ex_osc'))

    The Simulink block diagram opens for the model slrt_ex_osc.

    Image of slrt_ex_osc model

  4. Open the Simulink Library Browser. Select Simulink Real-Time: Speedgoat I/O Blockset > IO101. Drag each of these blocks to the Simulink block diagram: Speedgoat IO101 Analog input block, Speedgoat IO101 Analog output block, and Speedgoat IO101 Setup.

    The Simulink Editor adds the new I/O blocks to your model.

  5. Remove the Signal Generator block and add the Speedgoat IO101 Analog input block in its place. Remove the Scope block and add the Speedgoat IO101 Analog output block in its place. The block parameters select the number of outputs for the block.

  6. Save the model with a new name, such as ex_slrt_iob_osc . To open the completed model, in the MATLAB Command Window, type:

    open_system(fullfile(docroot, 'toolbox', 'slrealtime', ...
    'examples', 'slrt_ex_iob_osc'))

    Image of slrt_ex_osc_iob model

    You cannot run this model unless the required I/O board is installed in your target computer. You can substitute driver blocks for another I/O board that is installed in the target computer.

After you add I/O blocks to the model, set up the I/O operation by selecting block parameter values. For more information, see Configure Block Parameters.

Related Topics