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 RTDs, 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 9219 module in National Instruments® CompactDAQ Chassis NI cDAQ-9178. This is a 24-Bit Universal Analog Input module and is module 7 in our chassis.

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 9219 (Device ID: 'cDAQ1Mod7')
   Analog input subsystem 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 session, and add an analog input channel with RTD measurement type.

s = daq.createSession('ni');
addAnalogInputChannel(s,'cDAQ1Mod7',3, 'RTD');
Warning: The Rate property was reduced to 100 due to changes in the session

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 the following values:

  • Temperature units to 'Fahrenheit'.

  • RTD type to 'Pt3851'.

  • Configure RTD circuit as 'FourWire'.

  • Set resistance to 100 ohm.

s.Channels.Units = 'Fahrenheit';
s.Channels.RTDType = 'Pt3851';
s.Channels.RTDConfiguration = 'FourWire';
s.Channels.R0 = 100;

Set Scans Rate

  • Set the session to acquire 30 scans per second.

  • Set the ADCTimingMode to 'HighSpeed'.

By default, the ADC timing mode ADCTimingMode of the channel is set to 'HighResolution'. Dealing with high resolution acquisition requires longer processing time; module NI 9219 restricts the data acquisition rate to a maximum of 2. In order to increase the rate the ADCTimingMode is set to 'HighSpeed'

s.Channels.ADCTimingMode = 'HighSpeed';
s.Rate = 30;

Start the Acquisition

Use the startForeground command to start the acquisition.

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