main content

acquire temperature data from a thermocouple -凯发k8网页登录

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)');

网站地图