Example Code

XY Threshold Peak Detection from Excel Data Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI allows the user to select a tab-delimited text file created from Excel and then detect the peaks on that data

 

Description

This VI allows the user to select a tab-delimited text file created from Excel and then detect the peaks on that data. The data input consists of two columns - X and Y. These columns are extracted and manipulated to allow the data to be processed. After the data is processed, the locations of the peaks are reconstructed from the original waveform. The waveform and peak locations are then displayed on a single graph. A threshold can be set so that only the peaks above a certain value can be detected.

Once the data is obtained, a Peak Detection VI is used to find all the peaks above a certain threshold. That threshold is determined by moving the red cursor on the XY Graph in this front panel. The number of peaks as well as the x-index location of each peak is displayed below the graph. Since the x-index location does not correspond to the actual x-value at that index, they must be reconstructed. The outputs at the right of the graph result from searching for the s-index value in the original data and placing them into a separate array. This allows the x and y values for each peak to be displayed appropriately.

 

Requirements

LabVIEW 2012 Full Development System (or compatible)

 

Steps to Implement or Execute Code

  1. Run the VI
  2. When prompted, provide Excel file that is saved in a tab-delimited text format location

Additional Information or References

Caveats and Additional Notes

The threshold can be changed or removed so that all peaks are detected. Also, the data must be saved from Excel in tab-delimited text format.

 

VI Block Diagramxy threshhold peak detect BD.png

**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.