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

Correlate Analog Input and Frequency Measurement Using LabVIEW 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 VI correlates frequency measurement with the time base of an analog input measurement in software. 

 
Description

One applied case is the correlation of power data with temperature and pressure acquisitions in the 5-40 Hz range. The actual timing will slightly differ due to the two signal types. This VI is best suited for low frequency measurements.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Choose the counter input terminal for your signal and specify the maximum and minimum frequency range
  2. Choose the analog input channel that your analog input is connected to.
  3. Set the sample rate and samples to read.  The frequency measurement will duplicate itself the number of times of the samples to read in order to ensure you have a continuous graph.

 

Additional Information or References
VI Snippet

012.png

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

National Instruments
Applications Engineer

Visit ni.com/gettingstarted for step-by-step help in setting up your system.

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

Comments
yahya2006
Member
Member
on

Hello

how is the connection on the DAQ signal. since you are using both inputs (ai and counter) from where you get the waveform?

thanks for the post

CLSmith
NI Employee (retired)
on

Thanks for the message yahya2006,

If I interpret your question right, the waveform data from the counter is built within the while loop using the time information from the AI.  This is not effective for higher speed measurements since the measurements actually use different timing sources, as mentioned in the comments above.  Please post a reply if this does not answer your question.

Thanks,

Chris

National Instruments
Applications Engineer

Visit ni.com/gettingstarted for step-by-step help in setting up your system.
yahya2006
Member
Member
on

Hello Chris and thanks for your reply.

Actually i was testing your vi on my DAQ signal Accessory. However I was not sure if i connect the AI channel directly to the counter input since both are inputs for signal.

On the DAQ i have a generator function and i want to measure the frequency of the signal by using the counter.

Thanks

CLSmith
NI Employee (retired)
on

Yahya2006,

If order to make a frequency measurement on the signal generated by the frequency generator (square wave) you can create a frequency measurement task referencing the counter input.  Find more information on this task type below.  Alternatively, you can make a frequency measurement on an analog input signal in software by using an FFT or other frequency analysis VIs.

Frequency Measurements: How-To Guide - Developer Zone
http://zone.ni.com/devzone/cda/tut/p/id/7111

Best,

Chris

National Instruments
Applications Engineer

Visit ni.com/gettingstarted for step-by-step help in setting up your system.