Data Acquisition Toolbox
  Function/Property:
    Search    Help Desk 

Engineering Unit Conversion

The Data Acquisition Toolbox provides you with a method for scaling output data such that it is not clipped when sent to the D/A converter. In most cases, data that represents specific engineering units (Pascals, Newtons, etc.) should be scaled. When data is output to a D/A converter, you must be aware of these two issues:

You can set engineering unit (EU) conversions for each channel of data. Therefore, the properties related to EU conversions can be set on a per-channel basis. These properties are given below.

Table 5-10: Engineering Units Properties
Property
Description
OutputRange

Range of D/A converter

Units

Engineering units name

UnitsRange

Scaling factor for data in MATLAB workspace

Note:
Only linear engineering unit conversions are supported. You can perform nonlinear conversions by creating the appropriate M-file function.

For many devices, the OutputRange property is expressed in terms of gain and polarity. If data is outside the OutputRange values, it is clipped to the values set for UnitsRange. An example using UnitsRange is given in the following example.

Example: Performing a Linear Conversion

Suppose you are outputting data to one analog output channel. The output data ranges between -2 and 2 volts and the D/A converter has a maximum range of -1 volt to 1 volt. If the data is not scaled, it will be clipped since its range exceeds that of the D/A hardware. To solve this problem, you must use the UnitsRange property. As shown in the figure below, setting UnitsRange to [-2 2] scales the output data such that a value of -2 maps to -1 at the hardware level and a value of 2 maps to 1 at the hardware level.


The code below illustrates how to configure the appropriate properties.

Initialization: create the analog output object AO for a sound card. The available adaptors are found with daqhwinfo.

Configuration: Add one channel to AO, set the trigger to repeat two times, generate data to be queued, set the UnitsRange property, and queue the data with one call to putdata.

Termination: delete AO.



[ Previous | Help Desk | Next ]