PeakValley (Detect Signal Peaks and Valleys)

The PeakValley instruction is used to detect peaks and valleys (local maxima and minima) in a signal.

Syntax

PeakValley ( DestPV, DestChange, Reps, Source, Hysteresis )

Remarks

When a new peak or valley is detected, the new value and the change from the previous value are stored in variables. The minimum amount that the value of the Source array or variable must change for a new maximum or minimum to be detected is set by the Hysteresis argument.

Parameters

DestPV

Variable or array in which to store the new peak(s) or valley(s). When a new peak or valley is detected, the value of the peak or valley is loaded into the Dest argument. PeakValley will continue to load the last peak or valley value into the argument until the next peak or valley is detected. If reps is greater than 1, destination must be an array dimensioned to at least the number of reps.

Type -- Variable or Array

DestChange

Variable or array in which to store the change from the previous peak or valley. When a new peak or valley is detected, the change from the previous peak or valley is loaded in the DestChange argument. When a new peak or valley has not yet been reached, 0 will be stored. When Reps are greater than 1, DestChange must be an array that is dimensioned to Reps+1. The last array element [e.g., DestChange(Reps+1)] is used to flag when a new peak or valley is detected in any of the source inputs. The flag element is stored after the changes and is set to -1 (true) when a new peak or valley is detected and set to 0 (false) when none are detected.

Type -- Variable or Array

Reps (Repetitions)

The number of repetitions for the measurement or instruction.

Type: Constant integer (or expression that evaluates as a constant).

Source

The name of the Variable that is the input for the instruction. Right-click the parameter to display a list of defined variables.

Type: Variable

Hysteresis

The minimum amount that the input source value has to differ from the last peak or valley to be considered a new peak or valley. This would usually be entered as a constant, but the rate of change can also be derived from a variable or expression.

Type – Constant, Variable, or Expression