Discover NI Devices Using the Session-Based Interface

This example shows how to discover devices visible to MATLAB® and get information about channel and measurement types available in those devices.

Display a List of Available Vendors

Use the daq.getVendors command to display a list of vendors available to your machine and MATLAB.

v = daq.getVendors()
v = 

Data acquisition vendor 'National Instruments':

            ID: 'ni'
      FullName: 'National Instruments'
AdaptorVersion: '1.0'
 DriverVersion: 'n/a'
 IsOperational: true

Display a List of Available Devices

Use the daq.getDevices command to display a list of devices available to your machine and MATLAB.

d = daq.getDevices()
d = 

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

Get Details About a Device

The daq.getDevices command shows you the overview of devices available. You can run the following command or click the corresponding "Device ID" hyperlink in the Command window to get details of the device.

deviceInfo = d(1)
deviceInfo = 

ni: National Instruments NI 9205 (Device ID: 'cDAQ1Mod1')
   Analog input subsystem supports:
      4 ranges supported
      Rates from 0.6 to 250000.0 scans/sec
      32 channels ('ai0' - 'ai31')
      'Voltage' measurement type
This module is in slot 1 of the 'cDAQ-9178' chassis with the name 'cDAQ1'.

Get More Details About this Device

Use get to see more details for the device.

     ChassisName: 'cDAQ1'
    ChassisModel: 'cDAQ-9178'
      SlotNumber: '1'
          Vendor: National Instruments
              ID: 'cDAQ1Mod1'
           Model: 'NI 9205'
      Subsystems: [1x1]
     Description: 'National Instruments NI 9205'
RecognizedDevice: true

Display Subsystems of a Device

Use the Subsystems property to find all the subsystem information. To display all details about the first subsystem including the channel, type:

       CouplingsAvailable: DC
               SampleType: Scanning
 TerminalConfigsAvailable: SingleEnded,Differential
          RangesAvailable: -0.20 to +0.20 Volts,-1.0 to +1.0 Volts,-5.0 to +5.0 Volts,-10 to +10 Volts
               Resolution: 16
                RateLimit: [0.6 250000.0]
MeasurementTypesAvailable: [1x1 cell]
   DefaultMeasurementType: 'Voltage'
           NativeDataType: 'double'
            SubsystemType: AnalogInput
NumberOfChannelsAvailable: 32
             ChannelNames: [1x32 cell]

Dynamic Hardware Discovery

When you change your hardware configuration(for example, plug in a new CompactDAQ module), use the daqreset command to refresh Data Acquisition toolbox. Then use daq.getDevices to discover the changes.