Overview:
Demonstrates on counting digital edges within a finite high time of a digital pulse generated from a secondary counter.
Description:
This example demonstrates how to count digital events on a Counter Input Channel by using secondary counter i.e. Counter Output pulse as the gate. The Counter Output will generate a pulse with the specified period of high time when it detects a rising/falling edge from the Start Trigger Source. On the other hand, the Counter Input will count the edges within the high time of the single pulses generated.
Edges are counted on the primary counter's default input terminal (refer to section IV, I/O Connections Overview, for more information), but it could easily be modified to count edges on a PFI or RTSI line.
Requirements:
- LabVIEW 2012 or compatible.
- NI-DAQmx 15.5.1 or compatible.
- DAQ device with at least 2 counters.
Steps to Implement or Execute Code:
- Select the Physical Channel that corresponds to the counter at which edge counting takes place i.e. Counter Input.
- Enter the Initial Count, Count Direction, and measurement Edge to specify how the counter counts the edges. Additionally, you can change the input terminal (PFI pin) where events are counted using the channel property node.
- Select the Physical Channel which corresponds to the secondary counter that generates a single pulse on the DAQ device i.e. Counter Output - Gate.
- Enter the Gate Length, Idle State, and Initial Delay to specify how the gate signal is generated. Gate Length is the high time of the pulse generated which corresponds to the finite period within which the edge counting will take place.
- Select the Start Trigger Source and the Trigger Edge for the Digital Start Trigger.
- Run this VI.
- Verify the number of edges counted from the indicator on the front panel.
I/O Connections Overview:
- Connect digital pulses to be measured to the default PFI terminal of the specified Counter Input.
- Connect the default Output pin of the Counter Output to the default Gate pin of the Counter Input. This will allow the generated pulse to control when the Counter Input count the edges.
- Connect digital signal to the PFI line as specified at the Start Trigger Source control.
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.
Block Diagram Steps:
- Create a Counter Input channel to Count Events. The Edge parameter is used to determine if the counter will increment on rising or falling edges.
- Create a Counter Output channel to produce a Pulse in terms of Time. If the Idle State of the pulse is set to low, the state of the line will begin low and remain low after the generation is stopped.
- Call the DAQmx Start Trigger VI to configure the pulse to begin on a digital trigger.
- Call the Start VI in each task to arm the counters and begin counting or generating. The input counter will be preloaded with the Initial Count. The pulse will not begin until the generating counter receives a digital trigger and after the Initial Delay (in seconds) has expired.
- Use the Wait Until Done VI to ensure the entire gate pulse is generated before ending the task.
- Call the DAQmx Read VI to poll the input counter after the gate pulse generation has finished.
- Call the Clear Task VI to clear each Task.
- Use the popup dialog box to display an error, if any.


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