Compiling a Model from The MathWorks, Inc. Simulink® Software (Model Interface Toolkit)

LabVIEW 2017 Model Interface Toolkit Help

Edition Date: May 2017

Part Number: 374160C-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 the Model Interface API can run.

Note  Before you complete this procedure, ensure your models are configured to interact with the Model Interface API the way you want.

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 following KnowledgeBase at ni.com for a list of RT targets and the RTOS that each runs, then continue to step 2: What Operating System is my Real-Time Controller Running and Why? (Windows) If you want to create a compiled model that runs on Windows, just continue to step 2.
  2. Given the OS my target runs, what tools do I use to compile my model and what output do I create?
    OS Required Tools Required Output Type
    Windows
    • Microsoft Visual C++
    • The MathWorks, Inc. Simulink ® Coder ™ software
    Note  NI VeriStand 2015 also supports the older version of the Simulink Coder, called the Real-Time Workshop ®.
    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 the Model Interface Toolkit 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 the Model Interface Toolkit: NI VeriStand Version Compatibility.

Related Links

Note  The Model Interface Toolkit shares several components with the NI VeriStand software, such as tools for compiling models designed in third-party modeling environments.

3. Select the Correct Compiler in MATLAB

  • (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 Simulink

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
    • Solver: discrete (no continuous states)
  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:
    • (ETS, Windows) 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  The Model Interface Toolkit 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 the Model Interface Toolkit installer 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 the NI VeriStand Model Framework.

    The Model Interface Toolkit shares several components with the NI VeriStand software, such as tools for compiling models designed in third-party modeling environments.
  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 they are included 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