How to Create a LabVIEW Based Virtual Instrument for NI Multisim

Publish Date: Mar 14, 2012 | 12 Ratings | 3.33 out of 5 | Print | 3 Customer Reviews | Submit your review


The interactive simulation features of Multisim are designed to help hardware designers gain a better understanding of circuit behavior. Since the quality of simulation results is highly dependent on the applied signals as well as the methods of analyzing and displaying simulation data, Multisim offers the possibility to implement and use custom instruments based on NI LabVIEW together with your SPICE-based circuit, turning an ordinary schematic into a virtual prototype to help close the traditional the gap between design and test. You can now connect to real-world signals from inside Multisim, output data to drive real-world circuitry, or display simulation data in a way more suitable to your needs.

Table of Contents

  1. System Requirements
  2. Things to Consider
  3. Creating a New Instrument
  4. Install and Use the Custom Instrument
  5. Additional Resources

1. System Requirements

The current version of Multisim is NI Multisim 12. This version of Multisim supports LabVIEW instruments created in LabVIEW 2010 and newer. 

Back to Top

2. Things to Consider


  • You can build either an input instrument (Multisim inputs data to an instrument based on LabVIEW) or an output instrument (an instrument based on LabVIEW outputs data to Multisim).
  • Input instruments continuously receive data from Multisim while the simulation is running. If you plan to build or use instruments that connect to real-world I/O (for example, DAQ, GPIB, Serial, File, and so on) take into consideration that you deal with simulation time (related to SPICE Tmax, complexity of your schematic, CPU speed, and so on) versus "real time."
  • Output instruments cannot transfer data to Multisim while the simulation is running. This means that data acquisition,generation,and so on has to take place before you start a SPICE simulation (for example, first record data with the microphone and than start the simulation).
  • Instruments based on LabVIEW are built out of a LabVIEW project; therefore, you need NI LabVIEW 8.0 or later to create new instruments.
  • You need only LabVIEW to create the instrument. LabVIEW does not need to be installed on the machine where you intend to run Multisim.

In the tutorial, you will see references to the Samples folder and to the LVInstruments folder. 

To properly install the LabVIEW instrument in the correct folder you can look in Multisim under the Options»Global Preferences»Paths, look for User LabVIEW Instruments Path, this will give you an idea of where in your file directory are the folders located.


Back to Top

3. Creating a New Instrument

Creating an input or output instrument is nearly the same process. In this tutorial, we will create a new input instrument that takes a signal from a SPICE circuit and compares it against an upper and lower limit. Differences to creating an output instrument will be explained.

Note: DO NOT delete any of the front panel controls or block diagram code. Everything the template comes with is required for communication between Multisim and an instrument based on LabVIEW.

Step 1: Copy and Rename a Template Project

  1. Copy the folder ...samples\LabVIEW Instruments\Templates\Input to a new directory.
  2. Rename the folder ..\Input to ..\In Range.
  3. Rename the file ..\In Range\StarterInputInstrument.lvproj to In Range.lvproj.
  4. Double-click on ..\In Range\In Range.lvproj to open the project file in LabVIEW.
  5. Right-click on the Starter Input Instrument.vit and select Save As. Follow the dialogs and rename the template to In Range Instrument.vit.
  6. Repeat the same process to rename Starter Input to In Range (Note: Independent of the name you choose for the sub VI, you have to keep the extension "" to enable Multisim to load the instrument).
  7. Save your project.


