Program For Digital Clock Using 8051

Sometimes people find it difficult to read temperature from analog thermometer because of fluctuations. So here we are going to build a simple Digital thermometer using 8051 microcontroller in which LM35 sensor is used for measuring the temperature.

This project will also serve as a proper interfacing of ADC0804 with 8051 and 16*2 LCD with 8051 microcontroller.

Components Required:

  1. 8051 based Real time clock is a digital clock to display real time using a RTC DS1307, which works on I2C protocol. Real time clock means it runs even after power failure. When power is reconnected, it displays the real time irrespective to the time and duration it was in off state.
  2. Real Time Clock interfacing with 8051 Sample code for Real Time Clock interfacing with 8051. Following code can be using for 8051 and 8052 ICs like: 89c51, 89c52, 89s51, 89s52, 89c2051.
  3. In this mini-project, we are going to make a simple Digital Stopwatch by using a Microcontroller from 8051 families. Digital Stopwatch allows you to record the exact number of hours and minutes you worked on a task/activity.

As mentioned already, the primary objective of the first laboratory is to design a digital clock on a 4 LED display using 8-bit 8051 microcontroller. The target system is expected to perform sixty seconds counts, i.e., for example counting from 00:00 to 00:59 in one second interval and repeating the counts one second after it reaches 00:59. This is a simple digital voltmeter circuit diagram using 8051 microcontroller. We can also call it as analog to digital converter. (to demonstrate the program) DC Adapter or Battery; Digital Voltmeter Circuit Design using 8051 Microcontroller. The conversion time of this IC depends on clock source. ADC Features. 0 to 5V analog input. 8051 Microcontroller is a programmable device which is used for controlling purpose. Basically 8051 controller is Mask programmable means it will programmed at the time of manufacturing and will not programmed again, there is a derivative of 8051 microcontroller, 89c51 micro controller which is re-programmable.

  • 8051 development board
  • ADC0804 board
  • 16*2 LCD display
  • LM35 sensor
  • Potentiometer
  • Jumper wires

Circuit Diagram:

Measuring Temperature with LM35 using 8051:

8051 microcontroller is a 8 bit microcontroller which has 128 bytes of on chip RAM , 4K bytes of on chip ROM, two timers, one serial port and four 8bit ports. 8052 microcontroller is an extension of microcontroller. The table below shows the comparison of 8051 family members.

Feature

8051

8052

ROM (in bytes)

4K

8K

RAM (bytes)

128

256

Timers

2

3

I/O pins

