|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.
|Dialog Box Options|
|Block Diagram Inputs|
|Block Diagram Outputs|
|Threshold Crossing Detection||Contains the following options:|
|Measurement Time||Contains the following option:|
|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. input data is a fixed-point number or integer with a maximum word length of 32 bits.|
|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.|
|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.|
|timeout||Indicates 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.|
|crossing||Returns TRUE when the current input data sample completes a threshold level crossing in the direction you specify.|
|output valid||Returns 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.|
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.
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.
Refer to the following VIs for examples of using the Analog Period Measurement Express VI: