8051 – ADC0808 Interfacing

We had already seen ADC0804 Interfacing. So this Tutorial is all about ADC0808 Interfacing with 8051.

Suggest to Read

Introduction

In embedded systems microcontrollers needs to take analog input. Most of the sensors & transducers such as temperature, humidity, pressure, are analog. For interfacing these sensors to microcontrollers we require to convert the analog output of these sensors to digital so that the controller can read it. Some microcontrollers have built in Analog to Digital Convertor (ADC) so there is no need of external ADC. For microcontrollers that don’t have internal ADC external ADC is used.

Why we are using ADC for 8051 Microcontroller?

Well. 8051 doesn’t has inbuilt ADC. So we have to use external ADC. There are many ADCs available.

  • ADC 0804

  • ADC 0808

ADC0808

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. The difference between ADC0804 and ADC0808 is number of analog input signals. I mean, In ADC0804 we can give only one analog input. But in ADC0808 we can give 8 analog inputs. So if you want to interface more number of analog sensors, please select this ADC0808.

ADC0808 is an 8 bit analog to digital converter with eight input analog channels, i.e., it can take eight different analog inputs. The input which is to be converted to digital form can be selected by using three address lines. The voltage reference can be set using the Vref+ and Vref- pins. The step size is decided based on set reference value. Step size is the change in analog input to cause a unit change in the output of ADC. The default step size is 19.53mV corresponding to 5V reference voltage. ADC0808 needs an external clock to operate unlike ADC0804 which has an internal clock. The ADC needs some specific control signals for its operations like start conversion and bring data to output pins. When the conversion is complete the EOC pins goes low to indicate the end of conversion and data ready to be picked up.

Features

  • Easy interface to all microprocessors

  • Operates ratio metrically or with 5 V DC or analog span adjusted voltage reference

  • No zero or full-scale adjust required

  • 8-channel multiplexer with address logic

  • 0V to 5V input range with single 5V power supply

  • Outputs meet TTL voltage level specifications

  • Standard hermetic or molded 28-pin DIP package

  • 28-pin molded chip carrier package

Pin Diagram

ADC0808 8051 - ADC0808 Interfacing

Pin Description

 Pin NoFunctionName
1Analog Input Pin 3IN3
2Analog Input Pin 4IN4
3Analog Input Pin 5IN5
4Analog Input Pin 6IN6
5Analog Input Pin 7IN7
6Start conversion; input pin; a low to high pulse is givenSTART
7End of conversion; output pin; goes low when the conversion is overEOC
8Digital output bitD3
9Input pin; a low to high pulse brings data to output pins from the internal registers at end of conversionOutput Enable
10Clock input; to provide external clockClock Input
11Supply voltage; 5VVcc
12Positive reference voltageVref+
13Ground (0v)GND
14Digital output bitD1
15Digital output bitD2
16Negative reference voltageVref-
17Digital output bitD0
18Digital output bitD4
19Digital output bitD5
20Digital output bitD6
21Digital output bitD7
22Address latch enable; Input pin; low to high pulse is required to latch in the addressALE
23Address line CAddress C
24Address line BAddress B
25Address line AAddress A
26Analog Input Pin 0IN0
27Analog Input Pin 1IN1
28Analog Input Pin 2IN2

Selection of Channel

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

ADC Channel NameADD CADD BADD A
IN0LOW
LOW
LOW
IN1LOW
LOW
HIGH
IN2LOW
HIGHLOW
IN3LOW
HIGHHIGH
IN4HIGHLOW
LOW
IN5HIGHLOW
HIGH
IN6HIGHHIGHLOW
IN7HIGHHIGHHIGH

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

How to use the ADC0808?

  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 ADC’s 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 ADC’s output
  10. Make Output Enable pin Low.
  11. Stop

ADC0808 interfacing with 8051

Circuit Diagram

In this tutorial i’m going to connect the PotentioMeter (Variable Resistor) instead of real sensor. You can connect the real sensor in Hardware.

LCD:

  • RS  – P1.0
  • RW  – GND
  • EN  – P1.1
  • LCD Data Lines – P1 LSB 4 bits

ADC:

  • Output Enable    –  P2.0
  • EOC                      –  P2.1
  • Start                      –  P2.2
  • Addr A                  –  P2.4
  • Addr B                  –  P2.5
  • Addr C                  –  P2.6
  • ALE                       –  P2.7
  • ADC Data lines   – Po

adc0808-circuit 8051 - ADC0808 Interfacing

Code

You can download the entire project here.

Output

adc0808-output 8051 - ADC0808 Interfacing

Hope you have understood. If you haven’t please comment below your doubts.

%d bloggers like this: