Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

How to interface three input channels of ADC0808 using 8051 microcontrollers (AT89C51)- (Part 24/45)

By Himanshu Choudhary

Many applications need to measure and/or monitor the physical quantities like temperature, pressure, light intensity etc. The sensors used to measure the physical quantities give the output in analog form, which are converted to digital through an ADC for further processing. This circuit demonstrates the principle and operation of interfacing ADC0808 with three LDR. The output of the sensor is displayed on the LCD. The external clock needed by the ADC0808 is provided by the controller using interrupt. The output is displayed on the LCD. The circuit is divided into four parts: LDR, ADC, 8051 microcontroller and LCD. Its applications could be measuring and monitoring the light intensity level.

 

 


ADC0808 is an 8-bit resolution ADC with eight input channels. At any point of time only one input can be read. The output of LDR

 

s are used as inputs. An LDR will detect the intensity of light and generate voltage depending upon light intensity.

 

 A clock of frequency 500 KHz is generated using Timer0 in the interrupt mode. To enable the interrupt, the value of the register IE is set to 0x82 (Refer ADC 0808 with interrupt clock).
 
The output pins of ADC are connected to the port P0 of the microcontroller AT89C51.  Pin10 of the ADC is connected to pin8 (P1.7) of the controller for clock input. ALE, pin22 of the ADC is connected to pin1 (P1.0) of controller. OE, pin9 of the ADC is connected to pin4 (P1.3) of microcontroller. SC, pin6 of the ADC is connected to pin2 (P1.1) of the controller. EOC, pin7 is connected to pin3 (P1.2) of microcontroller. Selector pins A (25), B (24) and C (24) of ADC are connected to the pins 4, 5 and 6 of the controller respectively.
 
Port P2 (pins 21-28) of controller is used to send the data to the LCD (pins 7-14). RS (pin4) of LCD is connected to P3.0 (pin 10) of the microcontroller.AT89C51. R/W (pin5) of LCD is connected to P3.1 (pin11) of the controller. Enable pin, EN, pin6 of LCD will connect to P3.6 of controller (Refer LCD interfacing).
 

 

 

The controller monitors the output of the three sensors, from the ADC, serially one after the other and keeps displaying them on LCD. If the output of any of the LDR varies, the corresponding change is reflected on the LCD. The output of the LDR varies with the intensity of light. The output value of ADC varies in the range 0 to 255. The output is displayed as a number. (Refer displaying a number on 16×2 LCD)

 

 

Project Source Code

###

// Program to interface 3 LDRs with ADC 0808 using three input channels of ADC 0808. The output pins are connected to LCD to show intensity value between (0-255). Controller interrupt is used to generate the clock for driving the ADC 0808.
#include<reg51.h>
sbit ale=P1^0;  //address latch enable
sbit oe=P1^3;  //output enable
sbit sc=P1^1;  //start conversion
sbit eoc=P1^2;  //end of conversion
sbit clk=P1^7;  // clock
sbit ADD_A=P1^4;  //Address pins for selecting input channels.
sbit ADD_B=P1^5;
sbit ADD_C=P1^6;
sfr lcd_data_pin=0xA0;  //Port P2
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^6;
sfr input_port=0x80;  //Port P0
unsigned int key,value,number,ascii1,ascii2,ascii3,flag,temp1,key1/*,data1,data2,data3,data11,data12,data13,data21,data22,data23*/;

void timer0() interrupt 1  // Function to generate clock of frequency 500KHZ using Timer 0 interrupt.
{
clk=~clk;
}

void delay(unsigned int count)  // Function to provide time delay in msec.
{
int i,j;
for(i=0;i<count;i++)
  for(j=0;j<1275;j++);
}

void lcd_command(unsigned char comm)  //Function to send command to LCD.
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(1);
en=0;
}
           
void lcd_data(unsigned char disp)  //Function to send data to LCD.
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(1);
en=0;
}

