Polybench® Reference
Follows the input signal until a peak, and then follows the Slope settings until a new peak is about to come.

Peak detector

Overview

Use the Peak Detector operator to scan a signal for either maximum (top), or minimum (bottom) values.

The peak detector follows the input signal in positive or negative direction (depending on the Type property) until the signal differential crosses 0. The output will then hold its value (Slope = 0) at the peak value, until a new peak is detected.

To test how the detector finds the next peak, the detection signal can be made visible by setting the Hold property to False, so that the output changes with a constant (linear) slope (Slope < 0 or Slope > 0).

Operator ports

Input S: Floating point values

Output S_peak: Floating point values

Properties

Find more information about changing properties here: link

Slope
type: Real value
If the Type property is set to SLOPE, then the Slope is the output return slope in units per second. If the Type property is set to RETURN, then Slope is the output return slope in number of seconds. This value can be positive or 0 only.


Type
type: Select from the list
You may select to detect the top or the bottom of the signal. Here you also select how the output resets itself, either by a RETURN slope in units per second, or a gradual return in time.
Select one of those presets:
DetectTop_SLOPE
Detect positive peaks using the SLOPE method
DetectBottom_SLOPE
Detect negative peaks using the SLOPE method
DetectTop_RETURN
Detect positive peaks using the RETURN method
DetectBottom_RETURN
Detect negative peaks using the RETURN method

For more information about the difference between RETURN and SLOPE types, see the Details section.

Hold
type: True or False
If set to True, the output will hold the peak value, until a new peak is detected.
Select one of those presets:
True or False
True may also be read like 'yes' and false like 'no'


Caption
type: Word or phrase
The name of the object in the project. This name must not contain '.' or '$' characters.

Every object has the Caption property. This property is very important, because it is the name by which Polybench recognizes this object.
It is allowed to give multiple objects the same name, as long as the objects are of the same type. In that case, a reference to this caption includes all the objects with the same caption.
In Polybench, every object can be addressed by an Address specifier, which starts with the dollar sign, for example: $My Page.My Object. 'My Page' would be the Caption of a page, and 'My Object' the Caption of an object on that page.

Documentation
type: See description
Optional documentation of this object.

It is good practice to write in short notes why you have used this object, and why its properties are set the way they are set. If this object is an operator, the Documentation text is displayed below the operator symbol.

Details

The Peak Detector offers two peak detection methods, both in two directions: top or bottom.
For example: If you want to detect a top peak, set the detection method to DetectTop. Internally the Peak Detector then follows the input signal on its way up, until the next sample value is less than the previous. At this moment a peak has been detected, and the value is put to the output. Internally, the detector will now gradually lower its value by a certain slope, until the input signal is greater than the detection line. Then the procedure starts over again.

If you set to detect bottom values, the above procedure is applied in the other direction.

The detection line can be made visible by setting Hold to False, like is done in the figure below. You can use this to find the optimal slope value of the detector, before putting the Peak Detector to work.


Shows how the peak detector tries to find peaks. The end-result would be displayed if the Hold property would be set to True.

SLOPE versus RETURN

The difference between SLOPE and RETURN is, that SLOPE sets the output to return at a constant rate of a number of units per second. RETURN sets the output to return to the average value of the last n seconds, in exactly n seconds. The RETURN method better protects agains high peak artefacts, because it will always 'return' to the average level in n seconds. The SLOPE method could take a very long time to detect a 'normal' peak again in that case.

Examples

Example: Peak Bottom Demo
This project demonstrates the Peak Detector operator. Both the RETURN and the SLOPE detection methods are used.
Change the Hold property of the peak detectors to see what happens in the background of the peak detectors.
Press the Artefact button to make the amplitude of the signal larger, and see what effect this has for the RETURN and the SLOPE detection methods.
Examples\DF0204015_001_PeakDetector_Demo.xmc