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

Correlated Buffered Period Measurement with Analog Input

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 allows you to read a period measurement from your counter pin at the same rate as your analog input.  

Description:
As described, the VI would read a period measurement and match the rate of the usage of the analog input. It will hold the previous period value (stale data) until the next period is completed.  This will get around the error,  "The requested Samples have not yet been acquired", when trying to run a buffered period measurement faster than the frequency of the signal of interest.
Basically, this VI allows you to perform a buffered period measurement at whatever rate you would like, and the value returned will be old data until the new period has completed.
This allows you to log data for period 1 to 1 with the analog input data.
Things to keep in mind:

  • The data might be stale/old.
  • The counter is correlated to the analog sample clock.
  • The analog sample rate determines the period resolution/accuracy.
  • If the sample rate gets to be high enough, it could be necessary to use producer/consumer architecture to prevent buffer overflow.


Steps to Implement or Execute Code
To implement this example:

  1. Configure the following parameters: Counter channel, Analog input channel, the sampling rate, and samples to read for    your application
  2. Run the VI
  3. (Optional) Turn on the Highlight Execution to see the flow of the VI

To execute this example:

  1. Install the required software.
  2. Connect the DAQ hardware that supports the Counter and Analog Input features
  3. Confirm the connection with the MAX with TestPanel
  4. Open the VI and refer the Implement Steps


Requirements
Software
LabVIEW 2012 or compatible
NI-DAQmx 9.0 or compatible

Hardware
cDAQ with C series Counter Input and Analog Input Module

 

fp.JPG

 

bd.JPG

 

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

Adam
Academic Product Manager
National Intruments

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