Example Code

Frequency Measurement of Multiple PFI Pins Using One Counter

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:

Demonstrates on measuring frequency from multiple PFI lines using one counter input channel.

Description:
This VI is designed to allow the user to sample frequency data from multiple PFI lines using a single Counter on the device. The VI is limited only to PFI input and must be used
with M-Series devices or later. This selection includes, but is not limited to: X-Series DAQ, M-Series DAQ, Compact DAQ with C-Series and USB/WLS Carriers with PFI modules.

Requirements:
LabVIEW 2012 or compatible.
NI-DAQmx 15.5.1 or compatible.

Steps to Implement or Execute Code:
1. Specify the physical channel of the counter used for frequency measurement.
2. Specify the PFI terminals at which you  connect the signals to be measured.
3. Run this VI.
4. Monitor the Frequency indicator that shows the measurement of Currently Sampled Channel.

Block Diagram Steps:

1)
a. Creates a channel to measure the frequency of a digital signal.
b. Sets the sample cloock to Implicit which means that DAQmx will choose the most appropriate default timebase.
c. Specifies the PFI input terminal to be measured.
d. Runs the task to begin acquisition.
e. Returns counter samples in terms of frequency.
f. Stops the task and returns it to the state the task was in before DAQmx Start Task VI ran.
g. Check for any error occurs in every iteration or before exiting the loop.
h. Aborts and clears the task. Then, displays any error that occurs.

2) Create a Physical Channel Array for Counter Selection

a. Use the Build Array function to assemble an array of physical channels.
b. Use the Index Array function to iteratively select a channel each time the loop updates.
c. Employ logic to incrementally select the sample channel.
(Note: These numbers will need to be updated to match the
number of channels sampled. It is currently configured for two (2) channels.)

 

Front Panel.PNG

 

2017-05-15_10-43-11.jpg

 

 

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

Patrick Corcoran
Application Engineering Specialist | Control
National Instruments

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

Comments
Sumithra_Nagappan
Member
Member
on

hi..

when i use the vi in x series daq,frequency value varies continuosly........