Example Programs

cancel
Showing results for 
Search instead for 
Did you mean: 

Using Case Structures to Turn On and Off a Digital Line Based On a Condition

Overview:
Demonstrates on writing to digital lines base on specified conditions.

Description:
On every iteration of the loop, the case structure will determine if the random number generated is greater than or less than 5, then takes action by writing out a digital line to configured port and line, either high or low.

Requirements:

  1. LabVIEW 2012 or compatible.
  2. NI-DAQmx 15.5.1 or compatible.


Steps to Implement or Execute Code:

  1. Configure the block diagram DAQ Assistant Express VIs to your digital hardware.
  2. Run this VI.
  3. Observe the status of the digital lines (High/Low) from the LED on the front panel. The Current Value shows the most recent generated values wired to the case selector of the case structure.

 
Block Diagram Steps:

  1. Generates random number ranges from 0 to 10. The result is wired to the Case Selector.
  2. If the value is less than 5, the digital line configured in the DAQ Assistant will output high and the LED on the front panel will turn on. Else, it will output low to the digital line and turn off the LED. This loop will continue running until the user clicks on the stop button.

Front Panel.PNG

 

Block Diagram.PNG

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

Regards,
Margaret Barrett
National Instruments
Applications Engineer
Digital Multimeters and LCR Meters