Building a LabVIEW UI for a Simulink® Model with LabVIEW Simulation Interface Toolkit

Publish Date: Nov 30, 2018 | 57 Ratings | 3.33 out of 5 | Print | 6 Customer Reviews | Submit your review


The Simulation Interface Toolkit (SIT) provides a seamless integration between The MathWorks Inc. Simulink® software and LabVIEW. The Simulation Interface Toolkit automatically generates LabVIEW code to interface with a Simulink® module resulting in a flexible and easy-to-use user interface. You first must congifure the Simulink® model to communicate with LabVIEW. Then you can create a LabVIEW host VI that automatically calls, runs and interacts with the Simulink® model.

Table of Contents

  1. Configuring the Simulink Model
  2. Creating a LabVIEW User Interface
  3. Attachments

1. Configuring the Simulink Model

Before LabVIEW can communicate with your Simulink® model, you must first correctly configure your model in Simulink®.

  1. Save the attached files sinewave.mdl and Sine Wave.VI.  

  2. Launch MATLAB® and notice how the MATLAB® command window displays the following message:

    Starting the SIT Server on port 6011
    SIT Server started

    The Simulation Interface Toolkit automatically installs the SIT server. If you do not see this message, the toolkit is not installed correctly

  3. Enter simulink in the MATLAB® command window to launch the Simulink® Library Browser window.

  4. Select File»Open and select the sinewave.mdl, downloaded in Step 1.  

    The simulation model should look similar to the following diagram:

    This Simulink® model represents a sine wave.  

  5. Note the SignalProbe block on the diagram.   You must place a SignalProbe block on the top layer of your diagram.  The SignalProbe block can be found in the NI SIT Blocks library.

  6. Also note the simulation settings by selecting Simulation>>Simulation parameters.   For information on setting the simulation options, refer to the LabVIEW 2010 Simulation Interface Toolkit Help.

  7. Save the Simulink® model

    You can now create a user interface in LabVIEW for the Simulink® model.  Notice that the model remains fully-operational within the Simulink® environment

Back to Top

2. Creating a LabVIEW User Interface

To interact with the Sine Wave Model using a LabVIEW user interface, you need to create a user interface in LabVIEW.

  1. Launch LabVIEW and open a new VI.

  2. Place two knob controls on the front panel.   Label one Frequency and the other Amplitude.

  3. Place a waveform chart on the front panel.   Label the y-axis Amplitude and the x-axis Time.
    Your front panel should look similar to the following Front Panel:

  4. You can now create the mappings between the VI and the Simulink® model. From the VI, select Tools>>SIT Connection Manager.

  5. In the Model and Host category, select Simulation Environment under Host Execution.  The execution host is the machine on which the SIT server is running.  If you want to select Real-Time Target or Driver VI on Local host, you must convert your Simulink® model to a DLL before you can create mappings.

  6. Under Current Model, select Browse and select the sinewave.mdl file.

  7. Under Project Directory, select Browse and select the folder in which you want your project to be contained.  Ideally, this should be the same folder that you model is located in.  

  8. From the Category list, select Mappings to display the Mappings page.   The Current Mappings table shows the controls and indicators you created earlier on the front panel.  You will use this page to map your front panel items to the Simulink® model.

  9. Highlight the Frequency control in the Current Mappings table and click the Change Mappings button.   This will bring up the Specify Parameters for Control dialog box.  

  10. From this dialog box, select Frequency from the sinewave>>Sine Wave tree and click OK.

  11. Map the remaining objects.  Map the Amplitude control to the Amplitude from the sinewave>>Sine Wave tree.  Map the Sine Wave indicator to the Port 1 from the sinewave>>Sum tree.  

  12. Click the OK button to close the SIT Connection Manager dialog box and generate the block diagram code for the VI. Notice there are now Model Controls on your front panel.  You can use these controls to control the model from the VI.

  13. Notice the block diagram now contains code.   DO NOT MODIFY ANY of the code with green labels.  

You can run the VI and control the simulation with the Model Controls.   The Frequency and Amplitude knob controls can be used to change the sine wave output.

This process described here does not require the MathWorks Real-Time Workshop®.  This VI uses Simulink® to run the simulation.  You also can use the Simulation Interface Toolkit together with the Real-Time Workshop® to build the model into a DLL for stand-alone simulation.  You need MATLAB®, Simulink®, and Real-Time Workshop® to build a model DLL and configure the user interface.  You need only LabVIEW to run the simulation.  For hardware-in-the-loop (HIP) and prototyping applications, you can run the model DLL in LabVIEW Real-Time to provide real-time inputs and outputs and to ensure determinism.

MATLAB®, Simulink®, and Real-Time Workshop® are registered trademarks of The MathWorks, Inc. Other product and company names listed are trademarks and trade names of their respective companies.

Back to Top

3. Attachments

Related Links:
LabVIEW 2010 Help: Simulation Interface Toolkit 
Developer Zone Tutorial: Using NI-DAQmx with the LabVIEW Simulation Interface Toolkit
KnowledgeBase KB47IG4V3N: What Software Will I Need to Use the Simulation Interface Toolkit?



Back to Top

Customer Reviews
6 Reviews | Submit your review

Update this NOW, please...  - Dec 2, 2009

I can't believe this example still refers to the SIT v 2.0 while the current SIT is v 5.0. I know you guys are busy, but, good grief, isn't the purpose of help to be helpful?

  - May 28, 2009

Looks like the simulink model is way out of date, the NI interface has drastically changed as well, don't waste your time on this example unless you plan on reworking it significantly

  - Oct 3, 2008

Lots of issues in proper installation in SIT,Also Update this Tutorial for SIT 5.0

Does Lab VIEW interface influence the simulation speed  - Jun 2, 2008

I never used the LabVIEW interface for Simulink but, I would like to know whether it will influence the simulation time of Simulink model?

  - Mar 24, 2008

This needs to be updated for SIT 4.0 (as does the User Manual).

Need to update  - Feb 6, 2006

This needs to be updated for SIT 3.0 (as does the User Manual).

View more reviews

Bookmark & Share


Rate this document

Answered Your Question?
Yes No