Chapter 8
Counters
8-6
ni.com
condition is not met, consider
u
sing d
u
plicate co
u
nt prevention, described
in the
section.
For information abo
u
t connecting co
u
nter signals, refer to the
section.
Period Measurement
In period meas
u
rements, the co
u
nter meas
u
res a period on its Gate inp
u
t
signal after the co
u
nter is armed. Yo
u
can config
u
re the co
u
nter to meas
u
re
the period between two rising edges or two falling edges of the Gate inp
u
t
signal.
Yo
u
can ro
u
te an internal or external periodic clock signal (with a known
period) to the So
u
rce inp
u
t of the co
u
nter. The co
u
nter co
u
nts the n
u
mber
of rising (or falling) edges occ
u
rring on the So
u
rce inp
u
t between the
two active edges of the Gate signal.
Yo
u
can calc
u
late the period of the Gate inp
u
t by m
u
ltiplying the period of
the So
u
rce signal by the n
u
mber of edges ret
u
rned by the co
u
nter.
Single Period Measurement
With single period meas
u
rement, the co
u
nter co
u
nts the n
u
mber of rising
(or falling) edges on the So
u
rce inp
u
t occ
u
rring between two active edges
of the Gate inp
u
t. On the second active edge of the Gate inp
u
t, the co
u
nter
stores the co
u
nt in a hardware save register and ignores other edges on the
Gate and So
u
rce inp
u
ts. Software then reads the stored co
u
nt.
Fig
u
re 8-7 shows an example of a single period meas
u
rement.
Figure 8-7.
Single Period Measurement
S
OURCE
GATE
Co
u
nter V
a
l
u
e
HW
Sa
ve Regi
s
ter
1
0
3
5
4
5
2