You are on page 1of 12

Introduction to Digital and Analog Co-simulation Between NI LabVIEW and NI Multisim

Publish Date: Feb 21, 2013


The following document illustrates how to cosimulate analog and digital data between LabVIEW and Multisim software. Learn how
to use LabVIEW to vary the voltage level of a DC power supply in series with an RLC circuit in Multisim and then pass the output
voltage back to LabVIEW to be displayed on a graph.
Table of Contents


Required Software
Create an Analog Circuit in Multisim
Create a Digital Controller in LabVIEW
Performing Co-simulation Between LabVIEW and Multisim
Related Links

1. Introduction

For the design and analysis of complete systems, including those in power and mechatronics applications, you need to effectively
design across both the analog and digital domains. Traditional platforms are unable to accurately simulate both analog and digital
together, so design errors cascade to the physical prototype and lead to an ineffective and lengthy design approach.
With the new co-simulation capabilities between Multisim and LabVIEW, you can design with accurate, closed-loop point-by-point
simulation an entire analog and digital system. You can use LabVIEW and Multisim to take advantage of two distinct simulation
engines: Multisim simulation for the accuracy of analog and mixed-signal circuitry and LabVIEW for the effective design and
implementation of control logic. This is made possible by a unique time-step negotiation between both simulators using the
External Model Interface in LabVIEW.
2. Required Software

Before beginning co-simulation between LabVIEW and Multisim, you must install the following software in the specified order:
1. Install LabVIEW Full or Professional version 2011 or later.

2. Install the LabVIEW Control Design and Simulation Module version 2011 or later.


3. Install Multisim 12.0 or later. Select Install NI LabVIEW-Multisim Co-Simulation Plug-In for LabVIEW during the installation of

4. You have now successfully installed the required development environments for LabVIEW and Multisim co-simulation.
3. Create an Analog Circuit in Multisim

1. Place a voltage-controlled power supply to allow LabVIEW to vary the DC voltage level during simulation. Right-click and select
Place component from the shortcut menu. Choose the following parameters:
Database: Master Database
Group: Sources
Family: Controlled_Voltage_Sources
Component: Voltage_Controlled_Voltage_Source
Select OK to place the component onto the schematic. You can modify the ratio of voltage output per voltage input by
double-clicking the component. For a ratio of 1 V/V, the voltage controlled voltage source in Multisim outputs 1 V for every Volt
that is passed in from LabVIEW.


2. Place the resistor, capacitor, and inductor for the circuit. Use the following parameters for ideal components:
Database: Master Database
Group: Basic
Component: C=50 F, I=20 mH, R=10
With the release of Multisim 12.0, you can use nonideal resistors, capacitors, and inductors to add parasitic parameters to the
components. For nonideal components, use the following parameters:
Database: Master Database
Group: Basic

After placing the components, you must double-click each one to change the value of a nonideal component. At that time, you can

After placing the components, you must double-click each one to change the value of a nonideal component. At that time, you can
also modify the optional parasitics.

3. Finally, place the circuit ground. In the Select a Component dialog box, choose the following parameters:
Database: Master Database
Group: Sources
Family: Power Sources
Component: Ground

4. You are now ready to place the terminals that send and receive data to and from the LabVIEW simulation engine. These
terminals in Multisim are Hierarchical Block or Sub-Circuit (HB/SC) terminals. Right-click and select Place on
schematicHB/SC connector from the shortcut menu or simply type <Ctrl-I>. Place one HB/SC connector above and to the left
of the schematic and another connector above and to the right of the schematic. Rotate the second connector 180 degrees by
holding Ctrl and tapping R twice. Connect the HB connectors to the circuit as seen in the image below.


5. To configure the HB/SC connector as an input or output to LabVIEW, you must open the LabVIEW Co-simulation Terminals
window. Navigate to ViewLabVIEW Co-simulation Terminals.
Notice that the HB/SC connectors placed earlier appear in this window. To configure each connector as an input or output, select
the desired choice from the Mode settings. You can then configure each connector as a voltage or current input/output by
selecting the Type. Finally, if you have placed two input or output terminals that you want to function as a differential pair, you can
select a Negative Connection. Configure IO1 as an Input and IO2 as an Output. You can immediately see the shape of the
connector changing on the schematic based on whether it's an input or an output connector.

