Sei sulla pagina 1di 4

1/18/2018 Building a LabVIEW User Interface for a Simulink® Model with LabVIEW Simulation Interface Toolkit - National Instruments

Building a LabVIEW User Interface for a Simulink® Model with LabVIEW Simulation Interface Toolkit
Publish Date: Mar 15, 2011

Overview
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
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:

http://www.ni.com/white-paper/3057/en/ 1/4
1/18/2018 Building a LabVIEW User Interface for a Simulink® Model with LabVIEW Simulation Interface Toolkit - National Instruments

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.

http://www.ni.com/white-paper/3057/en/ 2/4
1/18/2018 Building a LabVIEW User Interface for a Simulink® Model with LabVIEW Simulation Interface Toolkit - National Instruments

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.
3. Attachments

(/jriley/DEVO/conceptd.nsf/1949a53100ddca4e86257116006c996a/955a9d79583a0ab686256db8006672b8/$FILE/ATT7V9V7/abs
(/jriley/DEVO/conceptd.nsf/1949a53100ddca4e86257116006c996a/955a9d79583a0ab686256db8006672b8/$FILE/ATTXM5KP/ab
Related Links:
LabVIEW 2010 Help: Simulation Interface Toolkit
(http://digital.ni.com/manuals.nsf/websearch/499D92D6929031E3862577610078FBF7)
http://www.ni.com/white-paper/3057/en/ 3/4
1/18/2018 Building a LabVIEW User Interface for a Simulink® Model with LabVIEW Simulation Interface Toolkit - National Instruments
Developer Zone Tutorial: Using NI-DAQmx with the LabVIEW Simulation Interface Toolkit
(http://zone.ni.com/devzone/cda/tut/p/id/4611)
KnowledgeBase KB47IG4V3N: What Software Will I Need to Use the Simulation Interface Toolkit?
(http://digital.ni.com/public.nsf/allkb/8DE2AC8755DBC7A7862572A30079957E?OpenDocument)

http://www.ni.com/white-paper/3057/en/ 4/4

Potrebbero piacerti anche