Measuring Digital Frequency
You can use the counters of your device to measure frequency. To measure the frequency of a signal using the counters of your device, use the time base rate of your counter as a reference frequency. To configure your measurement, specify the expected range of the input signal, so that NI-DAQmx can choose its timebase to provide the highest resolution for the measurement. You can calculate the frequency of your signal based on the timebase rate and the number of counts using the following formula:
Frequency (in Hz) = Counter Timebase Rate / Count
To get the period of the signal, take inverse of the frequency. If, for example, the timebase rate of your measurement device is 100 MHz and you are counting 500 counts, the frequency of the input signal is 200kHz.
The Counter Timebase Rate is a known frequency (20 MHz or 100 kHz) and allows you to make frequency and time measurements. To configure a measurement, you specify the expected range of the input signal. Based on this range, NI-DAQmx automatically picks the internal timebase that provides the highest resolution for your measurement and uses it as the counter timebase.
Depending on the phase of the input signal in relation to the start of the measurement, the first sample of continuous measurements is often invalid. For instance, if you are performing a continuous period measurement, and you start the measurement when the input signal is halfway through its current cycle, the measured period for the first sample is half of its expected value. Subsequent samples indicate the correct values because they are guaranteed to have seen a full period of the input signal. For this reason, the first sample of continuous period, pulse-width, and semiperiod measurements often indicates a smaller value than the actual value. For continuous frequency measurements, the first sample often indicates a higher frequency than the actual frequency.
For frequency measurements, you also can perform measurements with one or two counters. For most applications, setting Measurement Method to 1 Counter (Low Frequency) is sufficient and desirable because it uses fewer resources. However, if you have a high-frequency or widely varying signal, you may wish to use one of the two counter measurement methods—2 Counters (High Frequency) or 2 Counters (Large Range). Depending on the rate of your input signal and measurement method used, your measurement is subject to different quantization error. NI-DAQmx automatically internally routes as needed to perform the measurement across paired counters.