From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Counter and Digital Edge Detector Using FPGA with 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 FPGA Module
  • LabVIEW

Code and Documents

Attachment

Overview

This example increments a counter when an edge is detected.

 

Description

The two loops in the provided code demonstrate two functionally identical ways to store the counter value. The top loop demonstrates how to store the counter value in a shift register and the bottom loop demonstrates how to store the counter in a feedback node. The two loops also demonstrate that the use of an inverted input on a compound AND function allows a developer to easily switch between detecting a rising or falling edge.

 

Requirements to Run

  • LabVIEW 2012 (or compatible)
  • LabVIEW FPGA Module

 

Steps to Implement or Execute Code

  1. Download the VI
  2. Run the VI
  3. Click the "Digital Input" And "Digital Input 2" buttons and see the counts increasing(Optional)
  4. Replace the digital input control with the source of the digital signal being monitored for an edge.
  5. Modify the data type used to to initialize the counter so that it is approriately sized to prevent a roll over

 

Additional Information or References

VI Block Diagram

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