Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Analog Period Measurement (FPGA Module)

LabVIEW 8.5 FPGA Module Help
August 2007

NI Part Number:
371599C-01

»View Product Info

Calculates the period of an evenly sampled periodic signal using threshold crossing detection.

Details  

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.
ImplementationContains the following option:
  • Input resolution—Specifies the range of the input signal in number of bits. This option determines the data type of the input signal and allows LabVIEW to optimize the implementation. Contains the following options:
    • 16 bit—Input data is represented as a signed 16-bit integer.
    • 24 bit—Input data range is limited to 24 bits aligned to the least significant bit, although this Express VI represents the data as a signed 32-bit integer. Select 24 bit if the input data is from a 24-bit input module.
    • 32 bit—Input data is represented as a signed 32-bit integer and covers a range that is greater than 24 bits.
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. You can wire a 16- or 32-bit signed integer to this input.
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 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.
crossingReturns TRUE when the current input data sample completes a threshold level crossing in the direction you specify.
results validReturns 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.

Analog Period Measurement Details

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.

Detecting a Rising Crossing

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.


Resources


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit