User's Manual
Chapter 2 Function Reference — GPCTR_Set_Application
NI-DAQ FRM for PC Compatibles 2-222
©
 National Instruments Corporation
GPCTR_Watch(deviceNumber, gpctrNumber, ND_COUNT_AVAILABLE, 
count_available)
}
until (count_available = ND_YES)
GPCTR_Watch(deviceNumber, gpctrNumber, ND_COUNT, counted_value)
To calculate the measured interval, multiply the counted value by the period corresponding to 
the timebase you are using. For example, if your 
ND_SOURCE is ND_INTERNAL_20_MHZ, the 
interval will be 1/(20 MHz) = 50 ns. If the 
ND_COUNT is 4 (Figure 2-15), the actual interval is 
4 * 50 ns = 200 ns. 
When the counter reaches TC (Terminal Count), it rolls over and keeps counting. To check if 
this occurred, use the 
GPCTR_Watch function with entityID set to ND_TC_REACHED. 
Typically, you will find modifying the following parameters through the 
GPCTR_Change_Parameter function useful when the counter application is 
ND_SINGLE_PULSE_WIDTH_MSR. You can change the following:
•
ND_SOURCE to ND_INTERNAL_100_KHZ. With this timebase, you can measure pulse 
widths between 20 µs and 160 s. The resolution will be lower than if you are using the 
ND_INTERNAL_20_MHZ timebase. 
•
ND_SOURCE_POLARITY to ND_HIGH_TO_LOW.
•
ND_GATE to any legal value listed in the GPCTR_Change_Parameter function 
description.
•
ND_GATE_POLARITY to ND_NEGATIVE. The pulse width will be measured from a 
high-to-low to the next low-to-high transition of the gate signal. 
You can use the 
GPCTR_Change_Parameter function after calling 
GPCTR_Set_Application and before calling GPCTR_Control with 
action =
ND_PROGRAM or ND_PREPARE. 
To provide your timebase, connect your timebase source to one of the PFI pins on the I/O 
connector and change 
ND_SOURCE and ND_SOURCE_POLARITY to the appropriate values. 
You can also configure the other general-purpose counter for 
ND_PULSE_TRAIN_GNR and set 
ND_SOURCE of this counter to ND_OTHER_GPCTR_TC to measure pulse widths longer than 
160 s for E Series and 445X devices and 11.37 hours for 6602 and 455X devices. 
Caution Application ND_SINGLE_PULSE_WIDTH_MSR works as described only if the gate 
signal stays in the low state when 
ND_GATE_POLARITY is ND_POSITIVE, or if the 
signal stays in the high state when 
ND_GATE_POLARITY is ND_NEGATIVE while 
GPCTR_Control is executed with action = ND_ARM or action = ND_PROGRAM. If 
this criterion is not met, executing 
GPCTR_Control with action = ND_ARM or 
!










