You are on page 1of 9

INTERFACING ADC 0808 TO 8051 MICROCONTROLLER

MICROCONTROLLER INTERFACING
How to interface ADC 0808 to 8051 Micro controller and sample code for interfacing. Contents
I/O Pins Calculating Step Size Calculating Dout. PROGRAM In lot of embedded systems micro controllers needs to take analog input. Most of the sensors AND transducers such as temperature, humidity, pressure, are analog. For interfacing these sensors to micro controllers we require to convert the analog output of these sensors to digital so that the controller can read it. Some micro controllers have built in Analog to Digital Converter (ADC) so there is no need of external ADC. For controllers that dont have internal ADC external ADC is used. One of the most commonly used ADC is ADC0808. ADC 0808 is a Successive approximation type with 8 channels i.e. it can directly access 8 single ended analog signals. I/O Pins ADDRESS LINE A, B, C The device contains 8-channels. A particular channel is selected by using the address decoder line. The TABLE 1 shows the input states for address lines to select any channel. Address Latch Enable ALE The address is latched on the Low High transition of ALE. START The ADCs Successive Approximation Register (SAR) is reset on the positive edge i.e. Low- High of the Start Conversion pulse. Whereas the conversion is begun on the falling edge i.e. High Low of the pulse. Output Enable Whenever data has to be read from the ADC, Output Enable pin has to be pulled high thus enabling the

TRI-STATE outputs, allowing data to be read from the data pins D0-D7. End of Conversion (EOC) This Pin becomes High when the conversion has ended, so the controller comes to know that the data can now be read from the data pins. Clock External clock pulses are to be given to the ADC; this can be given either from LM 555 in Astable mode or the controller can also be used to give the pulses.

ALGORITHAM 1. Start. 2. Select the channel. 3. A Low High transition on ALE to latch in the address. 4. A Low High transition on Start to reset the ADCs SAR. 5. A High Low transition on ALE. 6. A High Low transition on start to start the conversion. 7. Wait for End of cycle (EOC) pin to become high. 8. Make Output Enable pin High. 9. Take Data from the ADCs output 10. Make Output Enable pin Low. 11. Stop The total numbers of lines required are: data lines: 8 ALE: 1 START: 1 EOC:1 Output Enable:1 I.e. total 12 lines. You can directly connect the OE pin to Vcc. Moreover instead of polling for EOC just put some delay so instead of 12 lines you will require 10 lines. You can also provide the clock through the controller thus eliminating the need of external circuit for clock. Calculating Step Size ADC 0808 is an 8 bit ADC i.e. it divides the voltage applied at Vref+ & Vref- into 28 i.e. 256 steps.

Step Size = (Vref+ - Vref-)/256 Suppose Vref+ is connected to Vcc i.e. 5V & Vref- is connected to the Gnd then the step size will be Step size= (5 - 0)/256= 19.53 mv. Calculating Dout. The data we get at the D0 - D7 depends upon the step size & the Input voltage i.e. Vin. Dout = Vin /step Size. If you want to interface sensors like LM35 which has output 10mv/C then I would suggest that you set the Vref+ to 2.56v so that the step size will be Step size= (2.56 - 0)/256= 10 mv. So now whatever reading that you get from the ADC will be equal to the actual temperature.

PROGRAM

Here is a program for interfacing the ADC to microcontroller, as stated above I have assumed that the OE pin is connected to Vcc & the clock is given by the controller. This program selects channel 0 as input channel reads from it & saves in the accumulator. adc_a adc_b adc_c adc_start adc_ale adc_clk bit p2.0 bit p2.1 bit p2.2 bit p2.3 bit p2.4 bit P2.5

Org 0000h clr ale clr start

clr adc_a

clr adc_b clr adc_c call delay_small setb adc_ale call delay_small setb adc_start call delay_small clr adc_ale call delay_small clr adc_start call delay_long mov a,P1 loop: ajmp loop end delay_small: mov r0,#10 l1_delay_small: cpl adc_clk nop nop nop nop nop nop

