8051 Code and Project
8051 Code and Project
8051 Code and Project
Project report
On
“EMBEDDED SYSTEM AND RTC CLOCK”
B.E. Semester-IV
(Electronics Engineering)
Submitted By
Group:-
Guided by:
Prof . KOMAL SONI
2|Page
2022
I. ACKNOWLEDGEMENT
We take this opportunity to express our sincere thanks and deep sense of
gratitude to our guide “Prof . KOMAL SONI” for imparting us valuable guidance
during this work. They helped us by solving many doubts and suggesting many
references. His presence and optimism have provided an invaluable influence
on my career and outlook for the future. I consider it my good fortune to have
an opportunity to work with such a wonderful person.
Lastly, We express deep sense of gratitude towards our colleagues and also to
3|Page
2022
PART 1: DAY TO DAY WORK
DAY 1:
Intel introduced an 8-bit microcontroller called the 8051. It was referred as system on a
chip because it had 128 bytes of RAM, 4K byte of on-chip ROM, two timers, one serial
port, and 4 ports (8-bit wide), all on a single chip. When it became widely popular, Intel
allowed other manufacturers to make and market different flavors of 8051 with its code
compatible with 8051.
4|Page
2022
DAY 2
SINGLE LED
#include<reg52.h> // special function register declarations
// for the intended 8051 derivative
void Delay(void)
{
int j;
int i;
for(i=0;i<10;i++)
{
for(j=0;j<10000;j++)
{
}
}
}
led1=0;
led6=0;
delay();
led1=1;
led6=1;
delay();
led2=0;
led5=0;
delay();
led2=1;
led5=1;
delay();
led3=0;
led4=0;
delay();
led3=1;
led4=1;
delay();
}
}
void delay()
{
int i,j;
for( i =0; i<10;i++)
6|Page
2022
for(j =0;j<1000;j++);
}
7|Page
2022
DAY 3
LCD INTERFACING
LCD INTERFACING
#include<reg51.h>
sbit RS=P2^0;
sbit RW=P2^6;
sbit EN=P2^1;
void delay(int i)
{
int m;
while(i>0)
{
for(m=0;m<1275;m++)
{
i--;
}
}
}
8|Page
2022
EN=1;
delay(2);
EN=0;
delay(2);
}
void lcd_data(unsigned char cmd)
{
//P3=d;
P2=((cmd&0xF0)>>2);
RS=1;
RW=0;
EN=1;
delay(2);
EN=0;
delay(2);
P2=(cmd & 0x0f)<<2;
RS=1;
RW=0;
EN=1;
delay(2);
EN=0;
delay(2);
}
void lcd_init(void)
{
lcd_cmd(0x02);
lcd_cmd(0x28);
lcd_cmd(0x06);
lcd_cmd(0x0E);
lcd_cmd(0x01);
lcd_cmd(0x1c);
{
lcd_init();
lcd_string("sj the king");
}
}
10 | P a g e
2022
DAY 4
sbit seg2=P1^1;
sbit seg3=P1^2;
sbit seg4=P1^3;
void delay(unsigned int time)
{
int i,j;
for( i =0; i<time;i++)
for(j =0;j<1000;j++);
}
void main()
{
for(A=0;A<10;A++)
{
P0=SHIVAM[A];
delay(100);
}
}
}
12 | P a g e
2022
DAY 5
IR SENSOR INTERFACING
IR SENSOR INTERFACING
#include<reg51.h>
#include "delay.h"
sbit RS=P2^0;
sbit RW=P2^6;
sbit EN=P2^1;
sbit sw1=P1^1;
void lcd_cmd(unsigned char cmd)
{
//P3=cmd;
P2=((cmd&0xF0)>>2);
RS=0;
RW=0;
EN=1;
delay(2);
EN=0;
delay(2);
P2=(cmd & 0x0f)<<2;
RS=0;
RW=0;
EN=1;
delay(2);
EN=0;
delay(2);
}
void lcd_data(unsigned char cmd)
{
//P3=d;
P2=((cmd&0xF0)>>2);
RS=1;
13 | P a g e
2022
RW=0;
EN=1;
delay(2);
EN=0;
delay(2);
P2=(cmd & 0x0f)<<2;
RS=1;
RW=0;
EN=1;
delay(2);
EN=0;
delay(2);
}
void lcd_init(void)
{
lcd_cmd(0x02);
lcd_cmd(0x28);
lcd_cmd(0x06);
lcd_cmd(0x0E);
lcd_cmd(0x01);
lcd_cmd(0x1c);
while(1)
14 | P a g e
2022
if(sw1==1)
{
lcd_init();
lcd_string("shivam detected");
}
else
{
lcd_init();
lcd_string("deep detected");
}
}
}
15 | P a g e
2022
DAY 6
16 | P a g e
2022
}
17 | P a g e
2022
DAY 7
18 | P a g e
2022
We have analyzed some videos and some research papers related to our project .
At first we wondered if this could be practically implemented or not? After thinking about
it, we started researching it and then analyzing its related documents, research papers
and many such patents. Then step by step we started working on it. Then we made a list
of all the components needed for our project. Then we will do the next part where we can
find the components from both the platform offline and online. After that we implement
the circuit on bread board.
19 | P a g e
2022
2.1 INTRODUCTION
In this article, we are going to see how to interface an RTC (Real Time Clock) Module to 8051
micro controller. There are different kinds of RTC module available in the market. We are using
the most common RTC module that comes with the DS1307 IC, an LCD module and AT89c51
(8051 variant) for this tutorial. AT89C52 is a typical 8051 microcontroller manufactured by
Atmel. Interfacing an RTC module to 8051 microcontroller is pretty simple. You only need to
make 2 connections between the RTC module and 8051
20 | P a g e
2022
RTC DS1307
AT89C51
LCD
RESISTOR
CRYSTAL OSSILATOR
Battery
RTC DS1307
Real time clocks (RTC), as the name recommends are clock modules. The DS1307
real time clock (RTC) IC is an 8 pin device using an I2C interface. The DS1307 is a
low-power clock/calendar with 56 bytes of battery backup SRAM. The
clock/calendar provides seconds, minutes, hours, day, date, month and year
qualified data. The end date of each month is automatically adjusted, especially
for months with less than 31 days.
AT89C51
21 | P a g e
2022
LCD
The term LCD stands for liquid crystal display. It is one kind of electronic display
module used in an extensive range of applications like various circuits & devices like
mobile phones, calculators, computers, TV sets, etc. These displays are mainly
preferred for multi-segment light-emitting diodes and seven segments. The main
benefits of using this module are inexpensive; simply programmable, animations, and
there are no limitations for displaying custom characters, special and even
animations, etc.
22 | P a g e
2022
RESISTOR
CRYSTAL OSSILAOR
The crystal oscillator is a quartz crystal used as a frequency selective element. The quartz
crystal is also known as piezoelectric crystal. Hence the oscillator circuit containing
piezoelectric crystal is called a crystal oscillator. It has two electrodes that supply signals
to the crystal. Crystal oscillators have high-frequency stability and a high-Quality factor
compared to RC and LC tuned circuit oscillators. It is considered one of the highly stable
oscillators suitable for high-frequency applications.
BUTTON CELL
23 | P a g e
2022
24 | P a g e
2022
In our project microcontroller communicate with the RTC chip on I C protocol, in which microcontroller
2
Microcontroller will read the data from RTC chip which is initially written by uC , perform required
operations on it and send that data to the LCD unit which will display it in human readable format.
25 | P a g e
2022
Merit
An external RTC allows you to keep the clock running
while the microcontroller is powered down
Demerit
Keeping the RTC on results in leakage current from the microcontroller, which does waste
some energy.
3.3 USES
It use in railway
Automobile
Computers
Washing machin
watch
26 | P a g e
2022
CHAPTER 4: REFERENCES
1) https://youtu.be/jNfnQWzhygg
2) https://youtube.com/playlist?list=PLRuRKN7_FVgtdXWWM-uosWYfmOFDp63dd
3) https://youtu.be/4GKbIPlvCrY
4) https://youtube.com/playlist?list=PLgwJf8NK-2e55CdbY_WnY6pejPHoojCkJ
1) https://www.googleadservices.com/pagead/aclk?
sa=L&ai=DChcSEwiT55nQpN34AhVRq5YKHZIgDcAYABAAGgJ0bA&ae=2&ohost=www.google.com&cid=C
AESbeD2Z1R5p9RDZaITB-iRpf6R6RQiDhS2qkGG-
vO0RYNZeD_fYR3el53ZgN5Uk0X8BblvX_NXTGQ8TL_8ABuY5VyTKw9Tzso7nG8cSYBtUlX5KQrYVYCOU6M
WUozCX6MrKpJY4ABQLSqi5Bi9-
Cg&sig=AOD64_02pcoQNXzx5PPXJctp4RihjnAJxw&q&adurl&ved=2ahUKEwjG9JLQpN34AhURGYgKHSTID
HIQ0Qx6BAgCEAE
2) https://www.googleadservices.com/pagead/aclk?
sa=L&ai=DChcSEwj7odbcpN34AhWWrZYKHQfwDNsYABAAGgJ0bA&ae=2&ohost=www.google.com&cid=
CAESbeD2XjqcGK5hnOx3dXdC0DloK0MAx14_kO9IYFwaiUSf115_kLoK-
b413y74YmDaEQSAyd4dzGALVaguX8ShSEe27zPvXk7m0U7-
dRNnZcroiNKDQBOgP3zNNS2ME6X5Ig7mC0moXPGnggverfM&sig=AOD64_3QcTtA6v5JnwKBfhhifpDhu9
zXLQ&q&adurl&ved=2ahUKEwihws_cpN34AhVYUd4KHTXHAckQ0Qx6BAgCEAE
3) https://www.edaboard.com/threads/7-segment-rtc-clock-with-temperature-display.259183/
4) https://www.hackster.io/embedotronics-technologies/counting-from-0-to-9999-with-8051-using-7-
segment-display-3cf151
5) https://www.engineersgarage.com/real-time-clock-with-alarm-option-using-at89s52-and-ds1307-ic/
27 | P a g e