Compiling a Model from The MathWorks, Inc. Simulink® Software

NI VeriStand 2018 Help

Edition Date: May 2018

Part Number: 372846M-01

»View Product Info
Download Help (Windows Only)

Complete the following steps to convert your model you created in The MathWorks, Inc. Simulink® software into a compiled model that runs on RT targets.

Note  Before you complete this procedure, you can refer to information about how NI VeriStand imports Simulink models to ensure your models are configured appropriately.

1. Verify That the NI VeriStand Model Framework Is Installed

The NI VeriStand Model Framework must be installed on the computer with the Simulink software. The NI VeriStand Model Framework adds tools to the Simulink software that you use later in this procedure. More information.

2. Ensure You Have the Correct Compiler

Answer the following questions to determine which tools you must use to convert and compile Simulink models:

  1. What real-time operating system (RTOS) does my target run?

    Refer to the KnowledgeBase at ni.com for a list of RT targets and the RTOS that each runs, then continue to step 2. (Windows) If you want to create a compiled model that runs on Windows, just continue to step 2.
  2. Given the RTOS my target runs, what tools do I use to compile my model and what output do I create?
    RTOS Required Tools Required Output Type
    Windows
    • Microsoft Visual C++
    • The MathWorks, Inc. Simulink Coder™ software
    Note  NI VeriStand 2015 also supports older versions of the Simulink Coder software, called the Real-Time Workshop® software.
    DLL
    Phar Lap ETS
    VxWorks
    • Wind River GNU Toolchain
    • The MathWorks, Inc. Simulink Coder software
    .out
    NI Linux Real-Time
    • C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition
    • The MathWorks, Inc. Simulink Coder software
    .so
  3. Which versions of these tools are compatible with the version of NI VeriStand I am using?

    Refer to the following KnowledgeBase document at ni.com for a list of the versions of the LabVIEW, Windows, model compiler, and The MathWorks, Inc. software you can use with each distribution of NI VeriStand: NI VeriStand Version Compatibility.

Related Links

3. Select the Correct Compiler in the MATLAB® Software

  • (Phar Lap ETS, Windows) Run mex -setup in the MATLAB software and select the option number for a compatible version of Microsoft Visual C++.
  • (VxWorks) Go to the next section. You will select the compiler in a later step.
  • (NI Linux Real-Time) Go to the next section. You do not need to select a compiler for NI Linux Real-Time when you install C/C++ Development Tools for NI Linux Real-Time, Eclipse Edition.

4. Build the Compiled Model in the Simulink Software

After you have the correct compiler set up and selected, complete the following steps to build the compiled model:

  1. Launch the Simulink software and load your model you want to convert.
  2. Select Simulation»Model Configuration Parameters to launch the Model Configuration Parameters dialog box.
  3. Click the Solver tab and configure the following options:
    • Stop time: inf
    • Type: Fixed-step
  4. Click the Code Generation tab.
  5. Click the Browse button to launch the System Target File Browser dialog box.
  6. Select the correct option for your target from the list:
    • (Windows, Phar Lap ETS) NIVeriStand.tlc—NI Real-Time Target
    • (NI Linux Real-Time) 
      • (ARM-based targets) NIVeriStand_Linux_ARM_32.tlc—NI Real-Time Target
      • (Intel x64-based targets) NIVeriStand_Linux_64.tlc—NI Real-Time Target
        Note  VeriStand is not supported on x64 Intel-based cDAQ controllers running NI Linux Real-Time.
    • (VxWorks) NIVeriStand_VxWorks.tlc—NI Real-Time Target
    Note  If the appropriate .tlc is not visible, the MATLAB software files might be read-only, and NI VeriStand is not able to provide this option. To display the option, add the following lines to the matlabrc.m file, a file that is installed by the MATLAB software:

    addpath('X:\VeriStand');

    NIVeriStandAddPaths;



    where X is the drive letter on which you installed NI VeriStand.
  7. (VxWorks) On the NI Configuration tab, which is located under the Code Generation tab, specify the setup path for the Wind River GNU Toolchain.
  8. Click the OK button.
  9. Click the Build button in the Category section to begin building the compiled model. The MATLAB software command window displays the status of the build process. The following message in the MATLAB command window indicates that the Simulink Coder software has completed building the compiled model.

    ### Successful completion of build procedure for model:ModelName

Including External Source Code in the Compiled Model

If your model you are converting specifies any .c or .h files, you must specify the locations of these files so NI VeriStand includes the code in the compiled model. Specify the source files and include directories in the Simulink software, on the Code Generation tab of the Configuration Parameters dialog box.

WAS THIS ARTICLE HELPFUL?

Not Helpful