;Select Channel 0 ;

;ale pin high

;start pin high

;ale pin low

;start pin low

djnz r0,l1_delay_small ret delay_long: mov r0,#40 l1_delay_long: cpl adc_clk nop nop nop nop nop djnz r0,l1_delay_long ret
element14 - Up to 70% Off
Reduced Prices on 130,000 Products. Free Delivery, No MOQ. Shop Now !
m y.e lem ent14.co m

Comments
Sign in to write a comment

Anonymous Untitled hi I want to know step for programming for ADC0804 interface to 8051.........steps for program after conversion....mean what type of conversion we required during displaying ADC out put on LCD or LED Display.....pls guide Deepak Thanks (deep_diva@rediffmail.com)

Last edited Jul 3, 2011 8:04 PM Report abusive comment 0 View/post replies (1) to this comment

ihsanbu Dear Amol Shah I am doing an Embedded system project i require AC Volt Meter. like this 8051 based AC volt meter using ADC0808. The unique requirement of this coding is that it require threshold pionting. if require the threshold from >160VAC and < 260 Volt AC. if the condition do not satisfy the above given threshold, the controller P1.2 become 0. thank you for helping in this regard Last edited Apr 1, 2011 5:58 AM Report abusive comment 0 Post reply to this comment

Anonymous shameer i checked 808 using vref=+5v and vref-=gnd and clk=555khz ,but adc operation with in the limit of 5v to 7.3v .please could u say a solution for working adc with in 0 to 5v ,.? Last edited Mar 26, 2011 11:44 PM Report abusive comment 0 Post reply to this comment

Anonymous Untitled

hiiiiiii frnds....... will u plz guide me 4 the adc804 interfacing with mc51 4 data aquisition in biomedical field......... Last edited Mar 14, 2011 10:12 PM Report abusive comment 0 Post reply to this comment

Anonymous Untitled hiii, could you please give me the 0809 interfacing program with 89c51 in embedded C kindly help Feb 28, 2011 10:06 PM Report abusive comment 0 Post reply to this comment

Anonymous Untitled hello!! plz tell me whether we can use 1 adc to take signals from 2 sensors simultaneously, considering that through the cs pin in adc only 1 out of many signals which are given as input is processed. if yes, how?? kindly help Apr 26, 2010 6:44 PM Report abusive comment 0 Post reply to this comment

love

further information about micro-controller 8051 and adc 0804 and adc0808 The ADC0808 or ADC 0809, A/D Converter is 8 bits analog to digital converter and has a microprocessor bus interface and it require only single single +5 power supply for operation . It also has an 8 input analog multiplexer on chip to select the desire analog channal for scanning or conversion to digital bit pattern. http://www.microcontroller51.blogspot.com/2009/08/adc0808-ad-converter.html Nov 14, 2009 1:46 AM Report abusive comment +1 Post reply to this comment

love further information about micro-controller 8051 and adc 0804 and adc0808 The ADC0808 or ADC 0809, A/D Converter is 8 bits analog to digital converter and has a microprocessor bus interface and it require only single single +5 power supply for operation . It also has an 8 input analog multiplexer on chip to select the desire analog channal for scanning or conversion to digital bit pattern. http://www.microcontroller51.blogspot.com/2009/08/adc0808-ad-converter.html Nov 14, 2009 1:45 AM Report abusive comment +1 Post reply to this comment

Anonymous Untitled hi I want to know about interfacing of 0804. Is it same as 0808 or different thanks....... Last edited Sep 11, 2009 6:05 AM Report abusive comment 0 Post reply to this comment

ayu Hi Amol Shah, How the crystal on 8051 ? 12MHz or other value ? Thanks a lot. Last edited May 5, 2009 7:45 AM Report abusive comment +1 View/post replies (1) to this comment