Example Code

Rising and Falling Thresholds 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
There may be two thresholds to consider when analyzing data: one to monitor when the data is rising, and one to monitor when the data is falling. This VI analyzes the data of a generated signal and indicates to the user if the values are "high" or "low" according to user defined thresholds and the trend of the data.

 
Description

 A sine wave is generated and the data is read 100 samples at a time. The mean and least squares slope of the data is calculated for each read. If the values are rising (positive slope) the LEDs will be set to "high" if the mean is above the rising threshold. If the values are falling (negative slope) the LEDs will be set to "low" if the mean is below the falling threshold.

 
Requirements

  • LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  • Run the VI, observe the "high" and "low" LEDs as the data crosses the rising threshold and the falling threshold.
  • Change the threshold values and observe the change in behavior of the LEDs.

 

Additional Information or References

Front Panel

FP.png

VI Block Diagram

 1.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

 

Rick C.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.