Step 2: Specify Interface Information

  1. Double-click on Open In to open it.
  2. Change to the block diagram of the VI (press Ctrl-E, or navigate to Window > Show Block Diagram).
  3. Enter the following information:
    1. Instrument ID = "InRange" (Unique used to communicate between Multisim and LabVIEW)
    2. Display name = "In Range" (the name that will appear in Multisim?s instrument toolbar list
    3. Number of pins = "1" (this sets the number of inputs pins offered by the instrument)
    4. Input pin names = "In" (pin name that will be used in a SPICE netlist or netlist report)
  4. Save (File > Save) this VI and close the block diagram and front panel.

NOTE: A valid instrument can have either input pins or output pins, but not both. If you set number of input pins > 0 and number of output pins > 0, the instrument will not be treated as a valid LabVIEW/Multisim instrument.

Note: If you create an output instrument, fill in the appropriate values for number of output pins and output pin names.


Step 3: Create Custom Instrument

The front panel of the VI In Range.vit will be the instrument interface a Multisim user sees and operates, the block diagram is where you add the graphical code for your instruments specific functionality.

Build The Fron Panel of Your Instrument
  1. Double-click on In Range Instrument.vit to open it.
  2. Select the front panel and change it as shown in the graphic below.
    1. Move (but DO NOT delete) all controls that a user should not see
    2. Right-click on the front panel and add a Horizontal Pointer Slide from the numeric controls
    3. Rename the control to Upper Limit
    4. Right click the slider and select Data Range and enter the following values
    5. Repeat the steps to create a slider named Lower Limit but set the default value to -5
    6. Place a Square LED from the Boolean Control palette and rename it In Range

Note: The front panel also holds a control named "Sampling Rate [Hz]" with a default value of 10 kHz. This control determines the rate data are transferred from the simulation to the instrument based on LabVIEW. Change the default value or make the control accessible on the interface if changes to that control are necessary.

Finish the Block Diagram of Your Instrument
  1. Change to the Block Diagram (press Ctrl-E) and add the following graphical code to the case "Update data," located in the lower while loop.
    1. Enlarge the space in the case structure (press Ctrl and draw a rectangle with the left mouse button)
    2. Place "Index array" from the array palette to select the data for pin number 1 (your input pin)
    3. Place "Get waveform components" from the waveform palette to extract Y-data from your wire
    4. Place "In Range and Coerce" from the comparison palette and wire your front panel controls to the upper and lower limit terminals
    5. Place "Index array" from array palette and wire its input to the "In Range" terminal of the "In Range and Coerce" function. Wire the output scalar to front panel square LED "In Range?"
    6. Save your VI and close front panel and block diagram

Note: If you create an output instrument, the process is very similar except that you wire all data you want to send to Multisim to control named Multisim output pins located in the case structure named Update Initial Output Data.

Note: If you intend to save instrument data (settings, control values, and so on) with your circuit, you need to place the appropriate code in the cases "Serialize Data" and "Deserialize Data."

Step 4: Build a Custom Instrument

  1. Expand the Build Specifications and double-click on Source Distribution to open it.
    1. Select the category "Distribution Settings"
    2. Change the Distribution Directory to ...\In Range\Build\In_Range.llb
    3. Press the Build button
  2. Press Done after the build process is completed.
  3. Save Project (File > Save Project) and close LabVIEW.

Back to Top

4. Install and Use the Custom Instrument

Everything you need to use a custom instrument inside Multisim comes with the Multisim installer. If you would like to share a new instrument with colleagues or other Multisim users, just send the *.llb from your project's ..\Build folder.

  1. Navigate to project's build folder "...\In Range\Build\" and copy the new instrument "In_Range.llb" to the LabVIEW instrument folder inside the Multisim installation directory ... \lvinstruments\.
  2. Start Multisim.
  3. Access the new "In Range" instrument from the LabVIEW category of the Multisim instrument toolbar or from the Simulate menu (Simulate > Instruments > LabVIEW Instruments > In Range).
  4. Build a simple circuit to test the instrument's behavior.
    1. Place a Function Generator
    2. Place the new In Range Instrument and connect it to the + pin of the Function Generator
    3. Place Ground and connect it to the Ground pin of the Function Generator
    4. Double-click the Function Generator symbol to open its interface and enter the following values
      1. Waveform: Sine Wave
      2. Frequency: 60 Hz
      3. Amplitude: 10 Volts
    5. Double-click the In Range instrument symbol to open its interface
  5. Start the simulation and verify the instruments behavior.

Back to Top

5. Additional Resources

Download custom analyses for different Multisim applications

How to Set Up a LabVIEW Instrument in the Multisim Environment

View the Tutorial: Assure Compatibility of LabVIEW Based Instruments across Different NI Multisim Versions 

Learn More about LabVIEW

Back to Top

Customer Reviews
3 Reviews | Submit your review

Where is the explanation about Serialize Data and Deserialize Data? - Nov 21, 2016

I found everywhere (like, google and multisim's help files), but the only sentence about Serialize Data is " If you intend to save instrument data, you should place the appropriate code ...". I think there should be some explanation of what is "appropriate" code and when it will call.

This tutorial is not up to date with latest versions of Multisim and LabView - Jul 5, 2016

This tutorial's instructions are not valid for the latest versions of Multisim and LabView. Some controls/parameters have different names and I tried my best to find the modern equivalent to what was requested here, but in the end the instructions did not result in a working instrument.

 - Nov 18, 2010

I have to admit that this tutorial is really poorly done. Many steps are missing or have no justification. Is there a similar tutorial available from a third-party perhaps?

Bookmark & Share




Rate this document

Answered Your Question?
Yes No