To download NI software, including the products shown below, visit ni.com/downloads.
Overview
This VI demonstrates how to count digital events on a Counter Input Channel.
Description
In this VI, the Initial Count, Count Direction, and Edge are all configurable. This VI shows how to use a secondary counter and a digital input line to count events for a specified amount of time, following an external digital trigger. Edges are counted on the primary counter's default input terminal, but it could easily be modified to count edges on a PFI or RTSI line.
The input counter will count edges on the input terminal of the counter specified in the left Physical Channel I/O control. The gating counter will generate a digital pulse on the output terminal of the counter specified in the right Physical Channel I/O control. Connect the default output line of the gating counter to the default gate line of the input counter. This will allow the gating counter to control when the input counter can count events. In this example the input counter will count edges on the default input terminal on ctr0, and the gating counter will generate a digital pulse on the default output terminal on ctr1. Connect your start trigger source to the appropriate connection specified by "Start Trigger Source" on the front panel.
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
Steps to Implement or Execute Code
Additional Information or References
VI Snippet
**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.
thank you for the detailed example, big help for a beginner like me!
Unfortunately, this example does not do what it claims - not at all.
This can be seen already by looking at step 6 on the diagram. Instead of waiting till the gate pulse is finished, the diagram just calls a sub-vi to check whether the task is done without even checking the result.
Simple tests show also that the actual time the events were counted is given by the argument of the "Wait Until Next ms", which is very unprecise.
Please see the link below for a post discussing how to get this code to function.