8051 Code and Project

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 27

Birla Vishwakarma Mahavidyalaya

Anand, Gujarat 388120

Project report
On
“EMBEDDED SYSTEM AND RTC CLOCK”

B.E. Semester-IV
(Electronics Engineering)
Submitted By
Group:-

SHIVAM JAYSWAL (20EL27)

DEVANG RATHOD (20EL07)

DEEP PATEL (20EL24)

AYUSH SHAH (20EC451)

Guided by:
Prof . KOMAL SONI

Academic year (2021-2022)


2022
INDEX
Table of Contents
I. ACKNOWLEDGEMENT.........................................................................................................................................................3
PART 1: DAY TO DAY WORK...................................................................................................................................................4
DAY 1:................................................................................................................................................................................ 4
DAY 2................................................................................................................................................................................. 5
DAY 3................................................................................................................................................................................. 8
DAY 4............................................................................................................................................................................... 11
DAY 5............................................................................................................................................................................... 13
DAY 6............................................................................................................................................................................... 16
DAY 7............................................................................................................................................................................... 18
PART 2: INTERNSHIP PROJECT..............................................................................................................................................19
CHAPTER 1: INTRODUCTION............................................................................................................................................19
1.1 AIM AND OBJECTIVE OF THE PROJECT.......................................................................................................................19
1.2 BRIEF LITERATURE REVIEW........................................................................................................................................19
1.3 PLAN OF PROJECT......................................................................................................................................................19
CHAPTER 2: INTRODUCTION AND BLOCK DIAGRAM............................................................................................................20
2.1 INTRODUCTION.........................................................................................................................................................20
2.2 BLOCK DIAGRAM.......................................................................................................................................................20
2.3 TOOLS/COMPONENTS REQUIRED.............................................................................................................................21
CHAPTER 3: CIRCUIT DIAGRAM............................................................................................................................................25
3.1 WORKING OF THE PROJECT.......................................................................................................................................25
3.2 MERIT AND DEMERIT.................................................................................................................................................26
3.3 USES........................................................................................................................................................................... 26
CHAPTER 4: REFERENCES.....................................................................................................................................................27
4.1YOUTUBE VIDEO LINK.................................................................................................................................................27
4.2 RESEARCH PAPER.......................................................................................................................................................27

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.

who helped us by giving valuable suggestions and encouragement which not


only helped us in preparing this work but also in having a better insight in this
field.

Lastly, We express deep sense of gratitude towards our colleagues and also to

those who directly or indirectly helped us throughout this work.

3|Page
2022
PART 1: DAY TO DAY WORK
DAY 1:

INTRODUCTION TO 8051 AND INTERFACING OF 8051 KIT

 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.

 To interface 8051 kit following download are require:


 keil uvision
 8051 flash
 Driver

4|Page
2022
DAY 2

SINGLE LED BLINK & ROW LED BLINK

 SINGLE LED
#include<reg52.h> // special function register declarations
// for the intended 8051 derivative

sbit LED = P2^0; // Defining LED pin

void Delay(void); // Function prototype declaration

void main (void)


{
while(1) // infinite loop
{
LED = 0; // LED ON
Delay();
LED = 1; // LED OFF
Delay();
}
}

void Delay(void)
{
int j;
int i;
for(i=0;i<10;i++)
{
for(j=0;j<10000;j++)
{
}
}
}

 ROW LED BLINK


#include<reg51.h>
5|Page
2022
sbit led= P3^0;
sbit led1= P3^1;
sbit led2= P3^2;
sbit led3= P3^3;
sbit led4= P3^4;
sbit led5= P3^5;
sbit led6= P3^6;
sbit led7= P3^7;
void delay();
void main()
{
while(1)
{
led=0;
led7=0;
delay();
led=1;
led7=1;
delay();

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--;
}
}
}

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;

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);

void lcd_string(char *s)


