Example Code

Detect Digital Edges 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

The purpose of this code is to detect digital edges in software.

 

Description

The first example (Detect Digital Edge.vi) compares an x value and the previous x value to detect whether there has been a digital edge. You can use this example by feeding the current sample into X and the previous sample into X-1. Using this example, you can specify whether you are looking for rising or falling edges.

 

This second example (Detect Digital Edge Pt by Pt .vi) implements the same ideas explored in the first example, but instead stores the previous value of the digital signal in a shift register. This example also counts the number of digital edges.

 

Steps to Implement or Execute Code

  1. Open and run vi.
  2. Select whether you would like to detect rising or falling edges.
  3. Either simulate a digital signal by toggling the x button, or alter code to take in a digital signal from a device.
  4. Edge Found? LED will become true when a digital edge is detected.

 

Requirements

Software

LabVIEW Base Development System 2012 or compatible

Hardware

No hardware is needed if you are simulating a digital signal, but the user may add functionality to read a digital signal from a device.

 

Additional Information or References

VI Block Diagram

 5061.PNG

 

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

 

James Mc
========
Ask me about Rust & NI Hardware
My writings are at https://www.wiresmithtech.com/devs/

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