You are on page 1of 59

DATA ACQUISITION

Chapter VIII
Objectives
After you read, discuss, study, and apply ideas in this chapter,
you will:

1. Understand how to properly sample a signal for digital


processing
2. Understand how digitized data are coded
3. Know the components of an A/D converter
4. Understand how A/D and D/A converters function and
recognize their
limitations
5. Be aware of commercially available hardware
and software tools for data
acquisition and control
6. Understand the basics of LabVIEW
programming and data acquisition
7. Understand the effects of sampling rate and
resolution on music sampling
INTRODUCTION

Chapter 8.1
Microprocessors, microcontrollers, single-board
computers, and personal computers are in
widespread use in mechatronic and
measurement systems. It is increasingly
important for engineers to understand how to
directly access information and analog data
from the surrounding environment with these
devices.
Data Acquisition
• A process in storing data using a microprocessor
or computer.
• It provides more compact storage of the data
(magnetic, optical, or flash media vs. long rolls of
paper),
• can result in greater data accuracy,
• allows use of the data in a real-time control
system, and
• enables data processing long after the events
have occurred.
The first process is called sampling. It is to
numerically evaluate the signal at discrete
instants in time.

The result is a digitized signal. It is composed of


discrete values corresponding to each sample.
Also, it is a sequence of numbers that is an
approximation to an analog signal.
The Sampling Theorem (Shannon’s
sampling theorem)

- states that we need to sample a signal at a rate


more than two times the maximum frequency
component in the signal to retain all frequency
components.
The Sampling Theorem (Shannon’s
Sampling Theorem)

fs > 2fmax

Where:
fmax - highest frequency component in the input
analog signal
fs – sampling rate
2fmax – Nyquist frequency, the limit on the minimum
required rate
The time interval between the digital samples is

Δt = 1 ⁄ fs
Quantizing Theory

Chapter 8.2
Analog-to-digital conversion

- it is the process required to change a sampled


analog voltage into digital form.
- It involves two steps, Quantizing and Coding
Quantizing is defined as the transformation of a
continuous analog input into a set of discrete
output states.

Coding is the assignment of a digital code word


or number to each output state.
An analog-to-digital converter is an electronic
device that converts an analog voltage to a digital
code.

Its output can be directly interfaced to digital


devices such as microcontrollers and computers.

The resolution of an A/D converter is the number


of bits used to digitally approximate the analog
value of the input.
The number of possible states N is equal to
the number of bit combinations that can
be output from the converter:

N= 2n

Where,

n is the number of bits


The analog quantization size Q, sometimes called the
code width, is defined as the full-scale range of the A/D
converter divided by the number of output states:

Q = (Vmax – Vmin) ⁄N

It is a measure of the analog change that can be


resolved by the converter.
For example, the analog quantization size , Q, is 10/8 V
= 1.25 V.

This means that the amplitude of the digitized signal


has an error of at most 1.25 V.

Therefore, the A/D converter can only resolve a voltage


to within 1.25 V of the exact analog voltage.
Analog-Digital Conversion

Chapter 8.3
Introduction
To properly acquire an analog voltage signal for
digital processing, the following components must
be properly selected and applied in this sequence:

1. buffer amplifier
2. low-pass filter
3. sample and hold amplifier
4. analog-to-digital converter
5. computer
The buffer amplifier isolates the output from
the input and provides a signal in a range close
to but not exceeding the full input voltage range
of the A/D converter.

The low-pass filter is necessary to remove any


undesirable high- frequency components in the
signal that could produce aliasing.
The sample and hold amplifier maintains a fixed
input value during the short conversion time of
the A/D converter.

The converter should have a resolution and


analog quantization size appropriate to the
system and signal.

The computer must be properly interfaced to


the A/D converter system to store and process
the data.
The conversion time, also called settling time,
depends on the design of the converter, the
method used for conversion, and the speed of
the components used in the electronic design.

The term aperture time refers to the duration of


the time window and is associated with any
error in the digital output due to changes in the
input during this time.
The relationship between the aperture time and
the uncertainty in the input amplitude:

During the aperture time ΔTa, the input signal


changes by ΔV, where:
Analog-to-Digital Converters
A/D converters are designed based on a number
of different principles:

• Successive approximation,
• flash or parallel encoding,
• single-slope and dual-slope integration,
• switched capacitor, and
• delta sigma.
The successive approximation A/D converter is
very widely used because it is relatively fast and
cheap.
The fastest type of A/D converter is known as a
flash converter.
Table 8.1 lists the comparator output codes and corresponding
binary outputs for each of the states, assuming an input voltage
range of 0 to 4 V. The voltage range is set by the Vmin and Vmax
supply voltages shown in Figure 8.11 (0 V and 4 V in this
example).
The code converter is a simple combinational logic circuit. For
the 2-bit converter, the relationships between the code bits Gi
and the binary bits Bi are
B0 = G0 ⋅ G1 + G2
B1 = G1
Several analog signals can be digitized by a
single A/D converter if the analog signals are
multiplexed at the input to the A/D converter.
An analog multiplexer simply switches among
several analog inputs using transistors or relays
and control signals.

This can significantly reduce the cost of a


system’s design.
DIGITAL-TO-ANALOG
CONVERSION
Digital-to-Analog (D/A) conversion is the reverse
process of A/D conversion by changing a digital
value to an analog value.

A D/A converter allows a computer or other


