Example Code

VirtualBench: Stimulus Response With the MSO and FGEN

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 generates an arbitrary waveform with optional white noise using the VirtualBench function generator (FGEN) and reads the resulting waveform from the mixed signal oscilloscope (MSO). The stimulus response is then displayed. 


[+] 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. Specify the arbitrary waveform settings, including the addition of white noise if desired. Specify the MSO channel, trigger, and timing information. 
    6. Connect the FGEN to the device under test (DUT); connect the DUT output to the MSO channel specified above. 
    7. Click the Run button source the waveform.
    8. The stimulus response will display in the graph. 

 
As a reminder, the detailed help for each VI specifies allowable values for each input. Below is an excerpt from the MSO Configure Analog Edge Trigger VI as an example:

 
[+] Enlarge Image

 

Program Explained

 

 

[+] Enlarge Image

 

    • Initialize Session
      • The VirtualBench device information is passed into the FGEN Initialize VI to initialize a new session to the FGEN and passed to the MSO Initialize VI to initialize a new session to the MSO.
    • Configure Instrument
      • Waveform Settings
        •  Error information is passed to the Basic Function Generator VI to create the arbitrary waveform. The specified waveform information from the Waveform Settings panel is passed to the VI. 
        • The arbitrary waveform signal and error information are passed into a Case Structure. The white noise selection is used as the case selector. Select the down arrow next to the case name to select a different case to view.
          1. True case: In this case, error information is passed into the Uniform White Noise Waveform VI. The amplitude and sampling information are passed to the VI, and it outputs white noise. The generated arbitrary waveform is added to the white noise waveform to create the final waveform to output. 
          2. False case: In this case, the generated arbitrary waveform and error information are passed unchanged through the case structure.
        • Instrument information, error information, and the generated arbitrary  waveform are passed into the FGEN Configure Arbitrary Waveform VI.
      • Channel Settings
        • Instrument and error information are passed into the MSO Configure Analog Channel VI. The specified channel is passed to the VI, and the channel is enabled through a Boolean true constant. 
      • Trigger Settings
        • Instrument and error information are passed into the MSO Configure Analog Edge Trigger VI. The trigger source, slope, level, and hysteresis voltage are passed to the VI.
      • Timing Settings
        • Instrument and error information are passed into the  MSO Configure Timing. 
    • Perform Operation
      • Instrument and error information are passed to the MSO Run VI to begin acquiring with the MSO. 
      • The error wires are bundled together and then passed into the FGEN Run VI to start outputting from the FGEN. The error wires enforce data flow in order to make sure the MSO is running before the FGEN begins. 
      • Instrument and error information are passed to the MSO Read VI, and the VI outputs the stimulus response which is displayed on the front panel. 
    • Close Session
      • The instrument and error information are passed to the FGEN Close VI and then the MSO Close VI. This closes the FGEN and MSO sessions and deallocates any resources for the next time a session is created with the 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.