Products & Services Solutions Academia Support User Community Company

Learn more about Data Acquisition Toolbox   

Linearly Scaling the Data: Engineering Units

Analog Input Engineering Units Properties

The Data Acquisition Toolbox software provides you with a way to linearly scale analog input signals from your sensor. You can associate this scaling with specific engineering units, such as volts or Newtons, that you might want to apply to your data. When specifying engineering units, there are three important considerations:

The properties associated with engineering units and linearly scaling acquired data are as follows:

Property Name

Description

SensorRange

Specify the range of data you expect from your sensor.

InputRange

Specify the range of the analog input subsystem.

Units

Specify the engineering units label.

UnitsRange

Specify the range of data as engineering units.

Linearly scaled acquired data is given by the formula

scaled value = (A/D value)(units range)/(sensor range)

The A/D value is constrained by the InputRange property, which reflects the gain and polarity of your hardware channels, and is usually returned as a voltage value. You should choose an input range that utilizes the maximum dynamic range of your A/D subsystem. The best input range is the one that most closely encompasses the expected sensor range. If the sensor signal is larger than the input range, then the hardware will usually clip (saturate) the signal.

The units range is given by the UnitsRange property, while the sensor range is given by the SensorRange property. SensorRange is specified as a voltage value, while UnitsRange is specified as an engineering unit such as Newtons or g's (1 g = 9.80 m/s2). These property values control the scaling of data when it is extracted from the engine with the getdata function. You can find the appropriate units range and sensor range from your sensor's specification sheet.

For example, suppose SensorRange is [-1 1] and UnitsRange is [-10 10]. If an A/D value is 2.5, then the scaled value is (2.5)(20/2) or 25, in the appropriate units.

Example: Performing a Linear Conversion

This example illustrates how to configure the engineering units properties for an analog input object connected to a National Instruments PCI-6024E board.

An accelerometer is connected to a device which is undergoing a vibration test. Your job is to measure the acceleration and the frequency components of the device while it is vibrating. The accelerometer has a range of ±50 g, a voltage sensitivity of 99.7 mV/g, and a resolution of 0.00016 g.

The accelerometer signal is input to a Tektronix TDS 210 digital oscilloscope and to channel 0 of the data acquisition board. By observing the signal on the scope, the maximum expected range of data from the sensor is ±200 mV, which corresponds to approximately ±2 g. Given this constraint, you should configure the board's input range to ±500 mV, which is the closest input range that encompasses the expected data range.

You can run this example by typing daqdoc5_8 at the MATLAB Command Window.

  1. Create a device object — Create the analog input object AI for a National Instruments board. The installed adaptors and hardware IDs are found with daqhwinfo.

    AI = analoginput('nidaq','Dev1');
  2. Add channels — Add one hardware channel to AI.

    chan = addchannel(AI,0);
    
  3. Configure property values —- Configure the sampling rate to 200 kHz and define a two-second acquisition.

    duration = 2;
    ActualRate = setverify(AI,'SampleRate',200000);
    set(AI,'SamplesPerTrigger',duration*ActualRate)

    Configure the engineering units properties. This example assumes you are using a National Instruments PCI-6024E board or an equivalent hardware device. SensorRange is set to the maximum accelerometer range in volts, and UnitsRange is set to the corresponding range in g's. InputRange is set to the value that most closely encompasses the expected data range of ±200 mV.

    set(chan,'SensorRange',[-5 5])
    set(chan,'InputRange',[-0.5 0.5])
    set(chan,'UnitsRange',[-50 50])
    set(chan,'Units','g (1 g = 9.80 m/s/s)')
  4. Acquire data — Start the acquisition and wait before acquiring data.

    start(AI)
    wait(AI,duration+1)

    Extract and plot all the acquired data.

    data = getdata(AI);
    subplot(2,1,1),plot(data)

    Calculate and display the frequency information.

    Fs = ActualRate;
    blocksize = duration*ActualRate;
    [f,mag]= daqdocfft(data,Fs,blocksize);
    subplot(2,1,2),plot(f,mag)
  5. Clean up — When you no longer need AI, you should remove it from memory and from the MATLAB workspace.

    delete(AI)
    clear AI

Linear Conversion with Asymmetric Data

The properties related to engineering units provide a way for The Data Acquisition Toolbox software to convert raw measurement data into its original values and units.

SensorRange is the output voltage range that your sensor is capable of producing.

UnitsRange is the range of real-world values (physical phenomena) that your sensor is measuring.

In many cases, it is appropriate to set InputRange, SensorRange, and UnitsRange to the same values. However, if there are significant differences in these ranges or the data is not symmetric, then using different values for these properties might be appropriate, as illustrated in the following scenario.

Suppose you have a speed sensor that generates 5 volts to 7 volts according to the detected speed, so you set SensorRange to [5 7]. When the sensor detects a speed of 0 m/s it generates a 5-volt signal; when it senses 20 m/s, it generates a 7-volt signal; so you set UnitsRange to [0 20].

For example, when the sensor transmits 6 volts, the Data Acquisition Toolbox software converts this value according to the formula

scaled value = (Sensor output - Offset) x (UnitsRange)/(SensorRange)

scaled value = (6 V - 5 V) x (20 - 0)/(7 - 5)

scaled value = (1) x (20)/(2)

scaled value = 10 m/s

For a sensor output value of 6.5 V, scaled value = (6.5 - 5) x (20)/(2) = 15 m/s; and so on, as shown in the following graph.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS