Acquire Temperature Data from a Thermocouple

This example shows how to read data from thermocouples using NI devices that support thermocouple measurements.

Discover Devices that Support Thermocouples

To discover a device that supports Thermocouples, click the name of the device in the list in the Command window, or access the device in the array returned by daq.getDevices command. This example uses a NI 9213 device. This is a 16 channel thermocouple module and is device 6 in our system.

devices = daq.getDevices
devices = 

Data acquisition devices:

index Vendor Device ID           Description           
----- ------ --------- --------------------------------
1     ni     cDAQ1Mod1 National Instruments NI 9205
2     ni     cDAQ1Mod2 National Instruments NI 9263
3     ni     cDAQ1Mod3 National Instruments NI 9234
4     ni     cDAQ1Mod4 National Instruments NI 9201
5     ni     cDAQ1Mod5 National Instruments NI 9402
6     ni     cDAQ1Mod6 National Instruments NI 9213
7     ni     cDAQ1Mod7 National Instruments NI 9219
8     ni     cDAQ1Mod8 National Instruments NI 9265
9     ni     Dev1      National Instruments PCIe-6363
10    ni     Dev2      National Instruments NI ELVIS II

ans = 

ni: National Instruments NI 9213 (Device ID: 'cDAQ1Mod6')
   Analog input subsystem supports:
      -0.078 to +0.078 Volts range
      Rates from 0.1 to 1351.4 scans/sec
      16 channels ('ai0' - 'ai15')
      'Voltage','Thermocouple' measurement types
This module is in slot 6 of the 'cDAQ-9178' chassis with the name 'cDAQ1'.

Add a Thermocouple Channel

Create a session, and add an analog input channel with Thermocouple measurement type and change the Rate to four scans per second.

s = daq.createSession('ni');
s.Rate = 4
s = 

Data acquisition session using National Instruments hardware:
   Will run for 1 second (4 scans) at 4 scans/second.
   Number of channels: 1
      index Type  Device   Channel MeasurementType       Range       Name
      ----- ---- --------- ------- --------------- ----------------- ----
      1     ai   cDAQ1Mod6 ai0     Voltage (Diff)  0 to +750 Celsius

Configure Channel Properties

Many properties are configured on channels individually. You can access channels through the Channels property, and see a list of properties and possible values by using the set command.

tc = s.Channels(1);
           Units: [ Celsius | Fahrenheit | Kelvin | Rankine ]
ThermocoupleType: [ Unknown | J | K | N | R | S | T | B | E ]
        Coupling: [ DC | AC ]
  TerminalConfig: [ Differential | SingleEnded | SingleEndedNonReferenced | PseudoDifferential ]
           Range: 0 to +750 Celsius
            Name: {}

In this example, set the thermocouple type to K and units to Kelvin. Make sure you match the thermocouple type to your sensor configuration.

tc.ThermocoupleType = 'K';
tc.Units = 'Kelvin';

For a quick summary of the channel type

tc = 

Data acquisition analog input voltage channel 'ai0' on device 'cDAQ1Mod6':

           Units: Kelvin
ThermocoupleType: K
        Coupling: DC
  TerminalConfig: Differential
           Range: +73 to +1523 Kelvin
            Name: ''
              ID: 'ai0'
          Device: [1x1]
 MeasurementType: 'Voltage'

Start the Acquisition

Use the startForeground function to start the acquisition.

[data,time] = startForeground(s);
plot(time, data)
xlabel('Time (secs)');
ylabel('Temperature (Kelvin)');