Вы находитесь на странице: 1из 39

Pemrograman Sistem Terbenam

Week 8 – Analog to Digital Converter (ADC)

Modified from Woodin et. al.


08.10.2018

Indra Hardian Mulyadi

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 1
Background Information
• What is ADC?
• Conversion Process
• Accuracy
• Examples of ADC applications

Presenter: Craig Woodin

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 2
Signal Types
Analog Signals
• Any continuous signal that a
time varying variable of the
signal is a representation of
some other time varying
quantity
– Measures one quantity in
terms of some other quantity
– Examples
• Speedometer needle as
t
function of speed
• Radio volume as function
of knob movement

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 3
Signal Types

Digital Signals
• Consist of only two states
– Binary States
– On and off
• Computers can only
1
perform processing on
digitized signals

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 4
Analog-Digital Converter (ADC)
• An electronic integrated circuit which converts a signal
from analog (continuous) to digital (discrete) form
• Provides a link between the analog world of transducers
and the digital world of signal processing and data
handling

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 5
Analog-Digital Converter (ADC)
• An electronic integrated circuit which converts a signal
from analog (continuous) to digital (discrete) form
• Provides a link between the analog world of transducers
and the digital world of signal processing and data
handling

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 6
Analog-Digital Converter (ADC)
• An electronic integrated circuit which converts a signal
from analog (continuous) to digital (discrete) form
• Provides a link between the analog world of transducers
and the digital world of signal processing and data
handling

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 7
Value - 4
Value - 3
Value - 2
Value - 1

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 8
ADC Conversion Process

Two main steps of process


1. Sampling and Holding
2. Quantization and Encoding

Analog-to-Digital Converter

Quantizing
and
Encoding
Sampling and
Hold
t
Input: Analog Signal t

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 9
ADC Process
Sampling & Hold

• Measuring analog signals at


uniform time intervals
– Ideally twice as fast as what
we are sampling
Continuous Signal
• Digital system works with
discrete states
– Taking samples from each
location

• Reflects sampled and hold


signal t
– Digital approximation

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 10
ADC Process

Sampling & Hold

• Measuring analog signals at


uniform time intervals
– Ideally twice as fast as what
we are sampling

• Digital system works with


discrete states
– Taking samples from each
location
t
• Reflects sampled and hold signal
– Digital approximation

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 11
ADC Process

Sampling & Hold

• Measuring analog signals at


uniform time intervals
– Ideally twice as fast as
what we are sampling

• Digital system works with


discrete states
– Taking a sample from each
location
t
• Reflects sampled and hold
signal
– Digital approximation

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 12
ADC Process

Sampling & Hold

• Measuring analog signals at


uniform time intervals
– Ideally twice as fast as
what we are sampling

• Digital system works with


discrete states
– Taking samples from each
location
t
• Reflects sampled and hold
signal
– Digital approximation

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 13
ADC Process

Quantizing Encoding
• Separating the input • Assigning a unique digital
signal into a discrete code to each state for
states with K increments input into the
• K=2N microprocessor
– N is the number of bits of
the ADC
• Analog quantization size
– Q=(Vmax-Vmin)/2N
– Q is the Resolution

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 14
ADC Process

Quantization & Coding

• Use original analog


signal

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 15
ADC Process

Quantization & Coding

• Use original analog signal


• Apply 2 bit coding 11

10

01

00
K=22 00 01
10
11

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 16
ADC Process

Quantization & Coding

• Use original analog


signal 11
• Apply 2 bit coding
10

01

00
K=22 00 01
10
11

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 17
ADC Process

Quantization & Coding

• Use original analog


signal
• Apply 3 bit coding

K=23 000 001


010
011
100
101
110
Indra Hardian Mulyadi, ST., M.Eng ADC 111
indra@polibatam.ac.id Page 18
ADC Process

Quantization & Coding

• Use original analog


signal
• Apply 3 bit coding
• Better representation of
input information with
additional bits
• MCS12 has max of 10
K=23 000 001K=16 0000 K=… .
bits 010 .
011
100 .
101
110
1111
111

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 19
ADC Process-Accuracy

The accuracy of an ADC can be improved by increasing:

Ts t

Sampling Rate, fs (Satuan: Sampling per Second / SPS)


• Based on number of steps required in the conversion process
• Increases the maximum frequency that can be measured

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 20
ADC Process-Accuracy

The accuracy of an ADC can be improved by increasing:

t
Resolution (bit depth), Q
• Improves accuracy in measuring amplitude of analog
signal.
• Example: Resolution 12-bit means 4095 of division
Indra Hardian Mulyadi, ST., M.Eng ADC
indra@polibatam.ac.id Page 21
ADC-Error Possibilities
• Aliasing (sampling)
– Occurs when the input signal is changing much faster than
the sample rate
– Should follow the Nyquist Rule when sampling
• Answers question of what sample rate is required
• Use a sampling frequency at least twice as high as the
maximum frequency in the signal to avoid aliasing
• fsample>2*fsignal
• Quantization Error (resolution)
– Optimize resolution
– Dependent on ADC converter of microcontoller

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 22
Indra Hardian Mulyadi, ST., M.Eng ADC
indra@polibatam.ac.id Page 23
Indra Hardian Mulyadi, ST., M.Eng ADC
indra@polibatam.ac.id Page 24
ADC Applications
• ADC are used virtually everywhere where an analog
signal has to be processed, stored, or transported in
digital form
– Microphones
– Strain Gages
– Thermocouple
– Digital Multimeters

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 25
Cara Menghitung ADC
Diketahui:
- Resolusi 3 bit
- Tegangan referensi (Vref) = 5 Volt
- Tegangan input (VIN) = 1,2 Volt
Ditanyakan: Berapa nilai ADC nya (DIN)?
Jawab:

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 26
2,7 V ada di sini
Vref = 5
Maka DIN = 3

5,00
4,29
3,57
2,86
2,14
1,43
0,71
0,00

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 27
2,7 V ada di sini
DIN VIN
Maka DIN = 3
0 0,00
1 0,71
1
2 0,71
1,43
3 2,14
2 1,43
4 2,86
5
3 3,57
2,14
6 4,26
4
7 2,86
5,00 DIN adalah bilangan bulat positif
(unsigned integer)
5 3,57 N = resolusi ADC (dalam bit)

6 4,26
= 3,78
7 5,00 VRef

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 28
PR Rumah (Tugas Teori)
• Kerjakan soal di bawah ini dengan jawaban yang singkat pada kertas A4 putih.
Tuliskan Nama, NIM, Tanggal, dan “#TugasTeoriADC”. Kumpulkan maks. 16.10.2018
@17:00 (di meja 501).

1. Jelaskan proses internal yang dilakukan ADC untuk melakukan konversi dari analog
ke digital, serta jelaskan tiap langkah-langkah tersebut!
2. Berapa bit resolusi ADC pada STM32F407?
3. Berapa cycle waktu minimum untuk melakukan konversi pada ADC 8-bit
STM32F07?
4. Berapa volt tegangan input ADC maksimum yang diperbolehkan pada STM32F407?
5. Berapa volt tegangan input ADC minimum yang diperbolehkan pada STM32F407?
6. Berapa nilai ADC 10-bit jika tegangan input 0,8 V dan tegangan referensinya Vref =
3V?
7. Berapa tegangan input jika nilai ADC = 300 (ADC 12-bit) dan tegangan referensinya
menggunakan Vref 3 V?

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 29
Types of ADC

• Successive Approximation A/D Converter


• Flash A/D Converter
• Dual Slope A/D Converter
• Delta-Sigma A/D Converter

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 30
Fitur ADC pada STM32F4
• 16 channel: [15:0]
• 12-bit, 10-bit, 8-bit or 6-bit configurable resolution
• Single and continuous conversion modes
• Interrupt generation
• Scan mode for automatic conversion of channel 0 to
channel ‘n’
• ADC supply requirements: 2.4 V to 3.6 V at full speed
and down to 1.8 V at slower speed
• ADC input range: VREF– ≤ VIN ≤ VREF+ (VREF- VSS)

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 31
STM32F4-DISCOVERY

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 32
Indra Hardian Mulyadi, ST., M.Eng ADC
indra@polibatam.ac.id Page 33
ADC Clock
1. Clock for the analog circuitry: APB2 clock divided by a
programmable prescaler that allows the ADC to work at
fPCLK2/2, /4, /6 or /8
2. Clock for the digital interface: APB2 clock

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 34
Mode
1. Single conversion mode: ADC does one conversion
2. Continuous conversion mode: ADC starts a new
conversion as soon as it finishes one
3. Scan mode: scan a group of analog channels
4. Discontinuous mode: convert a short sequence of n
conversions (n ≤ 8)

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 35
Alignment
1. Right alignment

2. Left alignment

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 36
Sampling Time

Resolusi Minimum_Cycle
12-bit 12
10-bit 10
6-bit 8
8-bit 6

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 37
Conversion on external trigger and trigger polarity

Indra Hardian Mulyadi, ST., M.Eng ADC


indra@polibatam.ac.id Page 38
Indra Hardian Mulyadi, ST., M.Eng ADC
indra@polibatam.ac.id Page 39

Оценить