Digital Theromometer Using 8051
Digital Theromometer Using 8051
Laboratory
Presented by,
Amirul Kabeer J (95072014006)
Bala Subramanian M(95072014010)
Harinath Siva M (95072014025)
Ishant Prabhu A (95072014028)
Jason Israel J (95072014031)
1
Introduction:
WORKING:
Here, Temperature is taken from the LM35 temperature sensor. LM35 converts
surrounding temperature into analog voltage (equivalent to temperature). This
analog voltage is provided to ADC0808 for digital conversion.
After digital conversion, the final temperature gets displayed on the LCD
display.
2
LCD (16X2) DISPLAY:
LM35 SENSOR:
ADC 0808:
Here supposed vref(+) is connected to VCC pin of ADC 0808 then step size is
equal to 19.53mv.
3
Calculation of vref(+) with step size of 10mv:
• 10*10^-3=[vref(+) - 0v]/256
• vref(+)=(10*10^-3)*(256)
• vref(+)=2.56v
1. Provide a clock signal of frequency (10 kHz up to 640 kHz) on the clock pin
of ADC 0808.I have selected the frequency of 15khz. Make EOC an input pin.
Clear START, ALE, and OE pin of ADC0808.
If we are taking analog signal from pin IN0 then select channel 0. Whenever we
are giving signals to pin IN0 to IN7, it is necessary to select the appropriate
channel with respect to that pin.
Here I have provided the analog output of the LM35 sensor to pin IN0 of ADC
0808, hence I have selected channel 0 by providing 0 to ADDC, ADDB, ADDA
pin of ADC 0808.
7. Take the data from the port of 8051 where output pins (OUT1 to OUT8) of
ADC 0808 are connected.
Here I have connected output pins of ADC 0808 to Port 1 of 8051. Hence, I
have taken data from Port 1.
4
8. Clear OE pin.
CIRCUIT DIAGRAM:
5
PROGRAM:
#include<reg51.h>
#include<string.h>
sbit RS = P2^5;
sbit RW = P2^6;
sbit EN = P2^7;
sbit ale=P2^3;
sbit oe=P2^4;
sbit start=P2^1;
sbit eoc=P2^0;
sbit clk=P2^2;
sbit chb=P0^6;
sbit cha=P0^5;
void delay(int t);
void lcd_init(void);
long float k;
clk=~clk;
}
void main() // MAIN PROGRAM
str("!!welcome!!");
str("Temp:");
lcd_data(0x10);
lcd_data(0x07);
lcd_data(0x08);
lcd_data(0x08);
lcd_data(0x08);
lcd_data(0x08);
lcd_data(0x07);
lcd_command(0x8b);
lcd_data(4);
7
ale=0;
oe=0;
start=0;
TH0=0xc2; // 15khz
while(1)
chb=0;
cha=0;
start=1;
delay(1);
ale=0;
start=0;
while(eoc==0);
oe=1;
8
k=P1;
lcd_command(0x85);
oe=0;
int j;
for(j=0;a[j]!='\0';j++)
lcd_data(a[j]);
9
lcd_command(0x0c); //cursor off
P3=c;
RS=0;
EN=1;
delay(5);
EN=0;
delay(5);
P3=d;
RW=0;
EN=1;
delay(5);
10
EN=0;
delay(5);
int j;
for(j=0;j<t*1275;j++);
x=p*10;
if(x>=1000)
q=x/1000;
q=q+48;
y=(x%1000)/100;
y=y+48;
z=((x%1000)%100)/10;
z=z+48;
r=x%10;
11
r=r+48;
lcd_data(q);
lcd_data(y);
lcd_data(z);
lcd_data(r);
else
q=x/100;
q=q+48;
y=(x%100)/10;
y=y+48;
z=x%10;
z=z+48;
lcd_data(q);
lcd_data(y);
lcd_data(z);
r=0;
12
lcd_data(r);
}
}
PROGRAM DESCRIPTION:
Firstly, I have initialized the LCD by providing the various LCD commands
required for initialization. After that LCD command function and LCD data
function are declared. Delay function is used to provide sufficient delay. The
string function is used to print the string.
In LCD to pass the commands, the command register needs to be selected, and
the enable pin must be provided with a high to low pulse to process those
commands. The command register is selected by providing logic 0 to RS
(Register Select) pin of LCD.
To pass the data to the LCD, the data register needs to be selected, and an
enable pin must be provided with high to low pulse to process that data.
For generating the clock signal on the clock pin of adc0808, I have used timer 0
interrupt. Here I have provided a clock signal of 15khz. Whenever the TF0 flag
is set, an interrupt gets generated and the controller starts executing the ISR.
After that I have followed the steps mentioned above (steps for ADC 0808
interfacing). The Output is taken from port 1 of 8051 and send to the lcd
display.
13
Here I have taken four digits number as an example. Suppose I want to display
1352 on lcd.
First basic step is initialization of lcd. Then the next step is to decompose
(break) the number.
Ex.1352/1000=1;
2.Divide the number by 1000 and take the remainder of the division. To Divide
that remainder by 100 so that we can get second number.
Ex:(1352%1000)/100= 3;
3.Divide the number by 1000 and take the remainder of the division. Divide that
remainder by 100.Again take the remainder of the division and divide it by 10.
So, that we can get third digit of the number.
4.Divide the number by 10 and take the remainder of the division so that we can
get last digit of the number.
Ex. 1352%10=2;
Ex. a = '0';
14
2.The other way is sending the ASCII value of the character.
Here for displaying the number I have used ASCII value of the characters.
ASCII value of '0' to '9' are ranging from 48 to 57 respectively.
Now after decomposing the number, next step is to add 48 to each separated
digit so that we can able to get ASCII value of that digit.
Ex.
3+48=51;(ASCII value of 3)
5+48=53;(ASCII value of 5)
2+48=50;(ASCII value of 2)
Send those values to lcd display one by one. So that we will be able to display
complete number 1352.This is the basic procedure to display number on lcd.
I have taken the micro-controller with 11.0592 MHZ frequency. So, I have used
timer 0 in mode 2. So, the calculation is
15
OUTPUT:
Practical Applications:
Conclusion:
Utility
• Measure temperature between -50 °C to 155 °C.
• It can sense every .01°C temperature change and display it.
• The unit (°C) can be replaced with °F that can use to measure viral fever.
• It can response immediately after the temperature change.
• It can also provide a digital input to a computer.
Limitations
• This device is costly because of using Microprocessor and LCD display.
• Its size is not so comfortable like others digital thermometer.
• Here we use an external power source.
• It is not convenient to measure a body temperature.
Proposal
• We can use it to measure room temperature of any industry.
• Here we can also measure the humidity of nature and the room.
16
• By adding a loud speakers we can use it as a fire alarm.
• If the production cost can be reduced that thermometer can be used for
daily purpose of general people.
Thus, the digital thermometer is applicable and can able to use in many applications.
17