LabVIEW Multisim Co Simulation

12
1/12 www.ni.com 1. 2. 3. 4. 5. 6. 7. Introduction to Digital and Analog Co-simulation Between NI LabVIEW and NI Multisim Publish Date: Feb 21, 2013 Overview 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 Introduction Required Software Create an Analog Circuit in Multisim Create a Digital Controller in LabVIEW Performing Co-simulation Between LabVIEW and Multisim Conclusion 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 and , you can design with accurate, closed-loop point-by-point Multisim LabVIEW 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.

description

Introducción a la co-simulación analógica y digital entre Multisim y LabVIEW.

Transcript of LabVIEW Multisim Co Simulation

1/12 www.ni.com

1. 2. 3. 4. 5. 6. 7.

Introduction to Digital and Analog Co-simulation Between NI LabVIEW and NI MultisimPublish Date: Feb 21, 2013

Overview

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

Table of Contents

IntroductionRequired SoftwareCreate an Analog Circuit in MultisimCreate a Digital Controller in LabVIEWPerforming Co-simulation Between LabVIEW and MultisimConclusionRelated Links

1. Introduction

For the design and analysis of complete systems, including those in power and mechatronics applications, you need to effectivelydesign across both the analog and digital domains. Traditional platforms are unable to accurately simulate both analog and digitaltogether, so design errors cascade to the physical prototype and lead to an ineffective and lengthy design approach.With the new co-simulation capabilities between and , you can design with accurate, closed-loop point-by-pointMultisim LabVIEWsimulation an entire analog and digital system. You can use LabVIEW and Multisim to take advantage of two distinct simulationengines: Multisim simulation for the accuracy of analog and mixed-signal circuitry and LabVIEW for the effective design andimplementation of control logic. This is made possible by a unique time-step negotiation between both simulators using theExternal 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.

2/12 www.ni.com

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

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 from the shortcut menu. Choose the following parameters:Place component

Master DatabaseDatabase: SourcesGroup: Controlled_Voltage_SourcesFamily:

Voltage_Controlled_Voltage_SourceComponent:

Select to place the component onto the schematic. You can modify the ratio of voltage output per voltage input byOKdouble-clicking the component. For a ratio of 1 V/V, the voltage controlled voltage source in Multisim outputs 1 V for every Voltthat is passed in from LabVIEW.

3/12 www.ni.com

2. Place the resistor, capacitor, and inductor for the circuit. Use the following parameters for ideal components:Database: Master Database

BasicGroup: CAPACITOR, INDUCTOR, RESISTORFamily:

C=50 µF, I=20 mH, R=10 ΩComponent: With the release of Multisim 12.0, you can use nonideal resistors, capacitors, and inductors to add parasitic parameters to thecomponents. For nonideal components, use the following parameters:Database: Master Database

BasicGroup: NON_IDEAL_RLCFamily:

NON_IDEAL_CAPACITOR, NON_IDEAL_INDUCTOR, NON_IDEAL_RESISTORComponent:

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

4/12 www.ni.com

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

3. Finally, place the circuit ground. In the dialog box, choose the following parameters:Select a ComponentDatabase: Master Database

SourcesGroup: Power SourcesFamily:

GroundComponent:

4. You are now ready to place the terminals that send and receive data to and from the LabVIEW simulation engine. Theseterminals in Multisim are or terminals. Right-click and select Hierarchical Block Sub-Circuit (HB/SC) Place on

from the shortcut menu or simply type . Place one HB/SC connector above and to the leftschematic»HB/SC connector <Ctrl-I>of the schematic and another connector above and to the right of the schematic. Rotate the second connector 180 degrees byholding and tapping twice. Connect the HB connectors to the circuit as seen in the image below. Ctrl R

5/12 www.ni.com

5. To configure the HB/SC connector as an input or output to LabVIEW, you must open the LabVIEW Co-simulation Terminalswindow. Navigate to .View»LabVIEW Co-simulation Terminals

