This example VI demonstrates the use of state machine to build a threshold with hysteresis and introduces an example to use it.
This VI detects peaks above a threshold and hysteresis level. The following example explains the functionality in detail:
The blue line is the input signal, the red line is the threshold level, and the green line is the hysteresis level. With this VI, peaks will only be counted at the vertical dotted lines, when the values pass both threshold and hysteresis, but only if the data has not crossed both already. This way, noisy data jumping around the threshold level does not count multiple peaks.
The VI and an example of its implementation are attached. NOTE: a 'First Call?.vi' boolean must be input into the subVI in order to allow the peak counter to reset.
Steps to Implement or Execute Code
Additional Information or References
VI Block Diagram of "Threshold-hysteresis Example 2012 NIVerified.vi"
**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.