Acquire Temperature Data From an RTD
This example shows how to acquire temperature data from a Resistive temperature device (RTD) and display the readings. The device is attached inside a PC case to monitor the internal temperature changes.
Discover Devices That Support RTDs
To discover a device that supports bridge sensor measurements, access the device in the table returned by the daqlist
command. This example uses an NI 9219 module in National Instruments® CompactDAQ Chassis NI cDAQ-9178. This is a 24-Bit Universal Analog Input module and is module 7 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{7, "DeviceInfo"}
deviceInfo = ni: National Instruments NI 9219 (Device ID: 'cDAQ1Mod7') Analog input supports: 9 ranges supported Rates from 0.1 to 100.0 scans/sec 4 channels ('ai0','ai1','ai2','ai3') 'Voltage','Current','Thermocouple','RTD','Bridge' measurement types This module is in slot 7 of the 'cDAQ-9178' chassis with the name 'cDAQ1'.
Add an RTD Channel
Create a DataAcquisition, and add an analog input channel with RTD
measurement type.
dq = daq("ni"); dq.Rate = 30; ch = addinput(dq, "cDAQ1Mod7", "ai3", "RTD");
Set Sensor Properties
Refer to the sensor data sheet and match the values accordingly. In this example, an SA1-RTD series sensor from Omega® is used. Set units to "Fahrenheit"
, RTD type to "Pt3851"
, configure the RTD circuit as "FourWire"
, and set the resistance to 100 ohms.
ch.Units = "Fahrenheit"; ch.RTDType = "Pt3851"; ch.RTDConfiguration = "FourWire"; ch.R0 = 100;
Set ADCTimingMode
By default, the ADC timing mode ADCTimingMode
of the channel is set to "HighResolution"
. Set the ADCTimingMode
to "HighSpeed"
.
ch.ADCTimingMode = "HighSpeed";
Acquire and Plot Data
Use the read
command to acquire data.
data = read(dq, seconds(1));
plot(data.Time, data.cDAQ1Mod7_ai3);
degreeSign = 176;
ylabel(sprintf("Temperature (%cF)", degreeSign));