Notice that the HB/SC connectors placed earlier appear in this window. To configure each connector as an input or output, selectthe desired choice from the settings. You can then configure each connector as a voltage or current input/output byModeselecting the . Finally, if you have placed two input or output terminals that you want to function as a differential pair, you canTypeselect a . Configure IO1 as an and IO2 as an You can immediately see the shape of theNegative Connection Input Output. connector changing on the schematic based on whether it's an input or an output connector.

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

6/12 www.ni.com

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 circuitis passed back to LabVIEW to be visualized on a graph with the original input voltage for comparison. The image below is aMultisim 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 toprogram 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. Navigateto the block diagram in LabVIEW (white window), right-click to open the and navigate to Functions Palette, Control Design &

. Left-click and drag the loop onto the block diagram.Simulation»Simulation»Control & Simulation Loop

7/12 www.ni.com

2. To modify the Solver and Timing settings of the Control & Simulation Loop, double-click the input terminal to the loop to makethe window appear. Enter the parameters as seen in the figure below; these settings provideConfigure Simulation Parameterseffective results for plotting the data on a waveform chart in LabVIEW with the settings used later in the tutorial. Tune theseparameters 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 andnavigate to . Left-click to place the Halt Simulation functionControl Design & Simulation»Simulation»Utilities»Halt Simulationon the block diagram and then right-click the Boolean input of the Halt Simulation VI and select . This creates aCreate»ControlBoolean control on the front panel that you can use to halt, or stop, the simulation while it is running.

8/12 www.ni.com

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 & Simulation»Simulation»External Models»Multisim»Multisim

and left-click to place the VI within the Control & Simulation Loop; it must be placed within the loop.Design

The dialog box appears after you place the Multisim Design VI. You now need to either specify the fileSelect a Multisim Designpath or browse to the location by clicking the button and locating the file on your hard disk.Browse

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 . This places a numeric control terminal on the block diagram that isCreate»Controlalready wired to the input of the Multisim VI. The block diagram terminal for the control has a corresponding control on the frontpanel, which is the user interface in LabVIEW. To quickly navigate between the block diagram and front panel, simply press

. <Ctrl-E>

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.

9/12 www.ni.com

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

and then selecting the numeric control that you want. Double-click the maximum and minimum valuesReplace»Silver»Numeric,to change the range of the control. Use - and for the minimum and maximum values, respectively.25 25

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 . Resize accordingly.Silver»Graph»Waveform Chart (Silver)

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

10/12 www.ni.com

8. Finally, you need to place the function to create a simulated time waveform within the loop to properly display the twowaveforms. Right-click the block diagram Control Design & Simulation»Simulation»Graph Utilities»Simulation Time

. This VI automatically places a waveform chart. Simply delete the newly created chart and rewire the output from theWaveformSimulation Time Waveform VI to the input of the existing waveform chart. Wire the output from the Build Array function to the inputof the Simulation Time Waveform.

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

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

11/12 www.ni.com

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

11. Save the LabVIEW VI to a known location, preferably the same location as your Multisim design because they are pairedtogether. The image below is a LabVIEW VI Snippet that you can drag and drop into a blank LabVIEW VI, and it recreates thecode automatically. Click here for . You are now ready to perform a co-simulationmore information about LabVIEW VI Snippetsbetween LabVIEW and Multisim.

Some browsers do not support drag-and-drop LabVIEW VI Snippet functionality. An alternative method is to right-click theNote:image and choose to save the image. You can then drag and drop the image file into a LabVIEW block diagramSave image as…

to paste the code.

12/12 www.ni.com

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 thecommunication paths, you are ready to co-simulate between the two simulation environments and visualize the results on thewaveform chart on your LabVIEW front panel.1. To begin the co-simulation, click the button on the LabVIEW toolbar. Multisim does not need to be open because anRuninstance of Multisim is opened and runs silently in the background. It takes between 5 and 30 seconds to launch the Multisiminstance 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 theparameters 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 accuratelysimulate the RLC response to multiple changes in the input voltage. In this example, LabVIEW acts as the digital controller, settingthe DC voltage level of the analog circuit that is simulated in Multisim. This is a simple yet fundamental circuit to show theco-simulation behavior. More complex examples of LabVIEW and Multisim co-simulation are available.7. Related Links

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