Calculates the period of an evenly sampled periodic signal using threshold crossing detection.
| Dialog Box Options |
| Block Diagram Inputs |
| Block Diagram Outputs |
| Parameter | Description |
|---|---|
| Threshold Crossing Detection | Contains the following options:
|
| Implementation | Contains the following option:
|
| Measurement Time | Contains the following option:
|
| Parameter | Description |
|---|---|
| reset | Restarts the measurement at the next crossing after input data leaves the hysteresis band. This Express VI initializes automatically the first time you call it. |
| input data | Specifies the periodic signal to measure. You can wire a 16- or 32-bit signed integer to this input. |
| threshold level | Specifies the level that, when crossed by input data in the direction you specify, defines a crossing. The value you wire to this input overrides the value you specify in the configuration dialog box. |
| hysteresis | Specifies a band around the threshold level that input data must leave before this Express VI can detect another crossing. The value you wire to this input overrides the value you specify in the configuration dialog box. |
| direction | Specifies whether to measure the period between rising or falling threshold crossings. The value you wire to this input overrides the value you specify in the configuration dialog box. |
| Parameter | Description |
|---|---|
| period (samples x 2^16) | Returns a signed 32-bit integer containing the measured period in units of input data samples, where the upper 16 bits are the integer portion and the lower 16 bits are the fractional portion. |
| crossing | Returns TRUE when the current input data sample completes a threshold level crossing in the direction you specify. |
| results valid | Returns TRUE on the same call as the crossing that completes the number of periods of the measurement. The period output is only valid when results valid is TRUE. |
The actual period in floating-point units of time is given by:
Period (sec) = period (samples x 2^16) * 2-16/loop rate,
where loop rate (in samples per second) is the time between calls to the Analog Period Measurement Express VI and must be constant for the duration of the measurement.
If you do not place a checkmark in the Interpolate crossings checkbox, the worst-case error for a given input signal frequency is determined by quantization of the measurement duration to an integer number of samples. The number of samples per period is given by
samples = sample rate (S/s) * period (s).
The maximum error (in samples) is given by
maximum error = max (samples – floor(samples), ceiling(samples)-samples).
The Interpolate crossings setting computes the linear interpolation of the crossing instant to 8-bit accuracy. The effect on measurement accuracy is dependent on the input signal. In the worst case (a perfect square wave), it has no effect, but for other signals it can provide a significant increase in accuracy.
For example, a 3600 Hz input signal sampled at 50 kS/sec consists of 50,000/3600 = 13.9 samples per period, where one period is 1/3600 = 278 µsec. If you do not place a checkmark in Interpolate crossings checkbox, the maximum error for a single-period measurement is 0.889 samples/50,000 samples/sec = 17.8 µsec, or (17.8/278) * 100 = 6.4% relative error. If the input is a sine wave and you place a checkmark in the Interpolate crossings checkbox, you can reduce the error to 0.121 µsec, or (0.121/278) * 100 = 0.044% relative error.
Refer to the Developer Zone for more information about the accuracy of the Analog Period Measurement VI.
The following figure shows when the Analog Period Measurement Express VI detects a rising crossing.

(A) The Express VI resets the measurement.
(B) The Express VI does not detect a rising crossing because the input signal did not meet the low hysteresis condition since the reset.
(C) The Express VI detects a rising crossing and begins the period measurement.
(D) The Express VI does not detect a rising crossing because the input signal did not meet the high hysteresis condition.
(E) The Express VI does not detect a rising crossing because the input signal must first meet the high hysteresis condition and then the low hysteresis condition before the VI can detect the next rising crossing.
(F) The Express VI detects the second rising crossing, completes the first period measurement, sets results valid to TRUE for one sample, and begins the next measurement from the same crossing.