Duplicate Count Prevention
Duplicate count prevention (or synchronous counting mode) ensures that a counter returns correct data in applications that use a slow or non-periodic external source. Duplicate count prevention applies to any counter application such as measuring frequency or period. In such applications, the counter should store the number of times an external Source pulses between rising edges on the Gate signal.
Example Application That Works Correctly (No Duplicate Counting)
The following figure shows a buffered period measurement that uses an external signal as the Source.
On the first rising edge of the Gate, the current count of 7 is stored. On the next rising edge of the Gate, the counter stores a 2 since two Source pulses occurred after the previous rising edge of Gate.
The counter synchronizes or samples the Gate signal with the Source signal. So the counter does not detect a rising edge in the Gate until the next Source pulse. In this example, the counter stores the values in the buffer on the first rising Source edge after the rising edge of Gate.
Example Application That Works Incorrectly (Duplicate Counting)
In the following figure, after the first rising edge of Gate, no Source pulses occur. So the counter does not write the correct data to the buffer.
Example Application That Prevents Duplicate Counting
With duplicate count prevention enabled, the counter synchronizes both the Source and Gate signals to the maximum timebase. By synchronizing to the timebase, the counter detects edges on the Gate even if the Source does not pulse. This enables the correct current count to be stored in the buffer even if no Source edges occur in between Gate signals. Refer to the following example.
Even if the Source pulses are long, the counter increments only once for each Source pulse.
Normally, the counter value and Counter n Internal Output signals change synchronously to the Source signal. With duplicate count prevention, the counter value and Counter n Internal Output signals change synchronously to the maximum timebase.
When To Use Duplicate Count Prevention
You should use duplicate count prevention if the following conditions are true.
- You are making a counter measurement
- You are using an external signal (such as PFI x) as the counter Source
- The frequency of the external Source is 25% of your maximum timebase or less
- You can have counter value and output to change synchronously with the maximum timebase
In all other cases, you should not use duplicate count prevention.
Enabling and Disabling Duplicate Count Prevention in NI-DAQmx
NI-DAQmx enables duplicate count prevention by default except in the following cases:
- The input terminal is an onboard timebase.
- Prescaling is enabled.
- The timing type is on demand.
- The Counter Output Event Output Terminal attribute/property is used in your application.
You can enable and disable duplicate count prevention in NI-DAQmx with the Enable Duplicate Count Prevention attribute/property.