6. Notice that the Multisim design VI preview updates with the selections that you made. This is a preview of the virtual
instrument (VI) that you later place in LabVIEW to interface with this Multisim circuit. If you want to change the input and output
terminal names of this Multisim VI, modify the text of the LabVIEW Terminal setting. For this example, enter Voltage_In and
Voltage_Out for the input and output terminals, respectively.


7. The completed circuit consists of a voltage-controlled voltage source that is in series with an inductor, capacitor, and resistor.
The input voltage to the voltage-controlled voltage source comes from a control in LabVIEW, and the output of the RLC filter circuit
is passed back to LabVIEW to be visualized on a graph with the original input voltage for comparison. The image below is a
Multisim Design Snippet that you can drag and drop into your Multisim environment and it automatically recreates the code. Read
more information on Multisim Snippets.

8. Save the Multisim design to a known location so you can retrieve it while you program in LabVIEW. You are now ready to
program the LabVIEW VI that communicates with this circuit in Multisim.
4. Create a Digital Controller in LabVIEW

1. To pass data back and forth between LabVIEW and Multisim, you must use a Control & Simulation Loop in LabVIEW. Navigate
to the block diagram in LabVIEW (white window), right-click to open the Functions Palette, and navigate to Control Design &
SimulationSimulationControl & Simulation Loop. Left-click and drag the loop onto the block diagram.


2. To modify the Solver and Timing settings of the Control & Simulation Loop, double-click the input terminal to the loop to make
the Configure Simulation Parameters window appear. Enter the parameters as seen in the figure below; these settings provide
effective results for plotting the data on a waveform chart in LabVIEW with the settings used later in the tutorial. Tune these
parameters to meet your needs.

3. Now add the Halt Simulation function to your VI to stop the Control & Simulation Loop. Right-click the block diagram and
navigate to Control Design & SimulationSimulationUtilitiesHalt Simulation. Left-click to place the Halt Simulation function
on the block diagram and then right-click the Boolean input of the Halt Simulation VI and select CreateControl. This creates a
Boolean control on the front panel that you can use to halt, or stop, the simulation while it is running.


4. Next, place the Multisim Design VI that facilitates the communication between the LabVIEW and Multisim simulation engines.
Right-click the block diagram and navigate to Control Design & SimulationSimulationExternal ModelsMultisimMultisim
Design and left-click to place the VI within the Control & Simulation Loop; it must be placed within the loop.
The Select a Multisim Design dialog box appears after you place the Multisim Design VI. You now need to either specify the file
path or browse to the location by clicking the Browse button and locating the file on your hard disk.
The Multisim Design VI now populates the terminals, identically to the Multisim Design VI Preview within the Multisim environment,
with the proper inputs and outputs. Left-click on the double down-arrow and expand the terminals if they are not visible.

5. To pass data to the Multisim design, you must first create a numeric control on the front panel. To easily accomplish this,
right-click on the input, Voltage_In, and select CreateControl. This places a numeric control terminal on the block diagram that is
already wired to the input of the Multisim VI. The block diagram terminal for the control has a corresponding control on the front
panel, which is the user interface in LabVIEW. To quickly navigate between the block diagram and front panel, simply press

If you want to change the appearance of the numeric control on the front panel, you can resize and move the control as you wish.

If you want to change the appearance of the numeric control on the front panel, you can resize and move the control as you wish.
Also, you can replace the control with a dial, knob, slider, and so on by right-clicking on the control, selecting
ReplaceSilverNumeric, and then selecting the numeric control that you want. Double-click the maximum and minimum values
to change the range of the control. Use -25 and 25 for the minimum and maximum values, respectively.

