Sie sind auf Seite 1von 20

Analog-to-Digital

Digital-to-Analog
Data Handling Systems
 Both data about the physical world and control
signals sent to interact with the physical world
are typically "analog" or continuously varying
quantities.
 In order to use the power of digital electronics,
one must convert from analog to digital form on
the experimental measurement end and
convert from digital to analog form on the
control or output end of a laboratory system.
Data Collection and Control
Analog to Digital
Conversion [ADC]
ADC Various Approaches
 4 Basic Types

 Ramp Type ADC


 Dual slope ADC
 Successive Approximation ADC
 Flash ADC
ADC..
 Specifications: Range of analog i/p,no of
digital bits at o/p, resolution, conversion
time and no.of analog i/p channels.
 I/P volt can be either unipolar or bipolar.
 Unipolar (0to+5V), Bipolar(-5Vto+5V)
 ADC chip with option to select using v-ref
i/p pin.
 ADC chip with diff no.o/p binary bits
8,10,12 or 16 bits.
 No.of bits decide no.of volt level sensed.
ADC..

 Ex: 8 bit ADC will have 2 power 8 possible


levels i.e 256 levels.
 No.of bits and i/p volt range decides the
resolution.
 Ex: (0 to +5V) range with 8 bits o/p will have
resolution of 5/256. i.e approx. 19.5 mV
 Conversion time is decided by type of ADC
and clock freq. used in converter circuits.
2 Methods of i/f ADC-8051

 Direct i/f (ADC chip with 8051 parallel


ports).
 8255 PPI chip with 8051,ADC chip can
be interfaced with the 8051 through 8255
(Complex system: involving many
external chips including memory)
ADC..
 ADC 0808/0809-commonly used ADC chip
with 8 analog i/p channels and an 8 bit
digital o/p.
 8 analog i/p are multiplexed and selected
using 3 select lines.-Connected to LS-3 bits
of Port 0.
 +Vref, -Vref ,CLK and supply i/p to ADC.
 ALE and SC pins are tied together and
connected to P0.3
ADC..
 OE is connected to P0.4, EOC is sensed
through P0.5.
Program for ADC
ADCONVERT: MOV P1,#0FFH Make port 1 as i/p port by writing 1s
MOV P0,#CH_NUM Select the channel number on P0 LSB
3 lines
SETB P0.3 Issue ALE/SC signal on P0.3
NOP Wait
NOP Wait
CLR P0.3 Remove ALE/SC by making it to 0
CHECK: JNB P0.5, CHECK Read P0.5 to check EOC until it
become 1
SETB P0.4 Make OE signal high on P0.4
MOV A, P1 Read the result data from port 1
MOV ADC_RES, A Store it in a memory location ADC_res
RET End of subroutine program
Digital-to-Analog
Conversion [DAC]
Digital-to-Analog Conversion
 Common chip is DAC 0800
 Any one port is enough to interface an 8-
bit DAC with the 8051.
 Data lines of DAC connected to Port 1
lines of microcontroller.
 o/p from DAC chip is variable current and
this is converted into a voltage using a
current to voltage converter.
 4 common application:
 Square wave generation
 Ramp wave generation
 Staircase wave generation
 Sine wave generation
Square wave generation..

 0v o/p for half a period and a voltage of


amplitude V1 for another half.
 V1=
 [(2power n -1)/Maximum o/p volt] x v1
 Ex: equivalent value of 3V o/p in a DAC
with an 8-bit binary i/p and a maximum
o/p of 5V is [(2 power 8-1)/5] x 3=153 (in
decimal form)
Square wave generation..
 The same value in Hex.deci is 99H

 Program can generate square wave of


amplitudes 3V and 0V, with a predefined
delay and hence a predefined frequency.
Program
START: MOV P1, #00H Load the hexadecimal equivalent of 0V in P1
LCALL DELAY Call the subroutine delay
MOV P1, #99H Load the Hex.Deci equivalent of 3 V in P1
LCALL DELAY Call the subroutine delay
SJMP START Loop again to get a continuous waveform
DELAY: MOV R0, #COUNT Load a register with a count value
RPT: DJNZ R0, RPT Decrement it and loop
RET If the value of count become zero, return from
subroutine