Example Code

Single Tone and Sweep Signal Generation with Arbitrary Waveform Generator

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

  • Modular Instrumentation

    Software

  • LabVIEW

    Driver

  • Other

Code and Documents

Attachment

 

Overview
The following example demonstrates two different approaches for generating a fixed tone and a sweep signal.


Description
This example has two options for generation. One of the options creates a waveform that contains a fixed tone at a frequency you specify as well as a tone that sweeps a frequency span that you specify. This setup generates this waveform continuously. The other option for generation is the use the triggered Arbitrary Sequence capabilities of the NI Arbitrary Waveform Generators, to generate the same single tone with a swept tone. In this case, however, the transition of the swept tone from one frequency to the next is handled by a trigger. This trigger can be a software trigger (default) or a hardware trigger that will determine the rate that the second tone sweeps the specified frequency span. Figure 1 shows an image of the front panel.

The bulk of the work of this VI is done by it's two subVIs. The first is named Create Frequency Sweep_w_Tone.vi and the second is named Calculate F1_F2.vi. The first of these two VIs is responsible for deciding how many segments the entire onboard waveform memory should be broken down into based on the number of steps set by the user. This VI then builds the two waveforms and adds them together for each frequency step of the sweep. Figure 2 is an image of the block diagram for this subVI.

The second VI, Calculat F1_F2.vi takes as inputs the samples used per step and the frequencies of the two waveforms for that particular step and calculates the number samples and exact frequencies that need to be passed to the Generate Sine Waveform VI in order to ensure phase continuity for both waveforms when transitioning from step to step. This requires finding the least common multiple of the necessary cycles for each waveform. Figure 3 is an image of the block diagram for the Calculate F1_F2 VI.


Requirements

  1. LabVIEW 2012 (or compatible)
  2. NI-Fgen


Steps to Implement or Execute Code

  1. Open the VI
  2. Select your device name and specify the frequencies that you would like to generate.
  3. You must also specify the sample rate to use as well as the number of frequency steps that you would like to use to step through the frequency span of waveform 2.

 

Additional Information or References
VI Snippet

1111.png

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

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