lcd_dataa(unsigned char *disp)  //Function to send string data to LCD.
{
int x;
for(x=0;disp[x]!=0;x++)
{
  lcd_data(disp[x]);
}
}

void lcd_ini()  //Function to inisialize the LCD
{
lcd_command(0x38);  // for using 8-bit 2 row LCD
delay(5);
lcd_command(0x0F);  // for display on cursor blinking
delay(5);
lcd_command(0x80);
delay(5);  //Force cursor to blink at line 1 positon 0
}

void BCD()  // Binary to decimal conversion to send the data to LCD
{
  key1++;
  key=0;
  flag=0;
    number=input_port;
    value=number%10;
number=number/10;
ascii1=value+48;
if(number!=0)
{
  value=number%10;
  number=number/10;
  ascii2=value+48;
    flag=1;
}
else
{
  ascii2=48;
  flag=1;
}
if(number!=0)
{
  value=number%10;
    number=number/10;
    ascii3=value+48;
    key=2;
}
else
{
  ascii3=48;
  key=2;
}
if(key1==1)    
{
  lcd_command(0xC0);
}
if(key1==2)
{
  lcd_command(0xC5);
}
if(key1==3)
{
  lcd_command(0xCA);
}
if(key==2)
lcd_data(ascii3);
if(flag==1)
lcd_data(ascii2);
lcd_data(ascii1);
if(key1==3)
{
  key1=0;
  ascii3=0;
  ascii2=0;
  ascii1=0;
  delay(10);
} 
}
void adc()  //Function to drive ADC
{
while(1)
  {
   if(temp1==0)
   {
    ADD_C=0;  // Selecting input channel 1 using address lines
    ADD_B=0;
    ADD_A=0;
   }
   if(temp1==1)
   {
    ADD_C=0;  // Selecting input channel 2 using address lines
    ADD_B=0;
    ADD_A=1;
   }
   if(temp1==2)
   {
    ADD_C=0;  // Selecting input channel 3 using address lines
    ADD_B=1;
    ADD_A=0;
   }
   delay(2);
   ale=1;
   delay(2);
   sc=1;
   delay(1);
   ale=0;
   delay(1);
   sc=0;
   while(eoc==1);
   while(eoc==0);
   oe=1;
   BCD();
   delay(2);
   oe=0;
   temp1++;
   if(temp1==3)
   temp1=0;
  }
}

void main()
{
  eoc=1;
    ale=0;
   oe=0;
   sc=0;
  TMOD=0x02;  //Timer0 setting for generating clock of 500KHz using interrupt enable mode.
  TH0=0xFD;
  IE=0x82;
  TR0=1;
  temp1=0;
key1=0;
lcd_ini();
lcd_dataa("SN1:");
lcd_dataa(" SN2:");
lcd_dataa(" SN3:");
   adc();
}

###

 


Circuit Diagrams

Circuit-Diagram-Interfacing-Three-Input-Channels-ADC0808-Using-8051-Microcontrollers-AT89C51

Project Components

  • AT89C51 Microcontroller
  • IC ADC0808
  • LCD
  • LDR
  • Preset

Project Video


Filed Under: 8051 Microcontroller
Tagged With: 8051, adc, microcontroller, three channel
 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)
  • Driving High Side MOSFET using Bootstrap Circuitry – (Part 17/17)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics Research robot samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • Verilog/SV: Using an array as a set of individual registers and not RAM
  • Bandpass filter why we are cascading HPF+LPF why not LPF +HPF,both are LTI systems
  • Diagnosing a fault on a 18volt lithium Ion charger
  • converting surface current into radiation im my problem
  • RISCV ALU Specifications

RSS Electro-Tech-Online.com Discussions

  • Relaxation oscillator with neon or...
  • LCD display on PICDEM 2 Plus board
  • software PWM
  • Positive and negative sides of voltage source
  • Cordless vacuum cleaner problem
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering