8051 interfacing da converters
TRANSCRIPT
DA Converters
GROUP 4
DEEC –MPIN
FEUP
April, 2010
April 10
José Borges, Patrício Lima, Marcos Brito, Marek Mastyło, Jakub Nyk
Outlines
April 10 2
1. Overview of DA converter types
• Four-bit DA converter
• R-2R ladder
2. Principle of operation
3. DAC performance
4. Applications
Overview of DA converter types
April 10 3
DAC is very important in electronics
DA converter transforms digital binary input signal into
analog output signal (e.g. voltage, current)
A typical DAC converts the abstract numbers into a
concrete sequence of impulses that are then
processed by a reconstruction filter using some form of
interpolation to fill in data between the impulses
Overview of DA converter types
April 10 4
Digital-to-analog (D/A) converters (sometimes called
DACs) are used to present the results of digital
computation, storage, or transmission, typically for
graphical display or for the control of devices that
operate with continuously varying quantities
The output of the D/A converter is proportional to the
product of the digital input value and the reference
Overview of DA converter types
April 10 5
Sampled data can be reconstructed perfectly provided
that its bandwidth meets certain requirements
Reconstructed signal should be a baseband signal
with bandwidth less than the Nyquist frequency
Overview of DA converter types
April 10 6
Instead of impulses, usually the sequence of numbers
update the analogue voltage at uniform sampling
intervals
Numbers are written to the DAC
Numbers are lanched in sequence with clock signal
Overview of DA converter types
April 10 7
It causes that DAC output voltage changes rapidly
from the previous value to the value represented by
the currently latched number
Output signal value is held in time at the current value
Every next latched number casues changes of current
output signal value
Overview of DA converter types
April 10 8
Example: Transform of latched number to output signal
value:
Sign bit can be used
MSB – bit 1 Bit 2 LSB – bit 3 Value
0 0 0 0.0
0 0 1 0.125
0 1 0 0.25
0 1 1 0.375
1 0 0 0.5
1 0 1 0.625
1 1 0 0.750
1 1 1 0.875
Overview of DA converter types
April 10 9
Operation gives „staircase” (equivalent to zero-order
hold):
Reference: http://en.wikipedia.org/wiki/Digital-to-analog_converter
Overview of DA converter types
April 10 10
DAC output is a sequence of piecewise constant
values or rectangular pulses
Harmonics are above Nyquist frequency
Low pass filters are used as a reconstruction filter to
remove higher harmonics
Overview of DA converter types
April 10 11
Effective frequency response of the DAC depends on
the filter phase distortion
Not all DACs have a zero order response
Overview of DA converter types
April 10 12
DA conversion is used in audio and video systems
Audio signals are stored in digital form (MP3, CD) and
they must be converted into an analog signal to be
heard
Video signals from a digital source, such as a
computer, must be converted to analog form if they are
to be displayed on an analog monitor
Applications
Principle operations
April 10 13
Counting, Pusle-Width Modulator:
Reference: http://www.analog.com/library/analogDialogue/archives/39-06/data_conversion_handbook.html
Counting Pulse-width modulator
April 10 14
It is constructed using counters to generate an output
voltage proportional to a digital input word
A sampling clock starts the counter, which is loaded
with the digital word and simultaneously sets an R/S
flip-flop
Principle operations
Counting Pulse-width modulator
April 10 15
The counter counts upward at a fast rate, and when it
reaches all "ones", the R/S flip-flop is reset
The output of the R/S flip flop is therefore a pulse-
width-modulated (PWM) pulse whose width is
proportional to the complement of the binary word
Principle operations
Counting Pulse-width modulator
Principle operations
April 10 16
An R-2R Ladder is a simple and inexpensive way to perform
digital-to-analog conversion, using repetitive arrangements of
precision resistor networks in a ladder-like configuration
Five-bit R-2R resistor ladder:
Reference: http://en.wikipedia.org/wiki/Resistor_ladder
R-2R Ladder
April 10 17
Bit4 MSB (most significant bit) to Bit0 LSB (least
significant bit) are driven from digital logic gates
The R-2R network causes the digital bits to be
weighted in their contribution to the output voltage Vout
In our example 5-bits are used, so it gives 32
possibilities of output values
Principle operations
R-2R Ladder
April 10 18
Depending on which bits are set to 1 and which to 0
the output voltage will be a stepped value between 0
volts and Vref minus the value of the minimum step
For a digital value VAL, of a R-2R DAC of N bits of
0 V/Vref, the output voltage Vout is:
Vout = Vref × VAL / 2N
Principle operations
R-2R Ladder
Principle operations
April 10 19
Let N = 5 and hence 2N = 32. With Vref = 3.3 V (typical
CMOS logic 1 voltage), Vout will vary between 00000,
VAL = 0 and 11111, VAL = 31
Minimum (single step) VAL = 1, we have
Vout = 3.3 × 1 / 32 = 0.1 volts
R-2R Ladder - example
April 10 20
Maximum output (11111 VAL = 31), we have
Vout = 3.3 × 31 / 25 = 3.2 volts
Principle operations
R-2R Ladder - example
April 10 21
R-2R ladder features:
Cheap – needs only two resistor values (or even
one, if we use parallel conection)
Fast
Fixed output
DAC tends to be restricted to a relatively small
number of bits
Principle operations
R-2R Ladder - example
April 10 22
Small inaccuracies in the higher significant bit resistors
can entirely overwhelm the contribution of the less
significant bits
Depending on the type of logic gates used and design
of the logic circuits, there may be transitional voltage
spikes at such major crossings even with perfect
resistor values
High output impedance gates may be unsuitable in
some cases
Principle operations
R-2R Ladder - example
April 10 23
Resistors used with the more significant bits must be
proportionally more accurate than those used with the
lower significant bits
On a printed circuit board, using discrete components,
high precision resistors of 1% accuracy may be
employed for a 5 bit circuit
Both the ratio tolerances of the individual resistors
within the ladder and the resistance of the switches
used at the ladder inputs can affect DAC output
accuracy
Principle operations
R-2R Ladder - example
April 10 24
Circuit Diagram for an R-2R Ladder Network DAC:
Reference: http://www.ecelab.com/circuit-dac-r2r.htm
Principle operations
R-2R Ladder - example
Principle operations
April 10 25
DAC with summing amplifier:
Reference:
http://hyperphysics.phyastr.gsu.edu/hbase/electronic/dac.html#c2
Four-bit DA Converter
Principle operations
April 10 26
Example of 5-bit Binary-Weighted DAC:
Reference: http://www.analog.com/library/analogDialogue/archives/39-06/data_conversion_handbook.html
Binary-Weighted DAC
April 10 27
By connecting various combinations of parallel shorting
switches, 32 possible values of series resistance can
be obtained ranging from 0 to 31·R
32 possible levels of light intensity are given
Principle operations
Binary-Weighted DAC
April 10 28
Example Voltage-mode Binary-Weighted Resistor DAC (The output impedance of the voltage-mode binary DAC changes with the input code ):
Reference: http://www.analog.com/library/analogDialogue/archives/39-06/data_conversion_handbook.html
Principle operations
Binary-Weighted DAC
Main Technical Specifications
April 10 29
Static Performance
• Resolution (N)
• Differential Nonlinearity (DNL)
• Relative Accuracy or Integral Nonlinearity (INL)
• Zero-Scale Error (VZSE)
• Full-Scale Voltage (VFS)
Main Technical Specifications
April 10 30
This is the number of possible output levels the DAC is
designed to reproduce
This is usually stated as the number of bits it uses
Resolution is related to the effective number of bits
which is a measurement of the actual resolution attained
by the DAC
Resolution
M.T.S.
April 10 31
Shows how much two adjacent code analog
values deviate from the ideal 1LSB step
Differential Nonlinearity (DNL)
M. T. S.
April 10 32
Shows how much the
DAC transfer
characteristic deviates
from an ideal one. That is,
the ideal characteristic is
usually a straight line;
INL shows how much the
actual voltage at a given
code value differs from
that line, in LSBs (1LSB
steps).
Integral nonlinearity (INL)
Main Technical Specifications
April 10 33
Analog Output
• Output Current (Iout)
• Load Regulation at Full Scale (LREG)
• Is the capability to maintain a constant voltage (or current)
level on the output channel of a power supply despite changes
in load
• Capacitance load (CL)
Main Technical Specifications
April 10 34
Logic Inputs
• Logic Low Voltage (VIL)
• Logic High Voltage (VIH)
• Input Leakage Current (IIL)
• Input Capacitance (CIL)
Main Technical Specifications
April 10 35
Interface timing specifications
• Clock Width High (tCH) / Low (tCL)
• Load Pulse Width (tLDW)
• Data Setup (tDS) / Hold (tDH)
• Clear Pulse Width (tCLRW)
• Load Setup (tLD1) / Hold (tLD2)
• Select (tCSS) / Deselect (tCSH)
Main Technical Specifications
April 10 36
Interface Timing Specifications
Main Technical Specifications
April 10 37
AC characteristics
• Voltage Output Settling Time (ts)
• DAC Glitch
• Digital Feedthrough
Main Technical Specifications
April 10 38
Supply characteristics
• Positive Supply Current (IDD)
• Positive Dissipation (PDISS)
• Positive Supply Sensitivity (PSS)
DAC performance
April 10 39
This is the number of possible output levels the DAC is
designed to reproduce
This is usually stated as the number of bits it uses
Resolution is related to the effective number of bits
which is a measurement of the actual resolution attained
by the DAC
Resolution
DAC performance
April 10 40
Measurement of the maximum speed at which the
DACs circuitry can operate and still produce the
correct output
Signal must be sampled at over twice the frequency of
the desired signal – Nyquist sampling theorem
Maximum sampling frequency
DAC performance
April 10 41
Ability of a DAC's analog output to move only in the
direction that the digital input moves
This characteristic is very important for DACs used as
a low frequency signal
Monotonicity
DAC performance
April 10 42
Measurement of the distortion and noise added to the
signal by the DAC
It is expressed as a percentage of the total power of
unwanted harmonic distortion and noise that
accompany the desired signal
THD+N(Total harmonic distortion)
DAC performance
April 10 43
Measurement of the distortion and noise added to the
signal by the DAC
It is expressed as a percentage of the total power of
unwanted harmonic distortion and noise that
accompany the desired signal
Measurement of the difference between the largest
and smallest signals the DAC can reproduce
expressed in decibels
Dynamic range
DAC performance
April 10 44
Phase distortion and sampling period instability are
also sometimes important in DA conversion process
Phase distortion
Application Example
April 10 45
Requirements:
Generate four waveforms:
• Square,
• Triangle ,
• Sawtooth
• Sine
Amplitude choise
DC Level choise
Frequency choise
Waves Generator
Application Example
April 10 46
Schematic circuit
Waves Generator
Waves Generator
April 10 47
Choosing DA Converter:
Two families widely used:
DAC 0808 ( parallel)
DAC 8512 (serie)
Choose for this circuit: DAC0808
National Semiconductors
How to generate
wave?
Application Example
April 10 48
Interface :
SET FUNC: to select functions:
• Waveform
• Amplitude
• Frequency
PLUS
MINUS
RST
Waves Generator
Application Example
April 10 49
Interface:
Led’s indicates selected function
Waves Generator
Waves Generator
April 10 50
Square wave:
Characteristics:
Vmax
Vmin
Pulse-width
How to generate waves?
Waves Generator
April 10 51
Square wave:
Is represented by tow voltage leves :Vmin and Vmax
The value to set in microcontroller output is :
How to generate waves?
Waves Generator
April 10 52
Algorithm to generate Square Wave:
1. Calculate Vmax and Vmin from VPP and DC level
2. Calculate delay from requested frequency
3. Loop :
• Set Vmin
• Delay
• Set Vmax
• Jump to loop
How to generate
waves?
Waves Generator
April 10 53
Triangle wave:
How to generate
wave?
Waves Generator
April 10 54
Triangle wave:
Equation definition
How to generate
wave?
Waves Generator
April 10 55
Tabling values of magnitude:
How to generate
wave?
Waves Generator
April 10 56
Algorithm to generate Triangle Wave :
1. Calculate Vmax and Vmin
2. Table the values of Wave
3. Calculate delay time
• Delay time is function of frequency
4. Infinit loop:
• Sending upward wave
• Sending downward wave
How to generate
wave?
Waves Generator
April 10 57
HOW TO GENERATE TAWTOOTH WAVE?
I just need to set the upward of triangle wave!!
How to generate
wave?
Waves Generator
April 10 58
Sine Wave
How to generate
wave?
Waves Generator
April 10 59
Algorithm to generate Sine Wave:
Generating a table with sine values (Sk) between 0º and 90º
Steps to set sine wave:
1. Send upward wave stored in table
2. Send downward wave
3. Do VDC- upward wave and send to output
4. Do VDC-downward wave and sendo to output
How to generate
wave?
Waves Generator
April 10 60
Calculating values of Sk:
How to generate
wave?
0 pi/16 2pi/16 3pi/16 4pi/16 5pi/16 6pi/16 7pi/16 8pi/16
0 10 20 28 36 42 47 50 51
𝑵𝒌 = 𝑽𝒅𝒄 +𝑽𝒑𝒑
𝟐∗ 𝑺𝒌
April 10 61
Circuit schematic• Interface with DA converter serial port and motor controller.
8051 Car
Application Example
Application Example
April 10 62
Circuit schematic
8051 Car
Connecting 8051 to:
• DA Converter
• Motor Controller
Application Example
April 10 63
Circuit schematic• VREF+ – Reference voltage (Maximum)
• VREF- – Reference voltage (Minimum)
• IOUT – Output current of the converted data
• VEE – Power supply
• COMP – Compensation
• A1 to A8 – Digital input pins
8051 Car
Application Example
April 10 64
Circuit schematic
• Output Signal
8051 Car
𝐼𝑜𝑢𝑡 =𝑉𝑅𝑒𝑓
𝑅𝑅𝑒𝑓∗ 𝐷𝑖 ∗ 2
𝑖−8
8
𝑖=1
𝐼𝑜𝑢𝑡 = 𝐼𝑅𝑒𝑓 ∗ (𝐷12+𝐷24+𝐷38+𝐷416
+𝐷532
+𝐷664
+𝐷7128
+𝐷8256
)
Ex:
𝐷 = 10001001
𝐼𝑅𝑒𝑓 = 1𝑚𝐴
𝐼𝑜𝑢𝑡 = 1𝑚𝐴 ∗ 1
2+1
32+
1
256 = 1𝑚𝐴 ∗
137
256= 0.535𝑚𝐴
Application Example
April 10 65
Circuit schematic
• Motor interface
• The amplifier operates as a
current to voltage converter.
8051 Car
Application Example
April 10 66
Circuit schematic
• Motor interface
• The voltage is used to generate
the necessary current to feed
The motors..
8051 Car
Application Example
April 10 67
Coding
• Main program
• Check the command saved on 8051 memory and execute it.
• Commands supported:
• Speed – arg
• Front – arg
• Front right – arg
• Front Left – arg
• Back – arg
• Back right – arg
• Accelerate
8051 Car
Application Example
April 10 68
Coding
• Serial port
• Commands comes from a terminal connected to the serial port
• The supported commands, will be saved on memory
• In the end the code is compiled and a warning message tells
us if the syntax is correct
8051 Car
Application Example
April 10 69
Coding
• Main program Flowchart
8051 Car
Memory Value Mnemonic
30h f front
31h 5 5s
32h b back
33h 6 6s
34h s speed
35h 9
36h 0
37h j jump
38h 0 0
39h e end
90
Application Example
April 10 70
Coding
• Serial port interrupt routine
• Flowchart
8051 Car
References
April 10 71
Sites: http://www.ecelab.com/circuit-dac-r2r.htm
http://en.wikipedia.org/wiki/Digital-to-analog_converter
http://en.wikipedia.org/wiki/Resistor_ladder
http://hyperphysics.phyastr.gsu.edu/hbase/electronic/dac.html#c2
http://www.the-crankshaft.info/2009/08/dac-interfacing.html
http://www.8051projects.net/
http://www.labcenter.co.uk/download/prodemo_autodl_general.cfm
Softwares: ISIS Proteus
Uvision
April 10 72
Thank you !