9|Page
2022
{
while(*s)
lcd_data(*s++);
}
void main()
{

{
lcd_init();
lcd_string("sj the king");

}
}

10 | P a g e
2022
DAY 4

SEVEN SEGMENT DISPLAY INTERFACING

 SEVEN SEGMENT DISPLAY


#include<reg51.h>

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()
{

unsigned char SHIVAM[]={0XC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X90};


int A ;
seg2=0;
seg3=0;
seg4=0;
while(1)
11 | P a g e
2022
{

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);

void lcd_string(char *s)


{
while(*s)
lcd_data(*s++);
}
void main()
{

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

MOTOR DRIVER L293D

 MOTOR DRIVER L293D


#include<reg51.h>
sbit out1=P1^0;
sbit out4=P1^1;
sbit sw1= P2^0;
sbit sw2= P2^1;
sbit en1=P1^2;
sbit en2=P1^3;
void main()
{
P1=0X00;
P2=0XFF;
en1=0;
en2=0;
while(1)
{
en1=P1^2;
en2=P1^3;
if(sw1==0)
{
out1=1;
while(sw1==0);
}
if(sw2==0)
{
out4=1;
while(sw2==0);
}
out1=out4=0;
}

16 | P a g e
2022
}

17 | P a g e
2022
DAY 7

INTRODUCTION TO ESP8266 AND INTERFACING

 KEY FEATURES ESP8266 WIFI Module


32 – bit microcontroller

 Central processing unit: 80 MHz or 160 MHz
 Instruction RAM: 32 KB
 Cache RAM: 32 KB
 User data RAM: 80 KB
 ETS system data RAM: 16 Kb
 External memory: 16 MB
 General purpose input output pins: 16
 SPI supported
 I2C interface supported
 I2S interface supported
 Wi-Fi standard of 802.11 b / g / n
 UART supported on specific pins
 10 – bit analog to digital converter (ADC)
 Protocol stack: TCP / IP
 To interface ESP8266 following download are require:
 ARDUINO IDE
 DRIVER

18 | P a g e
2022

PART 2: INTERNSHIP PROJECT


CHAPTER 1: INTRODUCTION

1.1 AIM AND OBJECTIVE OF THE PROJECT

Display time on lcd panel by using RTC DS1307 and AT89C51 .

1.2 BRIEF LITERATURE REVIEW

We have analyzed some videos and some research papers related to our project .

1.3 PLAN OF 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

CHAPTER 2: INTRODUCTION AND BLOCK DIAGRAM

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

2.2 BLOCK DIAGRAM

2.3 TOOLS/COMPONENTS REQUIRED

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

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with


4K bytes of Flash programmable and erasable read-only memory (PEROM). The
device is manufactured using Atmel’s high-density nonvolatile memory technology
and is compatible with the industry-standard MCS-51 instruction set and pinout.
The on-chip Flash allows the program memory to be reprogrammed in-system or
by a conventional nonvolatile memory programmer. By combining a versatile 8-bit
CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful
microcomputer that provides a highly-flexible and cost-effective solution to many
embedded control applications.

 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

A resistor is a passive two-terminal electrical component that implements


electrical resistance as a circuit element. Resistors act to reduce current flow, and,
at the same time, act to lower voltage levels within circuits. In electronic circuits,
resistors are used to limit current flow, to adjust signal levels, bias active
elements, and terminate transmission lines among other uses.

 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

It provides 3v D.C supply.

24 | P a g e
2022

CHAPTER 3: CIRCUIT DIAGRAM

3.1 WORKING OF THE PROJECT

 In our project microcontroller communicate with the RTC chip on I C protocol, in which microcontroller
2

will work as a master and RTC chip as a slave.

 RTC chip is able to maintain the time of its own.

 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.

 This process is going to continue for infinite time.

3.2 MERIT AND DEMERIT

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

4.1YOUTUBE VIDEO LINK

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

4.2 RESEARCH PAPER

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

You might also like