Chapter 2 Function Reference — GPCTR_Set_Application
NI-DAQ FRM for PC Compatibles 2-220
©
National Instruments Corporation
until (counter_armed = ND_NO)
GPCTR_Watch(deviceNumber, gpctrNumber, ND_COUNT, counted_value)
To calculate the measured interval, you need to 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 terminal count (see Table 2-31), 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_PERIOD_MSR. You can change the following:
•
ND_SOURCE to ND_INTERNAL_100_KHZ. With this timebase, you can measure the time
interval between 20 µs and 160 s for E Series and 445X (24 bits) devices and a time
interval of 20 µs and 11.37 hours for 6602 and 455X devices (32 bits). 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 interval will be measured from a
high-to-low to the next high-to-low 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, you can 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 also can 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 intervals longer than the
interval timebases allow.
application =
ND_SINGLE_PULSE_WIDTH_MSR
In this application, the counter is used for a single measurement of the time interval between
two transitions of the opposite polarity of the gate signal. By default, the measurement
is performed between a low-to-high and a high-to-low transition on the default I/O
connector gate pin (refer to Table 2-25). The counter counts the 20 MHz internal timebase
(
ND_
INTERNAL_20_MHZ
)
, so the resolution of measurement is 50 ns. The counter counts up
starting from 0. For the E Series and 445X devices with counter width of 24 bits, you can