Example Code

Set Analog Input Sample Rate Using a Variable Frequency Measurement Through CompactDAQ

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 example works to synchronize two similar channels of different types.

 

Description

In order to synchronize two similar channels (analog input, analog output, etc.) but different types (temperature, pressure, etc.) in CompactDAQ we can wire the DAQmx Create Channel VIs in parallel and then start the task.  If we wish to then change the sampling rate of the Analog Input task with a frequency measurement we must then ensure that the sample clock of the Analog Input task is configured accordingly. In this example we synchronize a temperature and a pressure measurement with a variable frequency.

 

Requirements

Software

  • LabVIEW 2012 or compatible
  • NI-DAQmx 9.5.5 or compatible

Hardware

  • NI Multifunction DAQ Device

 

Steps to Implement or Execute Code

  1.  

    Open SyncAIwithVarFreq VI.

  2. Set the Temperature and Pressure Analog Input configurations.

  3. Split the Frequency signal between two channels, X and Y.

  4. Set the Frequency channel to ctrX and the Sample Clock Source to PFIY.

  5. Set the AI Sample Rate to the greatest expected clock frequency.

  6. Run the VI.

 

Additional Information or References

FrontPanel.png

BlockDiagram.png

Items To Note:

1) We must first split our frequency signal between two channels.  This will ensure that we can use one as a clock source and one as a measurement.

2) The Frequency Channel for measurement must be set to ctrX where X is one of the split frequency channels.

3) The Analog Input Sample Clock must be set to PFIY where Y is the remaining split frequency channel.

4) The Analog Input Sample Rate must be set to the greatest expected clock frequency.  While the actual sampling rate is set by the frequency measurement, setting this value sets the buffer size for the acquisition. 

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

National Instruments
Senior Systems Engineer

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