Example Code

Creating Custom Alarms in NI LabVIEW with Your NI USB-TC01

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.

    Hardware

  • USB-TC01

Code and Documents

Attachment

Description

Overview


LabVIEW provides an easy-to-use application development environment designed specifically for the needs of engineers and scientists. Without any prior programming experience, you can use LabVIEW to take measurements from your USB-TC01 and create custom software functionality.

LabVIEW gives you the flexibility to design your own alarm conditions and alerting methods. Typical data-logging software normally includes only built-in predefined alarms. Using LabVIEW, you programmatically define conditions that trigger the alarm and can build functionality to alert the operator with basic prompts, LED indicators, or more complex alerts such as e-mails or text messages.

Creating Custom Alarms with LabVIEW

Follow these 11 steps to add a custom alarm to your LabVIEW application.

Don’t have LabVIEW? Try it free for 7 days.

Download includes NI-DAQmx driver software

1. Start with a basic measurement VI, similar to the one created in the Taking Measurements in LabVIEW tutorial.


Figure 1. LabVIEW applications consist of a Front Panel (left) and Block Diagram (right). Use the DAQ Assistant and Time Delay functions in a while loop to continually acquire data at an interval and plot it to a chart.

 

2. Right-click on the Block Diagram, select Signal Analysis » Mask & Limit, and place it on the Block Diagram.


Figure 2. The Mask & Limit Testing function can detect if a signal is within a threshold range.

 

3. After you place the Mask & Limit function on the Block Diagram, a configuration window opens. Set a constant value for the upper limit.


Figure 3. The upper and lower limits serve as the alarm threshold.

 

4. Wire the output of the DAQ Assistant directly to the input of the Mask & Limit function. Wire the output of the Mask & Limit function to the Waveform Chart.


Figure 4. The Waveform Chart displays both the limits and the original signal on the chart.

 

5. Right-click on the Passed boolean output of the Mask & Limit function, select Create » Indicator, and name it Alarm.


Figure 5. The Passed boolean outputs "true" if the signal is within the specified limits.

 

6. Right-click on the wire between the Passed boolean output and the Alarm indicator, and select Insert » Boolean Palette » Not.


Figure 6. This Not function inverts the boolean value so the LED indicator is turned on when the measured value has failed the Mask & Limit test and is outside of the threshold.

 

7. Right-click on the Block Diagram, select Exec Control » Case Structure, and place it on the Block Diagram. Wire the output of the Not function to the Case Selector terminal of the Case Structure.


Figure 7. When the measured value is outside of the threshold, the code in the "true" case of the Case Structure  executes.

 

8. Any code can be placed within the Case Structure to execute. To play a sound, right-click on the Block Diagram, select Search, and search for the Beep function.


Figure 8. Using the search feature is a quick way to find functions on the function palette.

 

9. Drag the Beep function to the Case Structure.


Figure 9. A system beep sound plays on your computer when the signal is outside of the threshold.

 

10. Press the run button in the top left corner to start the application. 


Figure 10. The run button starts your LabVIEW application.

 

11. Right-click on the Y-axis of the Waveform Chart on the Front Panel and uncheck AutoScale Y. Manually adjust the upper and lower values on the Y-axis to more easily view the measured signal and the limit values.


Figure 11. The LED indicator turns on and a system beep sound plays if the signal is above the upper limit.

 

Download the LabVIEW Code

tc01_custom_alarms.vi

Try LabVIEW Free for 7 Days


7-day trial version of LabVIEW and NI-DAQmx driver software
System Requirements: Windows 2000 or later

What Else Can You Do with LabVIEW?

  1. Take Measurements
  2. Data Logging
  3. Conditional Logging
  4. Custom Alarms
  5. Signal Analysis
  6. Report Generation
  7. Custom User Interfaces

 

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