Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey 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
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to interface Serial ADC0831 with 8051 Microcontroller (AT89C51)- (Part 30/45)

By Himanshu Choudhary December 31, 2012

ADC is an electronic device which converts analog signals into its corresponding digital signal. This article demonstrates the principle, operation and interfacing of 8-bit serial ADC0831 with 8051 microcontroller (AT89C51).
 

 

ADC0831 is an 8 pin IC with 8-bit serial data output (for more detail about ADC0831 refer to Interfacing ADC0831 with ATmega16). To receive the output from ADC high to low pulse is given at CS (chip select) pin of ADC form controller. ADC requires delay of two clock pulses before starting data conversion. At the second clock cycle, ADC sends a ‘0’ bit to the controller which indicates that the upcoming bits are the data bits.

 
ADC needs eight clock pulses to send 8-bit digital output. This digital data is received bit by bit and stored in a variable.  The data is converted to its corresponding ASCII value and sent to LCD for display. The connections of LCD with microcontroller are shown in circuit diagram. The analog signals are generated by at a variable resistance (preset) which is connected to input pin of ADC0831.  
 
Algorithm
1.      Initialize LCD.
2.      Send a high to low pulse to CS pin to initialize conversion.
3.      Send two clock pulses.
4.      Receive the data bits by one by one and store it in a variable.
5.      Display its corresponding decimal value on LCD.
 

Project Source Code

###


// Program to Interface ADC0831 with 8051 Microcontroller
#include<reg51.h>
#include<intrins.h>
sfr lcd_data_pin=0xA0;//p2 port
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;
sbit DO=P1^3;
sbit CS=P1^4;
sbit clk=P1^5;
unsigned char read,value,lcd;
 
void delay(unsigned int count)
{
int i,j;
for(i=0;i<count;i++)
for(j=0;j<1275;j++);
} 
 
void lcd_command(unsigned char comm)
{
lcd_data_pin=comm;
en=1;
rs=0;
rw=0;
delay(1);
en=0;
}
 
void lcd_data(unsigned char disp)
{
lcd_data_pin=disp;
en=1;
rs=1;
rw=0;
delay(1);
en=0;
}
 
lcd_dataa(unsigned char *disp)
{
int x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]);
 
}
}
 
void lcd_ini()
{
lcd_command(0x38);  // for using 8-bit 2 row LCD 
delay(5);
lcd_command(0x0F);        // for display on cursor blinking
delay(5);
lcd_command(0x0C);
delay(5);
lcd_command(0x80);
delay(5);
}
 
void lcd_display(unsigned char val)
{
 
unsigned char flg=0;
lcd_command(0xC7);
if(val==0)
lcd_data('0');
while(val>0)
{ 
 
lcd=val%10;
val=val/10;
lcd_command(0xC7-flg);
lcd_data(lcd+'0');
flg++;  
}
if(flg==1)
{
lcd_command(0xC6);
lcd_data(' ');
lcd_command(0xC5);
lcd_data(' ');
}
if(flg==2)
{
lcd_command(0xC5);
lcd_data(' ');
}
  
}
 
unsigned char read_byte()
{
unsigned char i;
read=0;
for(i=0;i<8;i++)
{
read=read<<1; //shift variable by one bit
clk=1;
_nop_();
_nop_();
if(DO==1) // if receive bit is one
{
read++; // increase the value of read by one else do nothig
}
clk=0;
}
return read; // return digital data stored in "read" variable
 
}
 
void adc()
 {
DO=1;
CS=1;
_nop_();
_nop_();
CS=0;
clk=1;
_nop_();
    _nop_();
clk=0;
clk=1;
_nop_();
    _nop_();
clk=0;
value=read_byte();
lcd_display(value);
 } 
 
void main()
{
lcd_ini();
lcd_dataa("ADC OUTPUT: ");
while(1)
{
value=read_byte();
adc();
}
}

###

 


Circuit Diagrams

Circuit-Diagram-Interface-Serial-ADC0831-8051-Microcontroller-AT89C51

Project Components

  • AT89C51 Microcontroller
  • LCD
  • Preset

Project Video


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

Next Article

← Previous Article
Next Article →

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.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

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!


RSS EDABOARD.com Discussions

  • Disappearing clock
  • How to best test Electrolytic capacitors for premature failure reduced life?
  • 12VAC to 12VDC 5A on 250ft 12AWG
  • TMP117 > Can not read temperature on LCD
  • LDO simulation by pcb

RSS Electro-Tech-Online.com Discussions

  • LED circuit for 1/6 scale diorama
  • Electronic board faulty?!?
  • Is there a Power Bank that can also be charged with electricity?
  • applying solder paste from a jar
  • Did a Buyer Kill My Amp?

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • Sienna Semiconductor data converters feature sample rates from 20 to 250 Msps
  • Delta’s 5,500 W power supplies achieve 97.5% energy efficiency for AI servers
  • Novosense Microelectronics releases digital isolators with capacitive-based design
  • MIPI C-PHY adds encoding option to support next-gen image sensor applications
  • Littelfuse gate driver delivers 1.9 A source and 2.3 A sink output current

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 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

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey 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
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe