Measuring Pulse Width
You can use the counters on your measurement device to measure pulse width. Pulse-width measurements measure the time between either a rising and a falling edge, or a falling and a rising edge.
The formula for pulse width is as follows:
Pulse width (in seconds) = Count / Counter Timebase Rate
where Count is the number of ticks of the counter timebase that elapsed during one pulse width of the input signal being measured.
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 since 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.