E.g 162) • Enjoy Replacing models: • Open CustomSteve/CS.txt,replace “Miku” with “yaya” or “Flandre” Customization: • Currently our mod support model files of pmd format,and action files of vmd format. Requirement: • OS at least Windows 7 (not yet support the linux or mac os.) • 64bits JRE(32bits only works with Miku model) How to install: • Download and install • Download and install • Download the mod • Find the location of.minecraft folder • Put CustomSteve***-Beta.jar into.minecraft/mods • Extract CustomSteve***-Resources.zip to the root directory of Minecraft(which is at the same level as.minecraft) • (*** is the version of the mod. How to install mod 3d custom girl mods catalog. • If texture files of tga format are detected in original files, they will be converted into png format. • Only texture files of png or bmp format are supported.

32

32

Serial port

1

1

Interrupt sources

6

8

16x2 LCD:

16*2 LCD is a widely used display for embedded applications. Here is the brief explanation about pins and working of 16*2 LCD display. There are two very important registers inside the LCD. They are data register and command register. Command register is used to send commands such as clear display, cursor at home etc., data register is used to send data which is to be displayed on 16*2 LCD. Below table shows the pin description of 16*2 lcd.

Pin

Symbol

I/O

Description

1

Vss

-

Ground

2

Vdd

-

+5V power supply

3

Vee

-

Power supply to control contrast

4

RS

I

RS=0 for command register ,

RS=1 for data register

5

RW

I

R/W=0 for write , R/W=1 for read

6

E

I/O

Enable

7

D0

I/O

8-bit data bus(LSB)

8

D1

I/O

8-bit data bus

9

D2

I/O

8-bit data bus

10

D3

I/O

8-bit data bus

11

D4

I/O

8-bit data bus

12

D5

I/O

8-bit data bus

13

D6

I/O

8-bit data bus

14

D7

I/O

8-bit data bus(MSB)

15

A

-

+5V for backlight

16

K

-

Ground

The below table shows frequently used LCD command codes.

Code(hex)

Description

01

Clear display screen

06

Increment cursor (right shift)

0A

Display off , cursor on

0C

Display on , cursor off

0F

Display on , cursor blinking

80

Force the cursor to beginning of 1st line

C0

Force the cursor to beginning of 2nd line

38

2 lines and 5*7 matrix

ADC0804 IC:

The ADC0804 IC is an 8-bit parallel ADC in the family of the ADC0800 series from National Semiconductor. It works with +5 volts and has a resolution of 8bits. The step size and Vin range varies for different values of Vref/2. The table below shows the relation between Vref/2 and Vin range.

Vref/2 (V)

Vin (V)

Step size (mV)

open

0 to 5

19.53

2.0

0 to 4

15.62

1.5

0 to 3

11.71

1.28

Sep 02, 2013  Check out Crises (Deluxe Edition) by Mike Oldfield on Amazon Music. Stream ad-free or purchase CD's and MP3s now on Amazon.com. Crises (Deluxe Edition) Mike Oldfield. September 2, 2013. Crises is one of Mike's best albums and I wish and hope that a similar 5-box set comes out on Discovery. Pleas be working on that mike! Mike Oldfield - Crises (2013) (Super Deluxe Edition) [24-96] 4 torrent download locations demonoid.pw Mike Oldfield - Crises [Super Deluxe Edition] (1983) [2013] [HDtracks] [FLAC] Music 28 days monova.org 1983. Mike Oldfield - Crises (2013) (Super Deluxe Edition) [24-96] Other 2 days. Download Mike Oldfield - Crises (Deluxe Edition) 2013 2CD-Reissue torrent from music category on Isohunt. Torrent hash: 99ffcced91fe20a0cc6feceb5eb8e4d8d08e8ce8. Mike oldfield crisis deluxe edition torrent free

0 to 2.56

10

In our case Vref/2 is connected to 1.28 volts, so step size is 10mV. For ADC0804 step size is calculated as (2 * Vref / 2) / 256.

Following formula is used to calculate output voltage:

Where Dout is digital data output in decimal, Vin = analog input voltage and step size (resolution) is the smallest change. Learn more about ADC0804 here, also check interfacing of ADC0808 with 8051.

LM35 Temperature Sensor:

The LM35 is a temperature sensor whose output voltage is linearly proportional to Celsius temperature. The LM35 comes already calibrated hence requires no external calibration. It outputs 10mV for each degree of Celsius temperature.

LM35 sensor produces voltage corresponding to temperature. This voltage is converted to digital (0 to 256) by ADC0804 and it is fed to 8051 microcontroller. 8051 microcontroller converts this digital value into temperature in degree Celsius. Then this temperature is converted into ascii form which is suitable for displaying. This ascii values are fed to 16*2 lcd which displays the temperature on its screen. This process is repeated after specified interval.

Code explanation:

The complete C program for this 8051 Thermometer Project is given at the end of this project. The code is split into small meaningful chunks and explained below.

For 16*2 LCD interfacing with 8051 microcontroller , we have to define pins on which 16*2 lcd is connected to 8051 microcontroller. RS pin of 16*2 lcd is connected to P2.7 , RW pin of 16*2 lcd is connected to P2.6 and E pin of 16*2 lcd is connected to P2.5. Data pins are connected to port 0 of 8051 microcontroller.

Similarly, for ADC0804 interfacing with 8051 microcontroller, we have to define pins on which ADC0804 is connected to 8051 microcontroller. RD pin of ADC0804 is connected to P3.0, WR pin of ADC0804 is connected to P3.1 and INTR pin of ADC0804 is connected to P3.2. Data pins are connected to port 1 of 8051 microcontroller.

Next we have to define some functions which are used in the program. Delay function is used to create specified time delay, cmdwrt function is used to send commands to 16*2 lcd display, datawrt function is used to send data to 16*2 lcd display and convert_display function is used to convert the ADC data into temperature and to display it on 16*2 lcd display.

In below part of the code, we are sending commands to 16*2 lcd. Commands such as clear display, increment cursor, force the cursor to beginning of 1st line are sent to 16*2 lcd display one by one after some specified time delay.

In this part of the code, we are sending data to 16*2 lcd. Data to be displayed on 16*2 lcd display are sent to display one by one after some specified time delay.

In this part of the code we are converting the analog voltage produced by LM35 sensor to digital data and then it is converted to temperature and displayed on 16*2 lcd display. For ADC0804 to start the conversion we have to send a low to high pulse on WR pin of ADC0804, then we have to wait for end of conversion. INTR becomes low at the end of conversion. Once INTR becomes low, RD is made low to copy the digital data to port 0 of 8051 microcontroller. After a specified time delay, next cycle starts. This process is repeated forever.

In below part of the code , we are sending commands to 16*2 lcd display. The command is copied to port 0 of 8051 microcontroller. RS is made low for command write. RW is made low for write operation. High to low pulse is applied on enable(E) pin to start command write operation.

In this part of the code, we are sending data to 16*2 lcd display. The data is copied to port 0 of 8051 microcontroller. RS is made high for command write . RW is made low for write operation. High to low pulse is applied on enable(E) pin to start data write operation.

In this part of the code, we are converting digital data into temperature and displaying it on 16*2 lcd display.

Also, check other thermometers using LM35 with different microcontrollers:

/*this program is for displaying the temperature on 16*2 lcd display using 8051 microcontroller , LM35 sensor and ADC0804*/
#include<reg51.h>
sbit rs=P2^7; //Register Select(RS) pin of 16*2 lcd
sbit en=P2^5; //Enable(E) pin of 16*2 lcd
sbit rd_adc=P3^0; //Read(RD) pin of ADC0804
sbit intr_adc=P3^2; //Interrupt(INTR) pin of ADC0804
void delay(unsigned int) ; //function for creating delay
void cmdwrt(unsigned char); //function for sending commands to 16*2 lcd display
void datawrt(unsigned char); //function for sending data to 16*2 lcd display
void convert_display(unsigned char); //function for converting ADC value to temperature and display it on 16*2 lcd display
void main(void) //main function
unsigned char i;
unsigned char cmd[]={0x38,0x01,0x06,0x0c,0x82};//16*2 lcd initialization commands
unsigned char value;
P1=0xFF; //make Port 1 as input port
for(i=0;i<5;i++) //send commands to 16*2 lcd display one command at a time
cmdwrt(cmd[i]); //function call to send commands to 16*2 lcd display

Assembly Language Code For Digital Clock Using 8051

}
for(i=0;i<12;i++) //send data to 16*2 lcd display one character at a time
datawrt(data1[i]); //function call to send data to 16*2 lcd display
}
intr_adc=1; //make INTR pin as input
wr_adc=1; //set WR pin LOW
while(1) //repeat forever
wr_adc=0; //send LOW to HIGH pulse on WR pin

