Acquire Temperature Data from a Thermocouple
This example shows how to read data from NI™ devices that support thermocouple measurements.
Discover Devices That Support Thermocouples
To discover a device that supports thermocouple measurements, access the device in the table returned by the daqlist command. This example uses an NI 9213 device. This is a 16 channel thermocouple module and is module 6 in the chassis.
d = daqlist("ni")
d =
12×4 table
DeviceID Description Model DeviceInfo
___________ __________________________________ _____________ ____________________
"cDAQ1Mod1" "National Instruments NI 9205" "NI 9205" [1×1 daq.DeviceInfo]
"cDAQ1Mod2" "National Instruments NI 9263" "NI 9263" [1×1 daq.DeviceInfo]
"cDAQ1Mod3" "National Instruments NI 9234" "NI 9234" [1×1 daq.DeviceInfo]
"cDAQ1Mod4" "National Instruments NI 9201" "NI 9201" [1×1 daq.DeviceInfo]
"cDAQ1Mod5" "National Instruments NI 9402" "NI 9402" [1×1 daq.DeviceInfo]
"cDAQ1Mod6" "National Instruments NI 9213" "NI 9213" [1×1 daq.DeviceInfo]
"cDAQ1Mod7" "National Instruments NI 9219" "NI 9219" [1×1 daq.DeviceInfo]
"cDAQ1Mod8" "National Instruments NI 9265" "NI 9265" [1×1 daq.DeviceInfo]
"Dev1" "National Instruments PCIe-6363" "PCIe-6363" [1×1 daq.DeviceInfo]
"Dev2" "National Instruments NI ELVIS II" "NI ELVIS II" [1×1 daq.DeviceInfo]
"Dev3" "National Instruments PCIe-6363" "PCIe-6363" [1×1 daq.DeviceInfo]
"Dev4" "National Instruments PCIe-6363" "PCIe-6363" [1×1 daq.DeviceInfo]
deviceInfo = d{6, "DeviceInfo"}
deviceInfo =
ni: National Instruments NI 9213 (Device ID: 'cDAQ1Mod6')
Analog input 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 DataAcquisition, change its scan Rate to four scans per second, and add an analog input channel with Thermocouple measurement type.
dq = daq("ni"); dq.Rate = 4; ch = addinput(dq, "cDAQ1Mod6", "ai0", "Thermocouple");
Configure Channel Properties
Set the thermocouple type to K and units to Kelvin (the thermocouple type should match the sensor configuration).
ch.ThermocoupleType = 'K'; ch.Units = 'Kelvin'; ch
ch =
Index Type Device Channel Measurement Type Range Name
_____ ____ ___________ _______ ________________ _____________________ _______________
1 "ai" "cDAQ1Mod6" "ai0" "Voltage (Diff)" "+73 to +1523 Kelvin" "cDAQ1Mod6_ai0"
Acquire and Plot Data
Use the read command to acquire data.
data = read(dq, seconds(1));
plot(data.Time, data.cDAQ1Mod6_ai0);
ylabel('Temperature (K)');
