Main Content

addAnalogInputChannel

(Not recommended) Add analog input channel

This session object function is not recommended. Use DataAcquisition object functions instead. See Compatibility Considerations.

Description

example

addAnalogInputChannel(s,deviceID,channelID,measurementType) adds a channel on the device represented by deviceID, with the specified channelID, and channel measurement type represented by measurementType, to the session s. Measurement types are vendor-specific.

example

ch = addAnalogInputChannel(s,deviceID,channelID,measurementType) creates and returns the channel object ch.

example

[ch,idx] = addAnalogInputChannel(s,deviceID,channelID,measurementType) creates and returns the object ch, representing the channel that was added, and the index idx, which is an index into the array of the session object Channels property.

Examples

collapse all

s = daq.createSession('ni')
addAnalogInputChannel(s,'cDAQ1Mod3','ai0','Current');
s = daq.createSession('ni')
[ch,idx] = addAnalogInputChannel(s,'cDAQ2Mod6','ai0','Thermocouple')
s = daq.createSession('ni')
ch = addAnalogInputChannel(s,'cDAQ1Mod1',[0 2 4],'Voltage');

Input Arguments

collapse all

Data acquisition session specified as a session object handle, created using daq.createSession. Use the data acquisition session for acquisition and generation operations. Create one session per vendor and use that vendor session to perform all data acquisition operations.

Device ID specified as a character vector or string, as defined by the device vendor. Obtain the device ID by calling daq.getDevices.

Data Types: char | string

Channel ID specified as a numeric value, character vector, or string; or the physical location of the channel on the device. Supported values are specific to the vendor and device. You can add multiple channels by specifying the channel ID as a numeric vector, or an array of character vectors or strings. The index for this channel in the session display indicates the position of this channel in the session. This channel ID is not the same as channel index in the session: if you add a channel with ID 2 as the first channel in a session, the session channel index is 1.

Channel measurement type specified as a character vector or string. measurementType represents a vendor-defined measurement type. Valid measurement types include:

  • 'Voltage'

  • 'Thermocouple'

  • 'Current'

  • 'Accelerometer'

  • 'RTD'

  • 'Bridge'

  • 'Microphone'

  • 'IEPE'

Not all devices support all types of measurement.

Data Types: char | string

Output Arguments

collapse all

Analog input channel that you add, returned as an object containing a 1-by-n array of vendor-specific channel information. Use this channel object to access device and channel properties.

Channel index returned as a numeric value. With this index, you can access the array of the session object Channels property.

Version History

Introduced in R2010b

collapse all

R2020a: session object interface is not recommended

Use of this function with a session object is not recommended. To access a data acquisition device, use a DataAcquisition object with its functions and properties instead.

For more information about using the recommended functionality, see Transition Your Code from Session to DataAcquisition Interface.