digital device to interface with external analog
circuits and devices.
The simplest type of D/A converter is a resistor
ladder network connected to an
inverting summer op amp circuit as shown in
Figure 8.12 .
VIRTUAL INSTRUMENTATION, DATA
ACQUISITION, AND CONTROL
Virtual instrumentation
It is an interdisciplinary field that merges
sensing, hardware and software technologies in
order to create flexible and sophisticated
instruments for control and monitoring
applications.
PRACTICAL CONSIDERATIONS
This section introduces detailed procedures
required to use the LabVIEW software
and a USB data acquisition card to sample and
display analog signals. Specific tools
for sampling, displaying, and replaying audio signals
are also presented. Detailed
instructions are provided for the National
Instruments USB 6009, a specific USB data
acquisition module, to show how the software is
used in practice.
The USB 6009 Data Acquisition Card
The National Instruments USB 6009 is a typical
small external data acquisition
card that is connected to a computer through a
USB port.
Creating a VI and Sampling Music
This example is based on LabVIEW version 8.0,
but should be fairly compatible
with previous or later versions. The procedure
also assumes that the USB 6009 is
already set up to interface with the computer
according to the instructions that come
with the device.
Opening a blank VI file

1. Start LabVIEW with Start > Programs >


National Instruments > LabVIEW 8.0
>LabVIEW.
2. Click Blank VI to start a new project. The
Block Diagram window and the Front Panel
window should appear. If only one is open,
then under the Windows menu click Show
Block Diagram or Show Front Panel. Some
other small windows may also be open.
3. Open the Functions palette if it is not open.
From the Block Diagram window, under
the View menu, click Functions palette to
open the Functions palette.
Creating node blocks
1. From the Functions palette, select Measurement I / O
> NI - DAQmx. Drag the DAQ Assist icon onto the
Block Diagram. A DAQ Assistant window should
appear.
2. Connect the USB 6009 device to the computer. The
green light should start blinking. From the DAQ
Assistant window, select Analog Input > Voltage> ai 0
> Finish. If the ai0 does not appear, then press the
plus next to “Dev1 (USB-6009)” to display the
available analog input channels.
3. A new window will open displaying the properties of
the DAQ Assistant block
4. Under Settings, set the maximum and minimum
values for the Signal Input Range based on the
amplitude of the input and the desired quantization
size.
5. Under Settings, set the Terminal Configuration to RSE
(single-ended mode) .
6. Under the Task Timing tab, set the acquisition mode
to N samples. The wiring diagram can be view by
selecting the Connection Diagram tab towards the
bottom of the window, assuming an appropriate
range was selected. (max ≤ 10 and min ≥ -10)
7. Select Ok to close the DAQ Assistant
properties window. This may be opened later
by right-clicking on the DAQ Assistant block.
Creating terminal blocks
1. Select the wire spool icon from the Tools palette (or the
automatic icon). Right-click on the rate input (arrow on
the side of the block) on the DAQ Assistant block and
select create > control. A block labeled rate should appear
with a wire connected to the DAQ Assistant block.
2. Repeat this to create a control for the number of samples
input. These two controls will appear in the Front Panel
window.
3. Activate the Front Panel window and open the controls
palette if it is not open. From the Front Panel window,
under the View menu, select Controls Palette to open the
Controls palette.
4. From the Controls palette, select modern > graph and
drag the Waveform Graph icon onto the Front Panel
window. A block labeled “Waveform graph” will
appear in the Block Diagram window.
5. Right-click on the graph and select properties. Under
the Scales tab select Amplitude (Y-axis) in the top
pull-down menu. Deselect Autoscale and set the
maximum and minimum to the values used for the
signal input range on the DAQ Assistant block. Click
Ok to close the properties window.
6. Select the Block Diagram window and select the wire spool
icon (or automatic icon) on the Tools palette. Click on the
data output of the DAQ Assistant block and then on the
Waveform Graph block. A wire will now connect the two
blocks and it should look like the window below.
Sampling an analog signal
1. Connect an analog signal to the USB 6009.
The positive side is connected to screw
terminal 2 (AI0), and the negative side is
connected to screw terminal 1 (GND).
2. Select the Front Panel window and select the
operate value icon from the Tools palette (or
automatic icon).
3. Set the rate and number of samples controls
to appropriate values.
4. Under the Operate menu, select run to run
the program. A waveform should appear on
the Waveform Graph. A picture of the
waveform can be saved to a file by right-
clicking on the waveform and selecting Data
Operations > Export Simplified Image . . . .
Sampling music
1. Connect the output of an audio device (e.g.,
speaker wires from an amplifier, or the
headphone wires of an MP3 player) to the
inputs of the USB 6009.
2. Select a sampling rate of 44,000 kHz (the
standard high-fidelity music sampling rate) to
capture all audio frequencies without aliasing.
Because human hearing is generally limited to
the 20 Hz to 20 kHz range, any rate less than or
equal to 40,000 (from Shannon’s Sampling
Theorem) can result in aliasing (poor fidelity).
3. Add the Play Waveform block to the block diagram,
which can be found in the Functions palette:
Programming, Graphics and Sound, Sound, Output.
Press OK when the configuration dialog window
appears. Wire the data input of the Play Waveform
block to the data output of the DAQ Assistant block.
Create a constant for the timeout input of the DAQ
Assistant (using the same method used to create a
control for the rate input) and set it to 30 (the letter
icon will need to be selected from the Tools palette).
Setting the timeout to 30 allows up to 30 seconds of
music to be recorded. The block diagram should now
look like the following figure.
4. Sample the music and listen to the recorded
waveform.

You might also like