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

Generate Trigger after Counting N Pulses Using LabVIEW with DAQmx

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 program shows how to use counters to count an input signal and generate a trigger after a specified number of counts.


Description

This example program uses counters to count an input signal and generate a trigger after a specified number of counts. Each individual counter is capable of generating a trigger by setting the initial count equal to the requested number of pulses to skip before triggering. Once the counter counts down from the initial count to zero, the Counter Output Event will be exported, and this signal can be used as a trigger. Any number of counters can be used and set to any initial count value (as long as this value is less than the total size of the counter).

 

This particular example uses two counters; the first counter will create a start trigger after N pulses of the input signal, and the second counter will be used to create a reference (stop) trigger after X pulses, where X > N.

 

Requirements

  • LabVIEW 2012 (or compatible)
  • DAQmx 12.0 (or compatible)

 

Steps to Implement or Execute Code

  1. Specify the desired counter source
  2. Set the number of ticks
  3. Run the VI and get the counts

 

Additional Information or References
VI Snippet

DAQmx Generate Pulse After N Counts 2012 NIVerified.png

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

Daniel S.
National Instruments

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