Example Code

Thermocouple Threshold Triggered Relay Operation with DAQmx

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.


  • Data Acquisition (DAQ)


  • LabVIEW


  • NI DAQmx

Code and Documents



This example program takes analog input from one or more thermocouple channels and performs waveform thresholding to switch a relay when the threshold is crossed.


The program consists of two DAQmx tasks: an analog input and a digital output task. The thermocouple channels are read and passed into a for loop to apply thresholding on each channel. This generates an array of Booleans indicating whether or not a user specified threshold has been crossed. If the threshold has been crossed in any channel, a case structure is used to write to a digital line, triggering the relay.



  • LabVIEW 2011 or compatible
  • DAQmx 9.3.5 or compatible


  • DAQmx compatible thermocouple
  • Digital output controlled relay

This program was tested using an NI cDAQ-9178 chassis, an NI 9211 thermocouple module, a K type thermocouple, and an NI 9481 relay module.

Steps to Implement or Execute Code

  1. Open the attached VI.
  2. Select the proper physical channels for your thermocouples and relay.
  3. Specify the sampling parameters and thermocouple type.
  4. Specify the temperature threshold
  5. Run the program.

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

Rob B
FlexRIO Product Manager

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