该内容不适用于您选择的语言

该内容将以另一种语言显示出来。 您可使用浏览器的翻译功能查看内容。

Creating Simulation Models Using NI VeriStand Model Framework

Updated Feb 28, 2024

Environment

Software

  • VeriStand
  • VeriStand Model Framework

NI VeriStand Model Framework allows the creation of models within the MathWorks Simulink® environment that are compatible with VeriStand.

This article describes how to set up and create a simple Simulink model using the NI VeriStand Model Framework, how to import it into VeriStand and deploy it to NI Linux Real-Time hardware.

Software Installation

  1. Check VeriStand Modeling Version Compatibility.
  2. Install a version of MATLAB/Simulink that is compatible with VeriStand.​
    • Must include MATLAB Coder and Simulink Coder addons​.
  3. Install the VeriStand Model Framework.​
    • Included with the VeriStand installer in NI Package Manager, but you can choose to just install the framework without the VeriStand IDE​.
Note: Installing compatible versions and in the correct order is very important. The majority of Simulink/VeriStand issues are due to this.


Setting up and building a VeriStand compatible Simulink model

  1. Open your MATLAB software and verify if the Model Framework is recognized in MATLAB. When you open MATLAB, you should see this message:​
2022-09-27_14h31_42.png
  1. If you do not have it, check to make sure the Simulink version is compatible with VeriStand​. If you have multiple versions of MATLAB/Simulink installed, you may need to add the following lines to the matlabrc.m file:​
addpath('X:\VeriStand’);​
NIVeriStandAddPaths;​
  1. Open Simulink and create a model from scratch or open an example mode. You can create a simple add model by following the picture below.
2022-09-27_16h36_29.png
  1. Setup the model options as stated on this link. Open Model Configuration Parameter settings from the toolbar:​
  • Solver >> Stop time>> inf​
  • Solver >> Solver Selection >>Type>> Fixed-step​
2022-09-27_16h45_32.png
  1. In Model Configuration Parameter settings, select the Code Generation >>Target selection >> System Target File. Browse to select the VeriStand.tlc file and use the correct toolchain, for example VeriStand Compiler for Linux63 target | gmake makaefile (64-bit Linux) if we are compiling for NI Linux Real-Time(64-bit) target.
2024-02-28_16h01_29.png
2024-02-28_16h02_00.png
  1. Build the model by selecting Code >> C/C++ Code >> Build Model. Make sure that the build process is completed successfully, the build output directory will contain:​
  • Generated C files and header files​
  • The makefile​
  • Other model framework files​
  • The compiled shared library (.dll or .so file)​


Deploy Model in NI Linux Real-Time Hardware Using VeriStand

  1. Install the VeriStand Engine to your real-time target.
  2. Open an existing VeriStand project or create a new project and then open the System Explorer. Make sure to input correct real-time target Operating System and IP Address.
2022-10-25_16h08_49.png
  1. To use the model in VeriStand, you can now use the build DLL or SO file and load it into VeriStand by selecting Add a Simulation Model.
2022-10-25_16h09_23.png
  1. After the model has been loaded, you can find the inputs and outputs channels under your models.
2022-10-25_16h11_05.png
  1. Open or create one screen file and drag all the inputs and outputs from the add models.
2022-10-25_16h22_00.png
  1. Deploy the model into the VeriStand. After the status has change to Connected, change the value of the input ln1 and ln2. You can find out that the output will reflect the result from the Add model.
2022-10-25_16h23_08.png