Example Code

VirtualBench: IV Curve With the DMM and PWS

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • VirtualBench All-in-One Instrument

Code and Documents

Attachment

Description

Overview
This example performs a voltage sweep with the VirtualBench power supply (PWS), measures the current with the VirtualBench digital multimeter (DMM), and plots the resulting IV curve. 


[+] Enlarge Image

Steps to Run Program

    1. Download the example program on the right under downloads.
    2. In LabVIEW software, open the program by going to File » Open… and navigating to the file.
    3. Connect the VirtualBench device.
    4. Select the correct VirtualBench device in the pull-down menu of the VirtualBench Device control.
    5. Select the PWS channel and specify the starting and ending voltage, number of steps, and current limit for the PWS.
    6. Specify the auto range terminal to use for the DMM. 
    7. Click the Run button to begin the voltage sweep.
    8. The IV curve will display on the graph on the front panel.

 

As a reminder, the detailed help for each VI specifies allowable values for each input. Below is an excerpt from the DMM Configure DC Current VI as an example:

 

Program Explained

 


[+] Enlarge Image

 

    • Initialize Session
      • The VirtualBench device information is passed into the PS Initialize VI to initialize a new session to the PWS and passed to the DMM Initialize VI to initialize a new session to the DMM. 
      • Error information is passed from the PS Initialize VI to the DMM Initialize VI. This passes error information and enforces data flow. 
    • Configure Instrument
      • Instrument and error information is passed into the DMM Configure DC Current VI. Auto range terminal specification is passed from the Auto Range control into the VI.
      • Instrument and error information is passed into the DMM Configure Measurement VI. The function has been set to DC current and auto range has been turned on using a Boolean true constant.  
    • Perform Operation
      • The starting and ending voltage, current limit, and PWS channel information is passed into a For Loop. The solid tunnels indicate that the information is passed into the For Loop without any additional manipulation. The For Loop will not execute until all of the inputs are available. As such, the controls are placed outside the loop to prevent a jump or discontinuity on the output if the user changes a control value while the program is running.
        • The number of steps specified on the front panel is increased by 1 then passed into the count terminal of the For Loop.  This specifies the number of times to set a voltage and measure the current. Because the program should measure at the starting voltage and then at every step, the 1 needs to be added to the step value. 
        • The starting and ending voltage is passed into the For Loop and then subtracted to find the voltage range. This range is then divided by the number of steps to determine the step size. 
        • The step size is then multiplied by the iteration terminal of the For Loop, and added to the start voltage. This specifies the voltage level for that iteration of the voltage sweep. On the first iteration of the For Loop, the iteration terminal will be 0 so the voltage level will be at the starting voltage. On the second iteration, the iteration terminal will be 1. It will then multiply this by the voltage step size and add it to the starting voltage. This will set the voltage level to be one step size over the starting voltage. The next iteration will be two step sizes over the starting voltage, and so on.  
        • The divide and multiply functions both have a coercion dot at an input.  LabVIEW places a red coercion dot to alert you that LabVIEW converted the value passed into the node to a different representation. In these cases, LabVIEW is converting a double-precision, floating-point number to an integer. While a conversion VI could have been used to convert the numeric type, it was unnecessary since LabVIEW can do it.
      • Instrument and error information are passed into the PS Configure Voltage Output VI. The calculated voltage is passed into the Voltage Level input, and the current limit information is passed from the control into the VI. 
      • Instrument and error information are passed into the PS Enable All Outputs VI. Outputs are enabled using a Boolean true constant. On the first iteration of the loop, this VI will ensure that the PWS is enabled. After the first loop, this VI has no actual effect since the PWS will already be enabled. 
      • Instrument and error information are passed into the DMM Read VI. The error wire forces data flow, ensuring that the DMM will always read after the voltage level has been set. The VI outputs the measured current. 
      • The voltage level and the output current are passed out of the For Loop. The auto-index tunnels indicate that the loop is creating an array with one element in the array per loop iteration. These values are bundled together and then displayed on a graph on the front panel.
      • Lastly, instrument and error information are passed into the PS Enable All Outputs VI. The PWS is disabled by inputting a Boolean false constant to the VI.
    • Close Session
      • Instrument and error information are passed into the PS Close VI and then the DMM Close VI. This closes the PWS and DMM sessions and deallocates any resources for the next time a session is created with these instruments.
    • Handle Errors
      • Finally, the error information is passed into the Simple Error Handler VI. If an error has occurred, a dialog box will open to notify the user.

 

Additional Resources

 

VirtualBench Examples

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.