Analog Period Measurement Express VI

LabVIEW 2018 FPGA Module Help


Edition Date: March 2018
Part Number: 371599P-01
View Product Info

DOWNLOAD (Windows Only)


LabVIEW 2016 FPGA Module Help
LabVIEW 2017 FPGA Module Help
LabVIEW 2018 FPGA Module Help
LabVIEW 2019 FPGA Module Help
LabVIEW 2020 FPGA Module Help

Owning Palette: FPGA Math & Analysis VIs and Functions

Requires: FPGA Module

Calculates the period of an evenly sampled periodic signal using threshold crossing detection. This Express VI accepts frames of data, performs measurement on the input data, and returns a valid single result for each frame.

During run time, you can use the Scale Period VI to convert the period output to units of seconds using the sample rate you specify.

Details  Examples

Dialog Box Options
Block Diagram Inputs
Block Diagram Outputs

Dialog Box Options

ParameterDescription
Threshold Crossing DetectionContains the following options:
  • Level—Specifies the level that, when crossed by input data in the direction you specify, defines a crossing. The value you enter in this option sets the default value of the threshold level input on the block diagram.
  • Hysteresis—Specifies a band around the threshold level that input data must leave before this Express VI can detect another crossing. The Hysteresis option sets the default value of the hysteresis input on the block diagram. The input data meets the hysteresis condition following a rising crossing only after meeting the following conditions in order:

    input datathreshold level + hysteresis, followed by

    input datathreshold levelhysteresis.

    For a falling crossing, input data must meet the above conditions in reverse order.

    To improve noise suppression, set Hysteresis to the maximum value appropriate for the input signal.
  • Direction—Specifies whether to measure the period between rising or falling threshold crossings. This option sets the default value of the direction input on the block diagram.
  • Interpolate crossings—Specifies whether LabVIEW applies linear interpolation to the input data points immediately before and after the threshold crossing in order to get a more accurate estimate of the actual crossing time instance.
Measurement TimeContains the following option:
  • Number of periods—Specifies the number of periods over which to average the measurement. Increasing the value of this option results in a more accurate measurement by amortizing the fixed errors at the two crossing endpoints. Increasing the value does not require any additional logic, but this Express VI takes longer to return a result. Increase the value of this option only if you need additional accuracy and if the signal period is stable over the number of periods you select.

Block Diagram Inputs

ParameterDescription
resetRestarts 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 dataSpecifies the periodic signal to measure. input data is a fixed-point number or integer with a maximum word length of 32 bits.
threshold levelSpecifies 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.
hysteresisSpecifies 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.
directionSpecifies 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.

Block Diagram Outputs

ParameterDescription
period (samples)Returns the measured period in units of input data samples. period (samples) is a fixed-point number with a word length of 32 and an integer word length of 16.
timeoutIndicates that the Express VI failed to detect enough transitions to complete a measurement in time to avoid overflow in period (Samples). The Express VI resets the measurement after each timeout.
crossingReturns TRUE when the current input data sample completes a threshold level crossing in the direction you specify.
output validReturns TRUE on the same call as the crossing that completes the number of periods of the measurement. After returning TRUE for the previous output frame, this indicator returns FALSE, waiting for the next frame to complete. The period output is only valid when output valid is TRUE.

Analog Period Measurement Details

The actual period in floating-point units of time is given by:

Period (sec) = period (samples) * 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 rounding 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 µs. 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 µs, 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 µs, or (0.121/278) * 100 = 0.044% relative error.

Refer to the support document at ni.com for more information about the accuracy of the Analog Period Measurement Express VI.

Detecting a Rising Crossing

The following illustration 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 output valid to TRUE for one sample, and begins the next measurement from the same crossing.

Examples

Refer to the following VIs for examples of using the Analog Period Measurement Express VI:

  • labview\examples\CompactRIO\FPGA Fundamentals\FPGA Math and Analysis\Analog Period Measurement\Analog Period Measurement.lvproj
  • labview\examples\R Series\FPGA Fundamentals\FPGA Math and Analysis\Analog Period Measurement\Analog Period Measurement.lvproj

WAS THIS ARTICLE HELPFUL?

Not Helpful