To download NI software, including the products shown below, visit ni.com/downloads.
Overview
An example that demonstrates a way to detect peaks in a signal that has varying amplitudes with rebound and overshoot using unique characteristics of the waveform.
Description
This example is designed to detect peaks when normal threshold methods may result in inaccurate detections. The signal type that this code was designed for is derived from a pressure sensor measuring the force of an object rebounding from its surface. The data from the pressure sensor contains overshoot such that there is a second peak following the first. The code was designed to detect only the first peak, even when large changes in amplitude cause the secondary peaks of one signal to exceed the size of the primary peak for another signal. The following image shows what a typical sample looks like:
Finding only the first peak may be beneficial if you have code that triggers on the arrival of a peak. The secondary peak will get reported as well if traditional threshold methods are used, which may throw off the logic of a particular system. The logic works by using the negative peaks contained in the signal as defining characteristics to locate and report the correct "primary" peaks. The code works by first using traditional peak detection methods to locate the negative peaks since they do not contain almost any overshoot, and only occur once per signal iteration. It then creates a subset array of the waveform from one negative peak to another.
With this separate subset data, you can reverse the order of the array such that the "primary" peak we are trying to locate is guaranteed to be the first peak a standard peak detection method would find, even without a threshold. Once the peak is located in this subset, the data is un-reversed and the location as well as amplitude of the peak is added to an array of results.
This method completely ignores the secondary peaks since the reversal of the array guarantees that they will be found after the first peak, making it very useful for situations where large amplitude changes prevent thresholds from being applicable. A screenshot of the code in action is below:
Requirements
Software
Hardware
Steps to Implement or Execute Code
Additional Information or References
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.