Example Code

Triggering a Value Change Event from a (programmatic) Digital Input

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 simple code shows a workaround to implement change detection logic for a boolean indicator, meant to represent a digital input. An example application would be a digital input line that is meant to trigger an event in an event-driven queued state machine architecture as shown in this example.

 

Description
In this case, when the digital input line goes high, we have no obvious way to have that trigger an event. We accomplish this by manually polling for change detection using a feedback node, and then creating a case structure that signals a value change.


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

 

  1. Run the example as is and toggle the boolean control on the front panel.
  2. For implementation in a VI with an event-driven architecture, replace the Simulated Digital Line Input control with the input signal of a digital line from a DAQ Assistant or DAQmx function.

 

Additional Information or References
VI Block Diagram

 1.png

 

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

 

 

Joey S.
Senior Product Manager, Software
National Instruments

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