Counting Edges
- Updated2024-12-11
- 3 minute(s) read
In edge counting applications, the counter counts edges on its Source after the counter is armed. You can configure the counter to count rising or falling edges on its Source input. You also can control the direction of counting (up or down), as described in the Controlling the Direction of Counting section. The counter values can be read on demand or with a sample clock.
Refer to the following sections for more information about edge counting options.
Single Point (On-Demand) Edge Counting
With single point (on-demand) edge counting, the counter counts the number of edges on the Source input after the counter is armed. On-demand refers to the fact that software can read the counter contents at any time without disturbing the counting process. The following figure shows an example of single point edge counting.
You also can use a pause trigger to pause (or gate) the counter. When the pause trigger is active, the counter ignores edges on its Source input. When the pause trigger is inactive, the counter counts edges normally.
You can route the pause trigger to the Gate input of the counter. You can configure the counter to pause counting when the pause trigger is high or when it is low. The following figure shows an example of on-demand edge counting with a pause trigger.
Buffered (Sample Clock) Edge Counting
With buffered edge counting (edge counting using a sample clock), the counter counts the number of edges on the Source input after the counter is armed. The value of the counter is sampled on each active edge of a sample clock and stored in the FIFO. The NI ASIC transfers the sampled values to host memory using a high-speed data stream.
The count values returned are the cumulative counts since the counter armed event. That is, the sample clock does not reset the counter. You can configure the counter to sample on the rising or falling edge of the sample clock.
The following figure shows an example of buffered edge counting. Notice that counting begins when the counter is armed, which occurs before the first active edge on Sample Clock.
Controlling the Direction of Counting
In edge counting applications, the counter can count up or down.
You can configure the counter to do the following:
- Always count up
- Always count down
- Count up when the Counter 0 B input is high; count down when it is low
For information about connecting counter signals, refer to the Default Counter/Timer Routing section.