ME 515 Mechatronics:
Computer Interfacing and Data
Acquisition
Asanga Ratnaweera
Dep. of Mechanical Engineering
Computer Interfacing
➢ In mechatronic systems, the PC is interfaced with
signal and power transmission components.
+ controller Actuator
-
Sensor
computer
Computer Interfacing
➢ Data Acquisition
❑ the means by which physical signals, such as
voltage, current, pressure, and temperature, are
converted into digital formats and brought into
the computer.
❑ DAQ card plugs directly into the computer bus
and interfaces to signals directly from
transducers or signal conditioning hardware.
Computer Interfacing
➢ Signal transmission components have analog outputs
or digital outputs.
➢ Data acquisition board requires very low output
impendence
❑ To reduce voltage drop when interfaced with other
devices
❑ To reduce the modification of the output voltage
carrying the measurement signal.
➢ Amplification of a sensor signal is often required to
match the signal data acquisition board characteristics.
❑ Usually maximum of 10 V and 0-20 mA of current and
achieved using inverting or non-inverting amplifiers.
Computer Interfacing
➢ Analogue signals
Signal
Sensor analog conditioned
output 0-10V,0-20mA
Analog signal DAQ PC
conditioning
Actuator Actuator
driver Analog signal
output
Computer Interfacing
➢ Conditioned digital signal has to be Transistor-to
Transistor logic (TTL) compatible.
❑ 0-0.6V for binary value 0 and 2.4-5.5V for binary
value 1.
➢ Power transmission components can receive analog
commands or digital commands from a PC.
➢ Output signals from the PC have to be made
compatible with the actuator’s or relay’s input
requirements.
❑ This usually requires a signal conversion to a higher
voltage and any current demanded by the actuator.
Computer Interfacing
➢ Digital signals
Signal
Sensor digital conditioned
output TTL compatible
Digital signal DAQ PC
conditioning
Digital signal
Power on/off to power
device converter Digital signal
output
Data Acquisition
➢ Most modern measurement and control
systems contain some form of
microprocessor.
➢ An understanding of how we transform
information from the analogue (i.e
continuous) domain to the digital (i.e
discrete) domain is therefore essential.
Elements of a Data Acquisition
System
Data Acquisition System
Block Diagram
Basics of digital encoding
➢ Computers use the binary system:
bn bn-1………… b0 = bnx2n+ bn-1x2n-1…..+ b0x20
where bi is a number between 0 and 1
Ex: 1011 = 1x23+0x22+1x21+1x20
➢ bn is commonly referred to as the ‘most significant bit
(MSB)’ and 0 b0 is commonly referred to as the ‘least
significant bit (LSB)’.
❑ Groups of 8 bits are referred to as ‘bytes’
27 20
MSB LSB
➢ The maximum integer that an n bit binary number can
represent in the decimal system is 2n-1.
❑ For example, 1111 =15.
Data Acquisition
➢ Digital to Analog (DA) and Analog to Digital
(AD) Conversion
Digital to Analog Conversion
➢ A digital-to-analog converter (DAC) takes a digital code
as its input and produces an analog voltage or current
as its output. This analog output is proportional to the
digital input.
The analogue output can only
Ex: 8-bit DAC be at certain discrete values
within some range
NI 6008 has a 12 bit DAC
❑ An 8 bit DAC has 28 possible states over the
range (including zero).
❑ If the analogue output range is from 0 to 10
➢ Resolution = Vref / (2n − 1)
V, the resolution is (10/255) =0.039 V
❑ The accuracy is specified as ±½ LSB: 0.0196 V The bit size of DAC is based on
the required resolution
Digital to Analog Converters
➢ Two standard approaches in converting digital signals
to analog signals:
❑ Binary-weighted input ❑ R/2R Ladder
A wide range of
accurate resistances
-
have to be used for
each of the resistors +
Two values of
resistors are
adequate
➢ Both methods use operational amplifiers with
negative feedback.
Digital to Analog Converters (DAC)
➢ Binary-weighted-input DAC Summing Amplifier
❑ In a binary-weighted-input DAC, the
input current in each resistor is
proportional to the column weight in the
binary numbering system. It requires
very accurate resistors and identical
1 1 1
HIGH level voltages. Vout = − R f V1 + +
1
R R2 R3
VREF 8R
The MSB is represented by the D0
Rf
largest current, so it has the smallest LSB + –
I0
D1 4R If
resistor. To simplify analysis, assume
all current goes through Rf and none D2 2R
I1 – Vout
into the op-amp. I=0
+
I2
D3 R Analog
MSB LSB
output
R f VREF D3 D2 D1 D0 I3
Vout =− + + + MSB
R 20 21 22 23 Di =0 or 1
Digital to Analog Converters (DAC)
➢ R2R ladder
❑ By calculating a Thevenin equivalent circuit for each
input, you can show that the output is proportional to
the binary weight of inputs that are HIGH.
Inputs
VREF
D0 D1 D2 D3 It can be shown that each
input that is HIGH contributes
Rf = 2R to the output (if Rf = 2R):
2R 2R 2R 2R
VREF
– Vout = − n −1−i
2R R R R Vout 2
+
VREF = input HIGH level
MSB LSB voltage
D D D D Di =0 or 1 n = number of bits
Vout = −VREF 03 + 12 + 21 + 30 i = bit number
2 2 2 2
Digital to Analog Conversion
➢ Reconstruction Filter
❑ After converting a digital signal to analog, it is
passed through a low-pass “reconstruction filter” to
smooth the stair steps in the output.
Reconstruction
Filter
Output of the DAC Final analog output
Analog to Digital Conversion (ADC)
➢ Analog-to-digital conversion is a more complicated process (than for the
DAC), and the hardware requires some conversion time, which is typically
in the microsecond range
Stage 1: Sampling and Hold
Measure analog
signals at uniform
time intervals.
The rate at which
measurements are made
is known as sampling rate
Stage 2: Quantization
Q=(Vmax-Vmin)/2N ,Q is Separating the input signal into a
the Resolution discrete states with K increments
Arduino Uno has
K=2N, N is the number of bits
a 10-bit ADC
Quantization error = ± Resolution/2
Encoding: Assigning a unique
NI 6008 DAQ has 12 bit ADC digital code to each state
ADC: Sampling Rate The amplitude of the
sampled data is misleading
➢ Selection of the appropriate
sampling rate is very important
for the accurate representation
converted signal Sampling rate = 5 Hz
➢ Ex : 10 Hz signal
Sampling rate = 11 Hz
The incorrect
frequencies in the
output data are called
aliases. Sampling rate = 18 Hz
ADC: Sampling Rate
➢ Sampling Theorem
❑ In order to recover a signal, the sampling rate
must be greater than twice the highest frequency
in the signal.
Stated as an equation, fsample > 2fa(max)
where fsample = sampling frequency
fa(max) = highest harmonic in the analog signal
If the signal is sampled less than this, the recovery process
will produce frequencies that are entirely different than in
the original signal. Arduino Uno
can sample
NI 6008 can sample analog data at
analog data at 10 kHz 9615 Hz
Major ADC Types
➢ Flash converter (fast, lesser accuracy, for video or
radar)
➢ Digital Ramp ADC (slow but simple)
➢ Successive approximation (medium speed and
accuracy, for general-purpose industrial
applications, commonly found in embedded
systems)
➢ Dual ramp (slow with very high accuracy, for
precision measurements)
➢ Sigma-Delta Converter (High resolution, No
precision external components needed)
Flash ADC
➢ The flash ADC uses a series high-speed comparators that
compare the input with reference voltages.
+VREF
Op-amp
R comparators
Input from +
1 sample- –
and-hold
R +
2 Priority
– encoder
R 7
+
6
–
If V1 > V2 the output is +Vs R
5
4
1 D0 Parallel
+
(approximately) – 3
2
4
D1 binary
D2
output
2
R +
If V2 > V1 the output is -Vs –
1
0 EN
(approximately) R
+
–
For 10-bit flash ADC, 210 -1 = 1023 R
+
–
Enable
pulses
comparators are required R
➢ Flash ADCs are fast but require 2n – 1 comparators to
convert an analog input to an n-bit binary number.
Digital-Ramp ADC
➢ The equivalent circuit of a commercial ADC IC is shown
below.
Full scale voltage range = 2RF VR / R
Digital-Ramp ADC
➢ The conversion of an analog signal to a digital
signal is done through a trial and error process.
1. The process begins with all bits zero.
2. Then the output signal from DAC analog
output op-amp Vo and analog input signal
voltage Vin is compared at the comparator.
3. If Vo < Vin , then a bit will be made high and
step two is checked.
4. The process loops through step 2 and 3 in the
form of up counting until Vo > Vin
Digital-Ramp ADC
➢ Ex: Conversion of an analog voltage Vin = 6.5V into 3 bit
digital word. Assume the Nominal voltage of the ADC is
10V.
➢ Resolution r = 10/23 = 1.25
Digital value Vo Vo< Vin
000 0 yes
001 1.25 yes
010 2.50 yes
011 3.75 yes
100 5.00 yes
101 6.25 yes
110 7.50 no
Successive Approximation ADC
➢ Much faster than
the digital ramp ADC
because it uses
digital logic to
converge on the
value closest to the
input voltage.
➢ A comparator and a
DAC are used in the
process.
Successive Approximation ADC
111
111
7 110 110
Vref VD/A
8 101 101
Vin
100 100
4
Vref 011
8 011
010 010
Vref 001
001
8
1. 2. 3. final 000
Iterations result
Sigma-Delta ADC
➢ Input over sampled, goes to integrator
➢ Integration compared with ground
➢ Iteration drives integration of error to zero
➢ Output is a stream of serial bits
Comparison of ADC’s
NI USB-6008 I/O Module
➢ Specifications:
❑ 8 analog inputs
▪ Resolution: 12 bits
▪ Sample rate: 10kS/s
▪ Voltage range: -10 to +10V)
❑ 2 analog outputs,
▪ Resolution: 12 bits
▪ Sample rate: 150 S/s
▪ Voltage range: 0 to +5 V)
❑ 12 digital I/O
❑ 32-bit counter Recommended Software: LabVIEW
Data Acquisition with NI 6008
NI 6008 Pinout diagram
NI 6008 Block diagram
LabVIEW
Virtual Instrumentation With
LabVIEW
➢ LabVIEW - Laboratory Virtual
Instrumentation Engineering Workbench
❑ A graphical development environment (“G”)
❑ A dataflow language
❑ Has native multi-threaded parallel execution
❑ A hardware communication/control platform
❑ Can target real-time and embedded hardware
Virtual Instrumentation With
LabVIEW
➢ LabVIEW Programs are called Virtual Instruments
❑ Virtual Instrument (VI) – “Software that controls external hardware
and displays data or results from that hardware to a front panel”
Block Diagram
• Accompanying “program” for front panel
Front Panel
• Components “wired” together
• Controls = Inputs; Indicators = Outputs
Why LabVIEW?
➢ LabVIEW as a multifunction environment
❑ Rapid Prototyping
❑ Out-of-the-box hardware integration
❑ Near-seamless configuration
❑ Portability of code
❑ Graphical debugging
References
➢ J. Paolo Davim, "Mechatronics" , Wiley-ISTE,
May 2011.
➢ John Billingsley , Essentials of Mechatronics
by John Billingsley , Wiley Published 2006.
➢ Kilian, Christopher T., Modern Control
Technology: Components and Systems, 2nd
Edition, Delmar Publications, 2008.