Data Acquisition Toolbox
  Function/Property:
    Search    Help Desk 
addchannel    Examples   See Also

Add hardware channels to an analog input or analog output object.

Syntax

chans = addchannel(obj, hwch);

chans = addchannel(obj, hwch, index);

chans = addchannel(obj, hwch, names);

chans = addchannel(obj, hwch, index, names);

Arguments

obj
An existing analog input or analog output object.
hwch
The hardware channels added to the object. Any MATLAB vector syntax can be used.
index
(optional)
The MATLAB indices to associate with the hardware channels. Any MATLAB vector syntax can be used provided the vector elements are monotonically increasing.
names
(optional)
A cell array containing the names of the channels.
chans
A vector of channels with the same length as hwch.

Description

addchannel adds hardware channels to an existing analog input or analog output object. The added channels constitute a channel group. The values you supply for hwch depend on the hardware accessed. For National Instruments hardware, channels are "zero-based" (begin at zero). For Hewlett-Packard hardware and sound cards, channels are "one-based" (begin at one). If in doubt, consult your hardware manual.

A hardware channel can be assigned to multiple device objects, or multiple times to the same device object. For sound cards however, hardware channels cannot be assigned multiple times to the same device object. Furthermore, sound cards can be configured in one of only two ways: mono mode or stereo mode. For mono mode, hwch must be 1, while for stereo mode, hwch must be specified as [1 2].

For every hardware channel contained by a device object, there is an associated MATLAB index that is used to reference the channel. The index assignments follow these rules:

In either case, the resulting indices will begin at one and increase monotonically up to the total size of the channel group.

Hardware channels can be assigned descriptive names. Choosing a unique descriptive name may be a useful way to identify and reference channels. For a single call to addchannel, you can:

If the number of names specified in a single addchannel call is more than one but less than the number of channels to be added, then an error is returned. If a channel is to be referenced by its name, then that name must begin with a character and contain only characters, numbers, and underscores. If you are naming a large number of channels, then the makenames function may be useful. If a channel is not assigned a descriptive name, then it must be referenced by index.

Examples

Sound Card

Suppose you create the analog input object AI1 for a sound card. Sound cards have two channels that can be added to a device object. To configure the sound card to operate in "mono" mode, you must specify hwch as 1

and the ChannelName property is assigned the name Mono. You can now configure the sound card to operate in stereo mode by adding the second channel

and the ChannelName property is assigned the names Left and Right for the two hardware channels. Alternatively you can configure the sound card to operate in stereo mode with one call to addchannel.

National Instruments

Suppose you created the analog input object AI1 for a National Instruments board, and add the first four physical hardware channels (channels 0-3).

These channels are automatically assigned the indices 1-4. You can associate descriptive names with channels by passing a cell array of names.

The cell array of channel names can be created manually as shown above or with the makenames function.

You can add channels 4, 5, and 7 to the existing channel group.

The new channels are automatically assigned the indices 5-7. Suppose instead you add channels 4, 5, and 7 to the channel group and assign them indices 1-3.

The new channels are assigned the indices 1-3, and the previously defined channels are reindexed as indices 4-7. However, if you assigned channels 4, 5, and 7 to indices 6-8, an error is returned since there is a gap in the indices (index 5 has no associated hardware channel).

See Also

Functions

delete, makenames



[ Previous | Help Desk | Next ]