Example Code

Using Counter Output as Sample Clock to Measure Digital Events

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 using pulse train from Counter Output as the sample clock source for the count edges event at the Counter Input channel.

Description:
The pulse train generated from Counter Output is internally routed to the sample clock source of the counter input.

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


Steps to Implement or Execute Code:

  1. Specify all control values on the front panel corresponding to the counter channels to be used on the DAQ device.
  2. Connects the signal to be measured to the default PFI source pin of the Counter Input terminal.
  3. Run this VI.
  4. The number of edges counted is shown on the Waveform Chart on the front panel.


Block Diagram Steps:

  1. Creates a channel to count the number of edges.
  2. Sets the source of sample clock to be the digital pulses generated by the Counter Output and internally route the signal to the Counter Input.
  3. Call the Start VI to begin counting the edges.  
  4. The counter will be polled continuously and display number of edges on the Waveform Chart.
  5. Call the Clear Task VI to clear the task and displays any error occurs.


Block Diagram Steps:

  1. Creates counter channels to generate digital pulses of defined frequency and duty cycle.
  2. Configures the pulse generation to be continuously sampling by using the DAQmx Timing VI (Implicit).
  3. Calls the Start VI to begin the pulse train generation.
  4. Loops continuously until the user presses the Stop button. Check for errors every 100 ms using the Is Task Done? VI.
  5. Call the Clear Task VI to clear the task and displays any error occurs.

2017-05-31_10-15-38.jpg

 

2017-05-31_10-16-00.jpg

 

**This document has been updated to meet the current required format for the NI Code Exchange.**
Justin Parker
National Instruments
Product Support Engineer

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