Chapter 4
Programming
©
National Instruments Corporation
4-45
General-Purpose Counter/Timer
There are two 24-bit up/down counters available for performing event
counting, pulse-width measurement, pulse and pulse train generation, etc.
Associated with each counter are load and save registers. You can use
interrupts with these counters to do buffered measurements. Each time the
counter generates an interrupt, a new set of values can be loaded into
the counters.
You can select the input signals to the counters from any of the 17 (10 PFI
and 7 RTSI) external timing I/O pins. Signals can also be output on certain
dedicated lines. For example, the pin name PFI8/CTRSRC0 means that the
clock source input for Counter 0 can come from any of the PFI/RTSI lines
but can be output only on the PFI8 line.
Chapter 4 of the DAQ-STC Technical Reference Manual contains all the
information on the DAQ-STC general-purpose counter and timer module,
with specific programming steps in the Programming Information section.
Example 1 shows simple gated event counting. Example 2 shows buffered
pulsewidth measurement, and Example 3 provides the framework for
continuous pulse generation.
Example 1
This is the example for gated event counting.
G0 counter counts the number of pulses (rising edge) that occur on the
G_Source after software arm, using PFI3 as G_Source and PFI4 as G_Gate.
The signal from G_Gate starts and stops the counter, allowing the counter
to count only when G_Gate is high. After the software arm, read from the
save register and display the counter contents. Counting and reading stop
when the counter reaches 10,000.
1.
Set up the PCI board. Use the
Setup_Mite()
function provided on
the Companion Disk.
2.
Call
MSC_IO_Pin_Configure()
to set all the PFI pins for input.
IO_Bidirection_Pin_Register
BD_i_Pin_Dir <= 0;
3.
Call
G0_Reset_All()
to reset all the necessary registers in
DAQ-STC.
Joint Reset Register
G0_Reset=1;