EE5206-Lecture 4
EE5206-Lecture 4
Implementation
LECTURE 4
Design of
Problem Requirements Specifications
Solution
9/8/2024 8:27 AM 2
Embedded System Design- Step by Step
9/8/2024 8:27 AM 3
Embedded System Design- Step by Step
9/8/2024 8:27 AM 4
Embedded System Design- Step by Step
9/8/2024 8:27 AM 5
Embedded System Design- Step by Step
9/8/2024 8:27 AM 6
Register Based Approach
Configure facilities by
Special registers for
setting registers
• Control Registers • Digital
• Data registers inputs/outputs
• Analog inputs, ADC
• PWMs
• Serial
Communication
• Special inputs and
outputs
9/8/2024 8:27 AM 7
ADC and DAC Conversion
8
Analog Inputs - Sensors
❑ Temperature Sensors
❑ Pressure Sensors
❑ Moisture
❑ Water level
❑ Preset value
❑ etc
9/8/2024 8:27 AM 9
Student Work: Digitally Controlled Solar Micro
Inverter
❑ Develop a quick sketch of the overall solution
❑ Evaluate the requirements for ADCs/DACs
▪ Bits?
▪ Conversion time?
▪ Real-time?
Design -Embedded
System , power
inverter
9/8/2024 8:27 AM 10
ADC
❑ Digital Signal Processing is more popular
▪ Easy to implement, modify, …
▪ Low cost
❑ Data from real world are typically Analog
❑ Needs conversion system
▪ from raw measurements to digital data
▪ Consists of
• Amplifier, Filters
• Sample and Hold Circuit, Multiplexer
• ADC
11
ADC
12
Interfacing Sensors/ADC/DAC
13
Interfacing ADC
14
Interfacing ADC
15
Interfacing ADC
❑ E.g.
16
Converter Errors
❑ Offset Error ❑ Integral Linearity Error
Chap 0 18
A/D Conversion Techniques
❑ Counter or Tracking ADC
❑ Shaft Encoder
19
Counter Type ADC
❑ Block diagram ❑ Operation
– Reset and Start Counter
– DAC convert Digital output of
Counter to Analog signal
– Compare Analog input and
Output of DAC
• Vi < VDAC
– Continue counting
• Vi = VDAC
❑ Waveform
– Stop counting
– Digital Output = Output of
Counter
❑ Disadvantage
– Conversion time is varied
• 2n Clock Period for Full
Scale input
20
Tracking Type ADC
21
Successive Approximation ADC
❑ Most Commonly used in medium
to high speed Converters
❑ SAR(Successive Approximation
Register) holds the current
binary value
22
Successive Approximation ADC
❑ Circuit waveform
❑ Conversion Time
– n clock for n-bit ADC
– Fixed conversion time
23
Parallel or Flash ADC
❑ Very High speed conversion
▪ 2n –1 comparator
▪ Encoder
❑ Resolution is limited
Chap 0 24
Shaft Encoder
• Binary Encoder
❑ Elctromechanical ADC – Misalignment of mechanism
▪ Convert shaft angle to digital causes large error
output • Ex: 011 → 111 (180deg)
❑ Encoding
▪ Optical or Magnetic Sensor
❑ Applications
▪ Machine tools, Industrial robotics,
Numerical control
• Gray Encoder
– Misalignment causes 1 LSB
error
Chap 0 25
ADC options - Compare
❑ https://www.st.com/en/microcontrollers-
microprocessors/stm32-high-performance-mcus/products.html
❑ 12 bit
❑ 16 bit
❑ Number of channels
9/8/2024 8:27 AM 26
ADC
❑ 8bit ADC
❑ 12bit ADC
9/8/2024 8:27 AM 27
E.g. - PIC: Programming ADC-Polling
28
ADC in STM 32 -Discussion
9/8/2024 8:27 AM 29
DAC-Basics
Reference Voltage
❑ Types of DAC
▪ Binary Weighted Resistor
▪ R-2R Ladder
▪ Multiplier DAC
• The reference voltage is constant and is set by the manufacturer.
▪ Non-Multiplier DAC
• The reference voltage can be changed during operation.
❑ Comprised of switches, op-amps, and resistors
30
Binary Weighted Resistor
Binary Representation
Rf = R
I i
R 2R 4R 8R Vo
Most
Significant Bit
Least
Significant Bit
-VREF
31
Binary Representation
SET CLEARED
Most
Significant Bit
Least
-VREF Significant Bit
( 1 1 1 1 )2 = ( 15 )10
32
Binary Weighted Resistor
I i
R 2R 4R 8R Vo
MSB
LSB
-VREF
33
Binary Weighted Resistor
B3 B2 B1 B0 I
REF R + 2R + 4R + 8R
I = V i
B B B R 2R 4R 8R Vo
VOUT = I R f = VREF B3 + 2 + 1 + 0
2 4 8 MSB
-VREF
• More Generally:
Bi = Value of Bit i
n = Number of Bits Bi
VOUT = VREF
2 n −i −1
= VREF Digital Value Resolution
34
R-2R Ladder
VREF
MSB
LSB
35
R-2R Ladder
LSB
36
R-2R Ladder
❑ Less significant the bit, the more resistors the signal must pass through
before reaching the op-amp
LSB MSB
37
R-2R Ladder
I0 I0 I0
2 4 8
I0
R R R 2R
R 2R 2R 2R
VREF B1 B2
Op-Amp input
“Ground”
B0 − VREF VREF
I0 = =
2 R + 2 R 2 R 3R
38
R-2R Ladder
VREF B2 B1 B0 – Bi = Value of Bit i
I= + +
3R 2 4 8
Rf B2 B1 B0
VOUT = VREF + +
R 2 4 8
Rf
39
Digital to Analog Converters
Performance Specifications
❑ Resolution
❑ Reference Voltages
❑ Settling Time
❑ Linearity
❑ Speed
❑ Errors
40
Performance Specifications
Resolution
❑ Resolution: is the amount of variance in output voltage for
every change of the LSB in the digital input
VRef
Resolution = VLSB = N N = Number of bits
41
Performance Specifications
Resolution
Vout Vout
110 110
8 Volt. Levels
2 Volt. Levels
101 101
100 100
011 011
010 010
001 001
0 0 000
000
42
Performance Specifications
Reference Voltage
43
Performance Specifications
Reference Voltage
11
11
10 10
10 10
01 01
01 01
0 0
00 00 00 00
Digital Input Digital Input
44
Performance Specifications
Settling Time
❑ Settling Time: The time required for the input signal voltage to settle to
the expected output voltage(within +/- VLSB).
❑ Any change in the input state will not be reflected in the output state
immediately. There is a time lag, between the two events.
+VLSB
Expected
Voltage -VLSB
Time
Settling time
45
Performance Specifications
Linearity
❑ Linearity: is the difference between the desired analog output and the actual
output over the full range of expected values.
Desired/Approximate Output
Approximate
output
Speed
❑ Speed: Rate of conversion of a single digital input to its analog
equivalent
❑ Conversion Rate
▪ Depends on clock speed of input signal
▪ Depends on settling time of converter
Errors
❑ Non-linearity
▪ Differential
▪ Integral
❑ Gain
❑ Offset
❑ Non-monotonicity
47
Performance Specifications
Errors: Differential Non-Linearity
❑ Differential Non-Linearity: Difference in voltage step size
from the previous DAC output (Ideally All DLN’s = 1 VLSB)
Ideal Output
Analog Output Voltage
VLSB
Digital Input
48
Performance Specifications
Errors: Integral Non-Linearity
Ideal Output
Analog Output Voltage
Digital Input
49
Performance Specifications
Errors: Gain
❑ Gain Error: Difference in slope of the ideal curve and the
actual DAC output
High Gain
Digital Input
50
Performance Specifications
Errors: Offset
❑ Offset Error: A constant voltage difference between the ideal
DAC output and the actual.
▪ The voltage axis intercept of the DAC output curve is
different than the ideal.
Positive Offset
Digital Input
Negative Offset
51
Performance Specifications
Errors: Non-Monotonicity
❑ Non-Monotonic: A decrease in output voltage with an increase
in the digital input
Monotonic
Digital Input
52
STM DAC - Discussion
9/8/2024 8:27 AM 53