| Data Acquisition Toolbox | Search  Help Desk |
Data Range and Engineering Units
Properties associated with engineering units allow you to control the range of data output to your D/A converter and the valid ranges that it can be set to. When data is output to a D/A converter, you must be aware of these two issues:UnitsRange property, and the D/A range is set with the OutputRange property, These are both channel properties and can be set on a per-channel basis. The range set for UnitsRange maps the data to the range set for OutputRange thereby scaling the output data accordingly.
For example, 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. 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.
ao = analogoutput('winsound')
addchannel(ao, 1);
ch = ao.Channel(1);
set(ao, 'SampleRate', 8000);
ActualRate = get(ao, 'SampleRate');
data = 2*sin(0:(2*pi/ActualRate):2*pi)';
set(ch, 'UnitsRange', [-2 2]);
set(ch, 'OutputRange', [-1 1]);
Setting the data range and engineering units is described in detail in "Engineering Unit Conversion".