From 12:00 PM - 8:00 PM CST on Thursday, October 18, ni.com will be undergoing system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Table Of Contents

Threshold Detector (G Dataflow)

Last Modified: January 12, 2018

Analyzes an input sequence for valid peaks and tracks the number of peaks encountered and a record of indices, which locates the points that exceed the threshold in a valid peak.

connector_pane_image
datatype_icon

reset

A Boolean that specifies whether to reset the internal state of the node.

True Resets the internal state of the node.
False Does not reset the internal state of the node.

This input is available only if you wire a double-precision, floating-point number to signal.

Default: False

datatype_icon

signal

The input sequence.

If the input sequence is less than or equal to the minimum width, this node sets the number of valid peaks to zero and returns an error.

This input accepts the following data types:

  • Waveform
  • 1D array of waveforms
  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
datatype_icon

threshold

The level that all valid peaks must equal or exceed for the duration of the minimum width.

This input accepts a double-precision, floating-point number or a 1D array of double-precision, floating-point numbers. This input accepts a 1D array of double-precision, floating-point numbers when signal is a 1D array of waveforms or a 2D array of double-precision, floating-point numbers.

Default: 0

datatype_icon

width

The minimum width, in number of samples, that the input sequence must remain at or above the threshold for the candidate peak to be considered a valid peak. This input must be greater than zero. If this input is less than or equal to zero, this node sets the number of valid peaks to zero and returns an error.

This input accepts a 32-bit signed integer or a 1D array of 32-bit signed integers. This input accepts a 1D array of 32-bit signed integers when signal is a 1D array of waveforms or a 2D array of double-precision, floating-point numbers.

Default: 1

datatype_icon

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

datatype_icon

dt

Sample period of the time-domain signal in seconds.

Set this input to 1/fs, where fs is the sampling frequency of the time-domain signal.

This input is available only if you wire a 1D array of double-precision, floating-point numbers or a 2D array of double-precision, floating-point numbers to signal.

Default: 1

datatype_icon

location mode

The mode in which to retrieve the peak location.

This input accepts a ring or a 1D array of rings. This input accepts a 1D array of rings when signal is a 1D array of waveforms or a 2D array of double-precision, floating-point numbers.

This input is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
Name Value Description
Index 0 Retrieves the peak locations as array indexes.
Time 1 Retrieves the peak locations as time in seconds.

Default: Index

datatype_icon

locations

Locations of peaks detected in terms of array index or time in seconds.

This output can return a 1D array of clusters or a 1D array of double-precision, floating-point numbers.

This output is available only if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers

Algorithm for Calculating the Location by Time

This node calculates location by time according to the following equation:

Time = Index * dt

When the input signal is a waveform or a 1D array of waveforms, dt is contained in the input signal.

Why the Peaks Found May not be the Actual Points in the Input Data

Because the peak detection algorithm uses a quadratic fit to find the peaks, the algorithm interpolates between the data points. Therefore, the indexes are not integers. In other words, the peaks found may not be actual points in the input data but may be at fractions of an index and at amplitudes not found in the input array.

datatype_icon

detected?

A Boolean that indicates whether this node detected a peak.

This output is available only if you wire a double-precision, floating-point number to signal.

datatype_icon

count

The number of valid peaks.

This output can return a 32-bit signed integer or a 1D array of 32-bit signed integers.

This output changes to index if you wire a double-precision, floating-point number to signal.

datatype_icon

index

Beginning index of the most recent peak when detected? is True.

This output changes to count if you wire one of the following data types to signal:

  • Waveform
  • 1D array of waveforms
  • 1D array of double-precision, floating-point numbers
  • 2D array of double-precision, floating-point numbers
datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Algorithm for Detecting Valid Peaks

A peak is valid where the consecutive elements of the input sequence exceed the threshold, and the number of elements that exceed the threshold is equal to at least width. This node detects the peak when the number of consecutive elements that exceed the threshold is greater than or equal to width.

The following figure shows the threshold detector result of a sinusoid waveform, where the threshold is 0.1 and width is 4. The red square represents the beginning index of a detected peak.

The following figure also shows a valid peak. Here the input waveform is a step signal. The threshold is 0.5 and width is 5. Because thirteen consecutive elements exceed the threshold, the beginning index of the peak is 7.

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported

Web Server: Not supported in VIs that run in a web application


Recently Viewed Topics