Example Code

Edge Detection

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 will detect edges on a digital signal and trigger on rising-only, falling-only, or both.  Can be used inside a single-cycle timed-loop.

 

 

Description

This VI uses an array of Boolean to simulate a digital signal. The program uses two Sub-VI's: Simple Edge Detection.vi and Digital Waveform Chart Maker.vi. The Simple Edge Detection Sub-VI detects rising, falling, or rising and falling edges. The edge detection works based on simple logic functions. For rising edge detection, if the current Boolean value is true AND the inverse of the previous value is true, then there is an edge. For falling edge detection, if the current Boolean value is false AND the inverse of the previous value is false, then there is an edge. To detect both rising and falling edges, a XOR function is used: if one and only one of the current or previous Boolean values is true and the other false, then there is an edge. The Digital Waveform Chart Maker.vi transposes the array of Boolean and displays the data on a chart.

 

 

Steps to Implement or Execute Code

1.     Unzip the Simple Edge Detection.zip folder.

2.     Open Simple Edge Detection Example.vi.

3.     Choose the mode: Rising Edge, Falling Edge, or Both

4.     Run the VI.

 

 

Requirements

LabVIEW 2012 (or compatible)

 

 

Additional Information or References

Front Panel:

FP.PNG

 

Block Diagram:

BD.PNG

 

 

Edge Detect Sub-VI:

edgedetectsubsnippet.png

 

Digital Waveform Chart Maker Sub-VI:

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

Comments
Vitor_Miranda
Member
Member
on

Very useful, well done!

KrisnaWisnu
Member
Member
on

thank you!

Certified LabVIEW Developer (CLD)
Certified TestStand Developer (CTD)
Using LabVIEW 8.5.1 (2008) to LabVIEW 2021
lahcene47
Member
Member
on

thanks a lot