Data Acquisition Toolbox
  Function/Property:
    Search    Help Desk 

Configuration

After initialization, a hardware device must be configured before a task can be executed. This essentially means setting up the device with the information necessary to carry out that task. In general, each type of device requires some configuration information that is specific to that device.

For example, typical configuration information for a National Instruments board might be to collect two seconds of data from analog input hardware channels 0, 1, and 2 at a sampling rate of 10 kHz using dual channel DMA and single-ended inputs. The associated code for this configuration is shown below.

Any property value that is not explicitly set results in the default value for that property being used.

With the Data Acquisition Toolbox, configuration consists of two basic steps: mapping the hardware to a data acquisition object, and setting property values to establish the behavior of your acquisition. These steps are discussed below.

Mapping Hardware to Objects

To perform any data acquisition task, device objects must contain channels or lines. The resulting channel or line group consists of a mapping from hardware channels or lines to corresponding MATLAB indices. This mapping is done automatically when hardware channels or lines are added to a device object. For example, if hardware channels 0, 1, and 2 are added to the analog input object AI

they are automatically assigned the corresponding MATLAB indices of 1, 2, and 3, respectively.

When referencing channels or lines, it is the MATLAB indices that are used and not the hardware identifiers. Given this, you should keep in mind that MATLAB is "1-based" (indices begin at 1), while some hardware is "0-based" (hardware channels begin at 0).

The hardware channel or line assigned to a specific index depends on the hardware assignment order. For example, you can assign channels such that the first index corresponds to the first hardware channel, the second index corresponds to the fifth hardware channel, etc. If you are using scanning hardware, then this mapping defines the scan order.

Setting Property Values

You can configure an existing device object by setting its property values. As described on page 2-15, all device objects, channels, and lines have a base set of properties that can be set. In addition to the base set of properties, there may be a set of device-specific properties, which is determined by the hardware you are using. You can use the set command to return all properties for AI and their possible values.

Property values can be set using property name/property value (PV) pairs.

In addition to using the set command to assign values to properties, you can use the standard MATLAB subscripted assignment syntax.

The advantage of the set syntax is that you can assign multiple property values with one call to set whereas with subscripted assignment, you can assign only one property value at a time.

Detailed procedures for configuring Data Acquisition Toolbox objects are given in Chapter 4, "Doing More With Analog Input."

Getting Property Values

You can evaluate the current object configuration by getting the property values. For example, you can use the get command to return all the current property names and property values for AI.

You can also return specific property values.

In addition to using the get command to return property values, you can use the standard MATLAB subscripted reference syntax.

For either syntax, if a left-hand-side variable is defined, then the returned values are captured in that variable.

The advantage of the get syntax is you can return multiple property values with one command whereas with subscripted reference, you can return only one property value at a time.



[ Previous | Help Desk | Next ]