Example Code

Test Counters on DAQ Device with On The Fly Configuration Enabled

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 testing the Counter Input and Output channels.

Descriptions:
This example uses internal routing from the output terminal of the Counter Output to the input terminal of the Counter Input at which the signal will be measured.
The user may change the frequency of the pulses generated by the Counter Output on the fly. When the Measure button is clicked, the VI will return the frequency measurement of the pulses generated by the Counter Output.
For more information on the default counter input and output terminals for your device, open the NI-DAQmx Help, and refer to Counter Signal Connections found under the Device Considerations book in the table of contents.

Requirements:

  1. LabVIEW 2012 or compatible.
  2. NI-DAQmx 15.5.1 or compatible


Steps to Implement or Execute Code:

  1. Select the Physical Channel which corresponds to the counter at which pulses will be generated and acquired on the DAQ device.
  2. Enter the Output Frequency (Hz) of the pulses to be generated. You may change this value while the VI is running.
  3. Specify the range of frequencies that you expect at the Minimum/Maximum Value (Hz) controls for the counter input task.
    Note:  It is important to set the Maximum and Minimum Values of your unknown frequency as accurately as possible so the best internal timebase can be chosen to minimize measurement error.  
    The default values specify a range that can be measured by the counter using the 20MhzTimebase.
  4. Run this VI.
  5. Click on Measure button to get the Frequency (Hz) measurement.


Block Diagram Steps - Counter Input:

  1. Creates a channel to measure the frequency of a digital signal.
  2. Specifies the input terminal at which the generated signal will be measured. In this case, it is using internal routing from Counter Output terminal.
  3. Transitions the task to the running state to begin measurement.
  4. Returns the measured frequency when the user clicks on Measure button.
  5. Clears the task and displays any error occurs.


Block Diagram Steps - Counter Output:

  1. Creates a channel to generate pulse train with specified frequency and duty cycle..
  2. Sets the counter output channel to continuously sample pulse train.
  3. Transitions the task to the running state to begin measurement.
  4. Allows the user to update the Frequency of pulse train to be measured.
  5. Clears the task and displays any error occurs.

 

Front Panel.PNG

 

2017-05-31_12-59-37.jpg

 

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

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