Sei sulla pagina 1di 2

Period Measurement with a Counter - Developer Zone - National Instruments Page 1

Improve your ni.com experience. Login or Create a user profile.

Document Type: Tutorial


NI Supported: Yes
Publish Date: Sep 6, 2006

Period Measurement with a Counter


Description
One potential use for counters is to measure the period, or the length of time between successive rising edges, of an
incoming signal. A faster signal with a known frequency, usually an internal clock, is used as a reference. The counter
starts counting at a rising or falling edge, which is user-configurable, and stops counting at its successive edge. The
pulse period is the number of counts between rising edges divided by the number of counts expected in one second
(frequency of the known clock), that is, period = counts / frequency.

As an illustration, assume that you want to verify the period of a one millisecond pulse train which should be sent to
the counter's gate. You now need a known frequency to count against, so you can connect the internal clock to the
source. Suppose that this internal clock is 100 kHz. After starting the measurement, you check the counter's value and
find that is 112. Therefore, the period of the incoming pulse is 112 counts / 100000 counts per sec = .00112 seconds
(1.12 msec).

Single-Period Measurement

Multiple Period Measurements


To do multiple period measurements, you can either stop, reconfigure, and restart the counter in software (and
therefore slower and subject to software delays), or you can use buffered counting. Buffered counting latches the
counter value on each rising edge of the gate pulse. This gate signal can be provided by an external device or can be
generated by using another available counter. The measurement continues to count exactly as before regardless of
the gate signal, except that an array is returned with the number of counts between each gate edge. You can then
perform the same calculation from above to extract the time information.

Buffered Period Measurement

Period measurement is useful when the frequency of the unknown signal is much smaller than the frequency of the
source signal, so that a high accuracy is achieved. Assuming that the counter may miss or over count one pulse, the
uncertainty of the measurement (in percent) is count uncertainty / total number of counts. Thus, in the example above,
the uncertainty would be 1 / 105 = .95 %. If the source frequency were decreased to 10000, then only 10.5 = 10 counts
would be received, so the uncertainty would 1 / 10 = 10 %.

http://zone.ni.com/devzone/cda/tut/p/id/2868 03/29/2009 06:53:09 PM


Period Measurement with a Counter - Developer Zone - National Instruments Page 2

the uncertainty would be 1 / 105 = .95 %. If the source frequency were decreased to 10000, then only 10.5 = 10 counts
would be received, so the uncertainty would 1 / 10 = 10 %.
Common Applications

You should not connect the same signal to both the gate and the source when doing pulse width measurement. Doing
so yields incorrect readings because the transitions are occurring the same time.

When using buffered counter operations, the first acquired points may represent bad data in pulse measurements and
thus should be ignored. The first data point is the measured interval between the instant when the counter is armed
and when the first edge transition takes place on the counter GATE. Since there is no deterministic way of specifying
when the counter is actually armed, the first value may be incorrect. Subsequent data points acquired will not have
this problem.
Reader Comments | Submit a comment »

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial
may be made available by National Instruments, the content in this tutorial may not be completely tested and
verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each
new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S
TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).

My Profile | RSS | Privacy | Legal | Contact NI © 2009 National Instruments Corporation. All rights reserved. | E-Mail this Page

http://zone.ni.com/devzone/cda/tut/p/id/2868 03/29/2009 06:53:09 PM

Potrebbero piacerti anche