ADC is the Analog to Digital converter, which converts analog data into digital format; usually it is used to convert analog voltage into digital format. Analog signal has infinite no of values like a sine wave or our speech, ADC converts them into particular levels or states, which can be measured in numbers as a physical quantity. Instead of continuous conversion, ADC converts data periodically, which is usually known as sampling rate. Telephone modem is one of the examples of ADC, which is used for internet, it converts analog data into digital data, so that computer can understand, because computer can only understand Digital data. The major advantage, of using ADC is that, we noise can be efficiently eliminated from the original signal and digital signal can travel more efficiently than analog one. That’s the reason that digital audio is very clear, while listening.

In present time there are lots of microcontrollers in market which has inbuilt ADC with one or more channels. And by using their ADC register we can interface. When we select 8051 microcontroller family for making any project, in which we need of an ADC conversion, then we use external ADC. Some external ADC chips are 0803,0804,0808,0809 and there are many more. Today we are going to interface 8-channel ADC with AT89s52 Microcontroller namely ADC0808/0809.

Components:

8051 Microcontroller (AT89S52)

ADC0808/0809

16x2 LCD

Resistor (1k,10k)

POT(10k x4)

Capacitor(10uf,1000uf)

Red led

Bread board or PCB

7805

11.0592 MHz Crystal

Power

Connecting wires

ADC0808/0809:

ADC0808/0809 is a monolithic CMOS device and microprocessor compatible control logic and has 28 pin which gives 8-bit value in output and 8- channel ADC input pins (IN0-IN7). Its resolution is 8 so it can encode the analog data into one of the 256 levels (28). This device has three channel address line namely: ADDA, ADDB and ADDC for selecting channel. Below is the Pin Diagram for ADC0808:

ADC0808/0809 requires a clock pulse for conversion. We can provide it by using oscillator or by using microcontroller. In this project we have applied frequency by using microcontroller.

We can select the any input channel by using the Address lines, like we can select the input line IN0 by keeping all three address lines (ADDA, ADDB and ADDC) Low. If we want to select input channel IN2 then we need to keep ADDA, ADDB low and ADDC high. For selecting all the other input channels, have a look on the given table:

ADC Channel Name

ADDC PIN

ADDB PIN

ADDA PIN

IN0

LOW

LOW

LOW

IN1

LOW

LOW

HIGH

IN2

LOW

HIGH

LOW

IN3

LOW

HIGH

HIGH

IN4

HIGH

LOW

LOW

IN5

HIGH

LOW

HIGH

IN6

HIGH

HIGH

LOW

IN7

HIGH

HIGH

HIGH

Circuit Description:

Circuit of “Interfacing ADC0808 with 8051” is little complex which contains more connecting wire for connecting device to each other. In this circuit we have mainly used AT89s52 as 8051 microcontroller, ADC0808, Potentiometer and LCD.

A 16x2 LCD is connected with 89s52 microcontroller in 4-bit mode. Control pin RS, RW and En are directly connected to pin P2.0, GND and P2.2. And data pin D4-D7 is connected to pins P2.4, P2.5, P2.6 and P2.7 of 89s52. ADC0808 output pin are directly connected to port P1 of AT89s52. Address line pins ADDA, ADDB, AADC are connected at P3.0, P3.1, and P3.2.

And here we have used three potentiometers connected at pin 26, 27, and 28 of ADC0808.

A 9 volt battery and a 5 volt voltage regulator namely 7805 are used for powering the circuit.

Working:

In this project we have interfaced three channels of ADC0808. And for demonstration we have used three variable resistors. When we power the circuit then microcontroller initialize the LCD by using appropriate command, gives clock to ADC chip, selects ADC channel by using address line and send start conversion signal to ADC. After this ADC first reads selected ADC channel input and gives its converted output to microcontroller. Then microcontroller shows its value at Ch1 position in LCD. And then microcontroller changes ADC channel by using address line. And then ADC reads selected channel and send output to microcontroller. And show on LCD as name Ch2. And like wise for other channels.

Working of ADC0808 is much similar to working of ADC0804. In this, first microcontroller provides a 500 KHz clock signal to ADC0808, using the Timer 0 interrupt, as ADC requires clock signal to operate. Now microcontroller sends a LOW to HIGH level signal to ALE pin (its active-high pin) of ADC0808 to enable the latch in the address. Then by applying HIGH to LOW Level signal to SC (Start Conversion), ADC starts analog to digital conversion. And then wait for the EOC (End of Conversion) pin to go LOW. When EOC goes LOW, it means analog to digital conversion has been completed and data is ready to use. After this, microcontroller enables the output line by applying a HIGH to LOW signal to OE pin of ADC0808.

ADC0808 gives ratio metric conversion output at its output pins. And the formula for radiometric conversion is given by:

Vin/(Vfs-Vz)= Dx/(Dmax-Dmin)

Where

Vin is input voltage for conversion
Vfs is full scale Voltage
Vz is zero voltage
Dx is data point being measure
Dmax is Maximum data limit
Dmin is Minimum data limit

Program Explanation:

In the program, first of all we include header file sand defines variable and input & output pins for ADC and LCD.

Function for creating the delay has been created (void delay), along with some LCD functions like for LCD initialization, printing the string, for LCD commands etc. You can easily find them in Code. Check this article for LCD interfacing with 8051 and its functions.

After this in main program we have initialize LCD and set the EOC, ALE, EO, SC pins accordingly.

this code is not working i guess due to the initialization its not working.it is showing some warning issues.
2 warnings like
adc single.c(84): warning C182: pointer to different objects
adc single.c(85): warning C182: pointer to different objects