Using VeriStand with Simulink
- Updated2023-02-20
- 3 minute(s) read
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
- Install the MathWorks MATLAB® Toolbox for the Inverter Test System. Refer to the Inverter Test System GitHub Repository for instructions.
- 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.
- Launch MathWorks MATLAB® software.
- Select Start Simulink.
- Open the model that you want to deploy.
- Select .
-
In the Model Configuration Parameters dialog box, click
Solver and configure the following:
- Stop time: inf
- Type: Fixed-step
- Fixed-step size (fundamental sample time): 50.0e-6 [1]
- Click Code Generation.
- If the model specifies any .c or .h files, specify the locations of the source files and directories.
- Click Browse... and select the ni_slxrt.tlc system target file for your target from the list.
- Select the GCC compiler for your Linux target from the Toolchain dropdown menu.
- Click OK.
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.
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:
- Launch Simulink.
- Open the model Configuration Parameters dialog box.
- Select .
- Select the External Mode checkbox.
- Select tcpip from the Transport layer dropdown menu.
- Enter the IP Address of the LinuxRT target in the MEX-file arguments box using the following format: ‘<TargetIP>’,0,<External Mode Port>.
- 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:
- Launch Simulink.
- Open the model Configuration Parameters dialog box.
- Select Code Generation.
- Select Browse... next to the System target file.
- Select ni_slxrt.tlc.
-
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.
Deploying a Model to a Target
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.