0% found this document useful (0 votes)
26 views23 pages

ADC Interfacing

Uploaded by

KISHOORE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views23 pages

ADC Interfacing

Uploaded by

KISHOORE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

ADC and DAC

interfacing with
8051
Analog to Digital
convertor(ADC)
• An ADC is a real world device which converts real time continuous
quantities into digital values that represent the amplitude of the
quantity.
• An ADC converts input analog signals by quantizing it.
• Higher the sampling rate used to discretize the values more will be the
accuracy with which the output from ADC is obtained.
• ADCs may be used in Digital Signal Processing, in commercial
applications as well as in music industries to convert the data from
analog to digital in order to create the data that will be used in compact
disks.
ADC 0808
• It is a 8-channel multiplexer, 8-bit ADC and microprocessor compatible
control logic.
• It has 28 pins, and can handle up to 8 analog signals using one chip. It has
got an 8-bit data output.
• The 8 input channels are IN0-IN7, and Vref(+)=5V; Vref(-) has been
grounded. In order to select the inputs IN0-IN7; A, B and C addresses are
used.
• The features of ADC0808 are differential analogue voltage inputs, 0-5V
input voltage range, no zero adjustment, built in clock generator, reference
voltage can be externally adjusted to convert smaller analogue voltage
span to 8 bit resolution.
ADC0808
• ADC receives analog signal from the source. This analog signal is
received from one of the 8 input channels of ADC0808.
• Then this signal is processed accordingly and converted to
corresponding digital signal.
• This signal is then sent to the microcontroller and the output is
displayed using Light Emitting Diode (LED)
ALGORITHM FOR
PROGRAMMING ADC
i) An analog channel is selected by giving bits to A, B, C addresses.
ii) ALE(Address Latch Enable) is activated by a low to high pulse in order to
latch in the address.
iii) SC(Start Conversion) is activated by a low to high pulse in order to start
the conversion.
iv) If a high to low output is obtained at EOC(End of Conversion), it
indicates that the data conversion is finished and the data is ready.
v) OE(Output Enable) is activated to read output data from the ADC chip.
In order to bring the digital data out of the chip a low to high pulse is given
to the OE pin
ASSEMBLY PROGRAM TO INTERFACE
ADC WITH 8051
ORG 000AH
SJMP MAIN
ADC_DATA EQU P1 ;Give Name To Port Pins
ADC_SC BIT P3.0
ADC_EOC BIT P3.1
ADC_ALE BIT P3.2
ADC_OE BIT P3.3
ADD_A BIT P3.4
ADD_B BIT P3.5
ADD_C BIT P3.6
MAIN:
MOV ADC_DATA,#0FFH ;Port 1 is input port
SETB ADD_A ;select channel
SETB ADD_B
CLR ADD_C ;for channel 3 selection CLR ADC_SC
ACALL DELAY1 LOOP1:
ACALL ADC_COUNT JB ADC_EOC,LOOP1 ;Wait for conversion to finish
MOV P0,A LOOP2:
;ADC Programming Start JNB ADC_EOC,LOOP2 ;Output becomes high
ADC_COUNT: SETB ADC_OE ;Set OE High to convert data on controller
SETB ADC_EOC ;it is made as input Port ACALL DELAY1 ;For Further delay
CLR ADC_ALE CLR ADC_OE ;digital converted data is saved in memory
CLR ADC_SC MOV B,#05H
CLR ADC_OE DIV AB ;amplify with gain in place of 05H for obtaining real
digital data
BACK:
RET ;Return To Main Routine
SETB ADC_ALE ;High To Low Pulse is given to ALE
Delay ;App. 1.3643 Sec. Delay
ACALL DELAY1
DELAY:
SETB ADC_SC ;High To Low Pulse is given to SC
MOV R3,#3
ACALL DELAY1
CLR ADC_ALE
LOOP3:
MOV R1,#254
LOOP4:
MOV R2,#254
LOOP5:
DJNZ R2,LOOP5
DJNZ R1,LOOP4
DJNZ R3,LOOP3
RET
;Approximately 435 μsec
DELAY1:
MOV R3,#1
LOOP6:
MOV R1,#10
LOOP7:
MOV R2,#10
LOOP8:
DJNZ R2,LOOP8
DJNZ R1,LOOP7
DJNZ R3,LOOP6
RET
END
OUTPUT
Example:2 Logic to communicate between 8051
and ADC 0808
• Step 1: Set the port you connected to the output lines of the ADC as an input port.
• Step 2: Make the Port connected to EOC pin high. The reason for doing this is that the
ADC sends a high to low signal when the conversion of data is complete. So this line
needs to be high so that the microcontroller can detect the change.
• Step 3: Clear the data lines which are connected to pins ALE, START, and OE as all these
pins require a Low to High pulse to get activated.
• Step 4: Select the data lines according to the input port you want to select. To do this,
select the data lines and send a High to Low pulse at the ALE pin to select the address.
• Step 5: Now the analog input pin is selected, ADC starts the conversion by sending a
pulse to the START pin.
• Step 6: Wait for the High to low signal by polling the EOC pin.
• Step 7: Wait for the signal to get high again.
• Step 8: Extract the converted data by sending a High to low signal to the OE pin.
Assembly language program to interface ADC
0808 with 8051
DAC Interfacing
• The Digital to Analog converter (DAC) is a device, that is widely used
for converting digital pulses to analog signals.
• There are two methods of converting digital signals to analog signals.
-Binary weighted method and
- R/2R ladder method.
• MC1408 (DAC0808) Digital to Analog Converter-
• This chip uses R/2R ladder method.
DAC0808
• This method can achieve a much higher degree of precision.
• DACs are judged by its resolution. The resolution is a function of the
number of binary inputs.
• The most common input counts are 8, 10, 12 etc.
• Number of data inputs decides the resolution of DAC.
• So if there are n digital input pin, there are 2n analog levels. So 8 input
DAC has 256 discrete voltage levels.
MC1408 DAC (or DAC0808)
• In this chip the digital inputs are converted to current.
• The output current is known as Iout by connecting a resistor to the
output to convert into voltage.
• The total current provided by the Iout pin is basically a function of the
binary numbers at the input pins D0 - D7 (D0 is the LSB and D7 is the
MSB) of DAC0808 and the reference current Iref.
• The following formula is showing the function of Iout
• The Iref is the input current. This must be provided into the pin 14.
Generally 2.0mA is used as Iref .
• Iout pin is connected to the resistor to convert the current to voltage.
Disadvantage- Inaccuracy since the input resistance of the load will also
affect the output voltage.
• So practically Iref current input is isolated by connecting it to an Op-Amp
with Rf = 5KΩ as feedback resistor. The feedback resistor value can be
changed as per requirement.
Generating Sinewave using DAC and 8051
Microcontroller

• For generating sinewave, a look-up table is created to represent the


magnitude of the sine value of angles between 0° to 360°.
• The sine function varies from -1 to +1.
• In the table only integer values are applicable for DAC input.
• In this example we will consider 30° increments and calculate the
values from degree to DAC input.
• Assumption: full-scale voltage of 10V for DAC output.
Lookup table according to the angle
and other parameters for DAC
OUTPUT

You might also like