Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • 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.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

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.

  • PCB layout impact on RF path impedance
  • rechargeable battery and simple alkaline battery in one single product
  • Persistent Shoot-Through vin=vout in Synchronous Buck Converter – Physical Phenomenon Issue
  • Methods for Calculating SNR and SFDR in a CUI for Use in Machine Learning
  • Ensuring Reliable Backups in Azure

RSS Electro-Tech-Online.com Discussions

  • strange laptop problem
  • Panasonic RQ-A170 Walkman recorder
  • WTB: "The Theory Of Servicing AM, FM, And FM Receivers" by Clarence R. Green and Robert M. Bourque
  • Converting 1vac to 24vac
  • AC Input Relay Device Required

Featured – Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
  • A filter design example
  • Types of filter responses
  • What are the two types of hardware filters?
  • What are hardware filters and their types?

Recent Articles

  • GigaDevices introduces 32-bit MCUs with integrated DSP and FPU support
  • Grinn introduces 8-core SBC supporting AI-ready embedded development
  • EPC’s 100 kHz BLDC inverter supports high-efficiency motion control
  • Melexis announces 5 W smart driver to supports sensorless FOC operation
  • STMicroelectronics’ motion sensor simplifies industrial IoT system design

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • 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

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • 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
  • Guest Post Guidelines
  • Advertise
  • Subscribe