User manual

Chapter 3 Software Overview
NI-DAQ User Manual for PC Compatibles 3-90 ni.com
(t1 in Figure 3-33) between two rising edges of the gate signal. With falling
edge-triggered gating, a counter can measure the time interval between two
falling edges of the gate signal. After you call
CTR_Config
and apply the
signal being measured to the appropriate gate, you can call
CTR_Period
to initiate period measurement. The specified counter starts counting
on the first gate edge and latches the counter value to the onboard
Hold Register after the counter detects a second gate edge. After each
period measurement, the counter reloads itself with a 0 and starts a new
measurement. Figure 3-34 shows a continuous period measurement.
Figure 3-34. Continuous Period Measurement
While the measurement is occurring, call
CTR_EvRead
to retrieve the
counter value saved in the Hold Register. The period is then equal to the
value returned by
CTR_EvRead
*
timebase.
If you choose an improper timebase frequency,
CTR_EvRead
retrieves
a smaller count value. A small count indicates that the timebase frequency
is either too low or too high compared to the gate signal. If the timebase
frequency is too low, the counter can only count a few source edges.
However, if the timebase frequency is too high, the counter counts too many
source edges, causing counter overflow. In case of counter overflow, a small
count (typically 1 or 2) is saved on the Hold Register, and the counter
reloads itself with a zero and waits for a new gate trigger to make a new
measurement.
For a pulse-width measurement, you use the same NI-DAQ calls used for
period measurement, except that you should set gateMode to high-level or
low-level gating (1 or 2). With high-level gating, a counter can measure the
duration of a positive pulse. With low-level gating, a counter can measure
the duration of a negative pulse. After you call
CTR_Period
, the counter
starts counting after the gate becomes active. When the gate becomes
SOURCE
Timebase
GATE
Periodic Signal
CTR_EvRead
Latched Count
Period
3
3*t1
t1
33
3*t1
3*t1