Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Dec 17, 2007

How To Create a LabVIEW Based Virtual Instrument For NI Multisim

2 ratings | 4.50 out of 5
Print | PDF

Overview

Multisim's interactive simulation features are designed to help hardware design gain a better understanding of the circuits behaviour. However the quality of simulation results is highly depending on the applied signals as well as of the methods to analyse and display simulation data. In order to help closing the traditional gap between design and test NI 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. Users can now connect to real world signals from inside Multisim, output data to drive real world circuitries or display simulation data in a way more suitable to their needs.

System Requirements

The current version of Multisim is NI Multisim 10.0.1. This version of Multisim supports LabVIEW instruments created in NI LabVIEW 8.2.x and NI LabVIEW 8.0.x.

 

Things To Consider

  •  
  • You can build either an Input Instrument (Multisim inputs data to a LabVIEW based instrument) or an Output Instrument (a LabVIEW based instrument 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 connects to real world I/O (e.g. DAQ, GPIB, Serial, File, etc) take into consideration that you deal with simulation time (related to SPICE Tmax, complexity of your schematic, CPU speed, etc.) vs. "real time".
  • Output instruments cannot transfer data to Multisim while the simulation is running. This means that data acquisition/generation/etc. has to take place before you start a SPICE simulation (e.g. first record data with the microphone and than start the simulation).
  • Due to the fact, that LabVIEW based instruments are build out of a LabVIEW project, you need NI LabVIEW 8.0 or higher to create new instruments.
  • You only need NI LabVIEW to create the instrument. NI LabVIEW doesn?t need to be installed on the machine where you intend to run Multisim.

 

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 frontpanel controls or blockdiagram code. Everything the template comes with is required for communication between Multisim and a LabVIEW based instrument.

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 NI 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 Instrument_multisimInformation.vi to In Range Instrument_multisimInformation.vi (Note: Independent of the name you choose for the sub VI, you have to keep the extension "_multisimInformation.vi" in order to enable Multisim to load the instrument)
  7. Save your project


[+] Enlarge Image


[+] Enlarge Image

 

Step 2: Specify Interface Information

  1. Double click on Open In Range_multisimInformation.vi 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 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


[+] Enlarge Image

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 Fronpanel 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


[+] Enlarge Image

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 LabVIEW based instrument. 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 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


[+] Enlarge Image

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


[+] Enlarge Image

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

Step 4: Build 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


[+] Enlarge Image


[+] Enlarge Image

Install And Use The Custom Instrument

Everything you need to use a custom instrument inside Multisim comes with the Multisim installer. If you like to share a new instrument with colleagues or other Multisim user it is enough to 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 Multisim's installation directory ... \lvinstruments\
  2. Start Multisim
  3. You can access the new "In Range" instrument from the LabVIEW category of Multisim's instrument toolbar or from the Simulate menu (Simulate > Instruments > LabVIEW Instruments > In Range)
  4. Build a simple circuit to test the instrument's behaviour
    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 behaviour


[+] Enlarge Image

Aditional Resources

Search ni.com for more LabVIEW based instruments for NI Multisim

Tutorial on "Assure Compatibility of LabVIEW based Instruments across different NI Multisim versions"

Overview of NI Multisim's Virtual Instruments

Learn more about NI LabVIEW

Downloads

in_range.zip

2 ratings | 4.50 out of 5
Print | PDF

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).