From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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

Measure the Frequency of an Analog Signal using a Counter (LabVIEW)

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 demonstrates how to acquire frequency value of analog input

 

Description:

An analog signal can be acquired and analyzed in software to determine its frequency. However, in many situations it is desirable to measure the frequency of an analog signal in hardware. A counter cannot be used to directly measure the frequency of an analog signal. Using an analog comparison event, you can generate a digital trigger that can measure the frequency and period of an analog signal using a counter. This should work with any multifunction DAQ card that has an analog input and 2 counters or more. It builds off of the LabVIEW Example Finder example, Meas Dig Freq-Buffered-Cont-Large Range 2 Ctr.vi.

Requirement:

NI LabVIEW 2012 or compatible

NI-DAQmx 9.0 or compatible

 

Steps to Implement or Execute Code:

  1. Configure the analog input parameter and counter input parameter
  2. Run the VI

2017-04-27_9-06-30.jpgBD.png

 

 

 

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

 

 

 

Additional information:

 

Measuring the Frequency of an Analog Signal in Hardware

 

Analog Input Period Counts Using Analog Comparison Event

 

National Instruments

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

Comments
NicolasZ
Member
Member
on

Hi,

There is a little thing I don't understand about this VI. I can understand the global algorithm, which is to generate an pulse which is trigerred by a certain level and slope (DAQmx Trigger Property Node) and then send it to the counter channel. What I don't understand is :

1 - why do you use a DAQmx Trigger Property Node instead of a normal DAQmx Trigger function ?

2- How the association of this DAQmx Trigger Property Node, the DAQmx Create Counter Frequency Channel  and the DAQmx Channel Property Node works (I mean here what is the role of each one and what is the kind of information transmitted between each-other) ?

3 - The DAQmx Read function is set to read only one DBL per iteration of the while loop, so how can it isolate a frequency ?

Some of those question maybe sound irrelevent, I apologize in advance in such a case.

kzamora
Member
Member
on

When I load this VI, it wants to load another VI by the name of

"Get Terminal Name with Device Prefix.vi"

but it can't find it.

Is this an omission?

WenR
Member
Member
on

Hi kzamora

I can see it has been a while since your comment, but here is a document that might help with that question.

http://digital.ni.com/public.nsf/allkb/9D58153D1B5E5B66862574C8006A30FB?OpenDocument

Regards