6. To move data from Multisim to LabVIEW, you need to create an indicator to display the data . Because you are displaying both
the input voltage and the resulting output voltage from the Multisim circuit, a chart indicator works best. While on the front panel,
right-click on empty space and navigate to SilverGraphWaveform Chart (Silver). Resize accordingly.

7. To properly display the voltage input and the voltage output together, you need to build the signals into an array. Right-click the
block diagram and navigate to ProgrammingArrayBuild Array and left-click to place the function on the block diagram. Place
your mouse pointer over the bottom middle of the Build Array function to reveal the resize anchors and then left-click and drag to
the function to resize the Build Array to receive two inputs. Wire the output from the voltage control into the top input and wire the
output from the Voltage_Out terminal of the Multisim Design VI to the bottom input. This creates a one-dimensional array of two


8. Finally, you need to place the function to create a simulated time waveform within the loop to properly display the two
waveforms. Right-click the block diagram Control Design & SimulationSimulationGraph UtilitiesSimulation Time
Waveform. This VI automatically places a waveform chart. Simply delete the newly created chart and rewire the output from the
Simulation Time Waveform VI to the input of the existing waveform chart. Wire the output from the Build Array function to the input
of the Simulation Time Waveform.

9. To produce a more readable waveform chart, navigate to the front panel, right-click Waveform Chart, and select Properties.
Navigate to the Display Format tab and select Automatic formatting for the Type input and 4 for the Digits input.

Then navigate to the Scales tab and deselect Autoscale for the Time (X-Axis). Finally, toggle from Time (X-Axis) to Amplitude
(Y-Axis) and deselect Autoscale. This holds the chart ranges to a constant range. Select OK to apply your changes.

10. Next, double-click the maximum and minimum inputs of the Amplitude scale and adjust to 40 and -40, respectively. This
allows for overshoot values to be displayed properly. Double-click the maximum of the Time axis and set this to 0.25, or 250

11. Save the LabVIEW VI to a known location, preferably the same location as your Multisim design because they are paired
together. The image below is a LabVIEW VI Snippet that you can drag and drop into a blank LabVIEW VI, and it recreates the
code automatically. Click here for more information about LabVIEW VI Snippets. You are now ready to perform a co-simulation
between LabVIEW and Multisim.
Note: Some browsers do not support drag-and-drop LabVIEW VI Snippet functionality. An alternative method is to right-click the
image and choose Save image as to save the image. You can then drag and drop the image file into a LabVIEW block diagram

to paste the code.


to paste the code.

5. Performing Co-simulation Between LabVIEW and Multisim

Now that you have created the analog circuit and digital controller in Multisim and LabVIEW and you have established the
communication paths, you are ready to co-simulate between the two simulation environments and visualize the results on the
waveform chart on your LabVIEW front panel.
1. To begin the co-simulation, click the Run button on the LabVIEW toolbar. Multisim does not need to be open because an
instance of Multisim is opened and runs silently in the background. It takes between 5 and 30 seconds to launch the Multisim
instance and begin the co-simulation between the LabVIEW and Multisim simulation engines.
2. Modify the input voltage in LabVIEW and observe the output voltage that is returned from the Multisim simulation engine.
Example results are shown below.

3. Modify the RLC circuit parameters in Multisim to alter how the circuit responds to a change in input voltage. To change the
parameters of the capacitance, resistance, and inductance during transient co-simulation, use a voltage-controlled capacitor,
resistor, and inductor in Multisim and pass control voltages to Multisim from LabVIEW controls.
6. Conclusion

As shown in the resulting waveform chart on the LabVIEW front panel, LabVIEW and Multisim can effectively and accurately
simulate the RLC response to multiple changes in the input voltage. In this example, LabVIEW acts as the digital controller, setting
the DC voltage level of the analog circuit that is simulated in Multisim. This is a simple yet fundamental circuit to show the
co-simulation behavior. More complex examples of LabVIEW and Multisim co-simulation are available.
7. Related Links

Download NI Multisim
How to Design and Simulate a Brushed DC Motor H-Bridge Circuit Using Multisim and LabVIEW