From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Frequency Sweep Counter Output with DAQmx

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

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Overview

This code is an example of how to generate a frequency sweep on a counter output channel. 

Description

This VI will generate a buffer of frequency and duty cycle pairs to output to the coutner output.  Once one cycle has been performed on that frequency duty cycle pair it goes on to the next frequency duty cycle pair.  As the frequency changes, the time to execute each cycle changes.  Because of this the frequency jumps are not linear, meaning if we jumped from 1000Hz to 1002Hz, our next step will not be to 1004Hz because the period for 1000Hz and 1002Hz is not the same.  This code should account for that.

Steps to Implement or Execute Code

  1. Enter in the physical channel for the Counter Output
  2. Enter Frequency Min which is the minimum frequency that will be set to the Counter Output
  3. Enter Frequency Max which is the maximum frequency that will be set to the Counter Output
  4. Enter Sweep Duration which is the time in seconds to go from Frequency Min, to Frequency Max, and back to Frequency Min
  5. Set Duty Cycle to use during the sweep

Requirements

Software

LabVIEW 2012 or compatible

DAQmx 9.6 or compatible

Hardware

NI DAQ Hardware with a Counter Output.  Tested with a cDAQ-9188 outputting on PFI0

Additional Information

Frequency Sweep.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.

Contributors