Using VeriStand with Simulink

Refer to the following topics to use VeriStand and MathWorks Simulink® software together in the Inverter Test System:

Preparing the Simulink Model Environment

Complete the following steps to set up your environment for MathWorks Simulink® model integration.
  1. Install the MathWorks MATLAB® Toolbox for the Inverter Test System. Refer to the Inverter Test System GitHub Repository for instructions.
  2. Add the Inverter Test System Buffers to your model. Refer to the Inverter Test System GitHub Repository for instructions.

Preparing a Simulink Model for Inverter Test

Use MathWorks Simulink® software to convert your vehicle control or ECU model for use on real-time targets. This model will run on LinuxRT and communicate data to the FPGA.

Before you begin, choose a compiler.
  1. Launch MathWorks MATLAB® software.
  2. Select Start Simulink.
  3. Open the model that you want to deploy.
  4. Select Simulation » Model Configuration Parameters.
  5. In the Model Configuration Parameters dialog box, click Solver and configure the following:
    1. Stop time: inf
    2. Type: Fixed-step
    3. Fixed-step size (fundamental sample time): 50.0e-6 [1]
  6. Click Code Generation.
  7. If the model specifies any .c or .h files, specify the locations of the source files and directories.
  8. Click Browse... and select the ni_slxrt.tlc system target file for your target from the list.
  9. Select the GCC compiler for your Linux target from the Toolchain dropdown menu.
  10. Click OK.
The MATLAB software command window displays the status of the build process and indicates when the Simulink Coder software has completed compiling the model.

Deploying a Simulink Model to a Target

Complete the following process to deploy a MathWorks Simulink® software model to a target for the Inverter Test System.

Note This process is specific to the Inverter Test System.

Installing Software Components

Refer to the Inverter Test System Software Toolkit Readme for instructions on installing software to enable you to deploy a MathWorks Simulink® model to a target.

Enabling External Mode

Complete the following steps if you want to connect to a deployed model via External Mode:

  1. Launch Simulink.
  2. Open the model Configuration Parameters dialog box.
  3. Select Code Generation » Interface.
  4. Select the External Mode checkbox.
  5. Select tcpip from the Transport layer dropdown menu.
  6. Enter the IP Address of the LinuxRT target in the MEX-file arguments box using the following format: ‘<TargetIP>’,0,<External Mode Port>.
  7. Click OK.

Compiling a Model

The Inverter Test System uses a custom system target file to configure the hardware settings required to deploy models on a LinuxRT target. To compile a model for deployment, complete the following steps:

  1. Launch Simulink.
  2. Open the model Configuration Parameters dialog box.
  3. Select Code Generation.
  4. Select Browse... next to the System target file.
  5. Select ni_slxrt.tlc.
  6. Select Build.
    Simulink stores the output .so file in the same folder as the top model or in your working folder, depending on your code generation settings.

Connecting to a Running Model

If you have already deployed and started a model, you can press the Connect button to begin an external mode session.

1 This value is provided as an example and may change depending on your application.