Generating a Pulse Train with a Counter
Description
Many applications require a series of pulses produced at specific intervals (a pulse train). For some applications, a pulse train of a specific frequency is sufficient, but other applications may require the pulses to be generated from an input signal, have a specific duty cycle (the percentage of the pulse period that the pulse is high), or to start in response to a particular input. All of the counters available on National Instruments data acquisition devices can produce pulse trains, but you cannot control all pulse train characteristics on every NI counter.NI counters and NI-DAQ use two parameters, COUNT 1 (ND_COUNT_1) and COUNT 2 (ND_COUNT_2), to define the lengths of the low and high parts of the pulse train in terms of a number of source (timebase) pulses. COUNT 1 is the time, in number of source pulses, that the output signal is low, and COUNT 2 is the time that the output signal is high. If you are using negative polarity, COUNT 1 defines the high portion and COUNT 2 the low portion of the signal. Depending on the NI-DAQ function or LabVIEW VI, COUNT 1 and COUNT 2 may have other names, most of which are shown in the following table. Refer to the applicable function or VI reference for more information.
| Parameter Name | Alternative Parameter Names in Functions and VIs |
| COUNT 1 | pulse delay phase 1 pulse spec 1 |
| COUNT 2 | pulse width phase 2 pulse spec 2 |
The output frequency is source frequency / (COUNT 1 + COUNT 2), and the duty cycle (assuming positive polarity) is COUNT 1 / (COUNT 1 + COUNT 2). Since COUNT 1 + COUNT 2 must be an integer greater than 1 (and may be additionally constrained), the counter can produce only a discrete number of frequencies and a maximum frequency (in toggle mode) that is one-fourth of the source frequency. The actual output frequency is accurate to within ±1 COUNT (1 source period) or ±source frequency(Hz). Therefore, when you use higher source frequencies you can use larger COUNT values, which results in an actual output frequency that is closer to the desired output frequency.
Although the counters use COUNT 1 and COUNT 2 internally, many NI VIs/functions only require you to specify the duty cycle and frequency you want for the output pulse, then automatically calculate the appropriate values for COUNT 1 and COUNT 2 for you.

Pulse Train Generation
Finite pulse trains are produced in the same manner as continuous pulse trains, except that the counter is gated so that the gate is high for exactly the length of time it takes to generate the required number of pulses, then the gate falls low and no pulses are generated. Finite pulse trains require a second counter (or, if no more counters are available, a cleverly configured analog output) to generate the gating signal.
A start trigger can be implemented only with the PC-TIO-10 and the NI-TIO based (NI 660x) devices.
Common Applications
8253 Counters
The 8253 counter (used on the LabPC series of devices) can generate pulse trains at frequencies that are integer divisor of the internal timebase (usually 1 or 2 MHz). They can only produce a duty cycle of 50%, and the output frequency cannot be changed without restarting the counter.
Am9513 Based Counters
The Am9513 counter (used in non-E Series MIO devices and the PC-TIO-10) can, in addition to generating frequencies of integer divisors of the internal timebases (5 MHz, 1 MHz, 100 kHz, 10 kHz, 1 kHz, and 100 Hz), produce pulses with a specified duty cycle. You cannot change the frequency or the duty cycle without restarting the pulse train generation using the NI-DAQ APIs, but it is possible to do so using register-level programming (not recommended).
DAQ-STC Based Counters
The DAQ-STC counter has all of the features of the Am9513 based counters, except that the timebases are limited to 20 MHz and 100 kHz. COUNT 1 and COUNT 2 must be at least 2, so the maximum frequency that can be generated is 5 MHz. Unlike the previous counters, the frequency and duty cycle can be changed on the fly without restarting the counter or interrupting the pulse train.
NI-TIO Based Counters
The NI-TIO counters (used on the 660x devices) have all the features of STC. In addition, the NI 6602/6608 adds an 80 MHz timebase (allowing a 20 MHz output pulse). Also, the frequency and/or duty cycle can be changed on the fly without restarting the counter or interrupting the pulse train. For more information on the NI-TIO counters, refer to the 6601/6602 User Manual.
Related Links:
Frequency Shift Keying with Measurement Studio for Visual Basic
Frequency Divider (DAQ-STC)
Reader Comments | Submit a comment »
misprint in duty cycle
Hallo, I think that there is a misprint in
this document: In the second line of the
third paragraph, in the expression of the
duty cycle, the numerator should
say "COUNT 2" instead of "COUNT 1".
I take the opportunity to say that I have
found this document very interesting and
useful. Thanks.
- Jul 28, 2009
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/).
