Справочник Пользователя для National Instruments 321645c-01

Скачать
Страница из 554
Chapter 2
Function Reference — GPCTR_Set_Application
NI-DAQ FRM for PC Compatibles
2-224
©
 National Instruments Corporation
Figure 2-17.  Single Triggered Pulse Width Generation Measurement
Use the 
GPCTR_Watch
 function with entityID = 
ND_COUNT_AVAILABLE 
to monitor the 
progress of the counting process. This measurement completes when entityValue becomes 
ND_YES
. After this is completed, you can retrieve the counted value by using 
GPCTR_Watch
 
with entityID = 
ND_COUNT
, as shown in the following example code:
Create u32 variable count_available.
Create u32 variable counted_value.
repeat
{
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. 
Note
The measured interval will correspond to the most recent pulse that arrived prior 
to the invoking of 
GPCTR_Watch 
call with entityID set to 
ND_COUNT_AVAILABLE
.
Caution
There should be source transitions between gate transitions in order for this 
measurement to be correct.
0
0
NO
NO
0
Gate
Source
Count
Count
Available
Measured
Interval
NO
YES
0
0
1
2
2
Trigger
!