Digital Clock Download

wr_adc=1;
rd_adc=0; //make RD = 0 to read the data from ADC0804
convert_display(value); //function call to convert ADC data into temperature and display it on 16*2 lcd display
rd_adc=1; //make RD = 1 for the next cycle
void cmdwrt (unsigned char x)
P0=x; //send the command to Port 0 on which 16*2 lcd is connected
rw=0; //make RW = 0 for write operation
en=1; //send a HIGH to LOW pulse on Enable(E) pin to start commandwrite operation
en=0;
void datawrt (unsigned char y)

Program For Digital Clock Using 8051 Numbers

P0=y; //send the data to Port 0 on which 16*2 lcd is connected
rw=0; //make RW = 0 for write operation
en=1; //send a HIGH to LOW pulse on Enable(E) pin to start datawrite operation
en=0;
void convert_display(unsigned char value)
unsigned char x1,x2,x3;
cmdwrt(0xc6); //command to set the cursor to 6th position of 2nd line on 16*2 lcd
x1=(value/10); //divide the value by 10 and store quotient in variable x1
x1=x1+(0x30); //convert variable x1 to ascii by adding 0x30
x2=value%10; //divide the value by 10 and store remainder in variable x2
x2=x2+(0x30); //convert variable x2 to ascii by adding 0x30
datawrt(x1); //display temperature on 16*2 lcd display
datawrt(x3);
}
void delay(unsigned int z)
unsigned int p,q;
{
}