27
INTRODUCTION:- This project works as a digital thermometer wherein we use a buzzer to set the alarm for the normal temperature of body. Thermometer displays the ambient temperature through a LCD display. It consists of two sections. One is that which senses the temperature. This is a temperature sensor LM 35. The other section converts the temperature value into a suitable number in Celsius scale which is done by the ADC0804. BLOCK DIAGRAM:- 1

Digital Thermometer Final Report.docx

Embed Size (px)

DESCRIPTION

This project works as a digital thermometer wherein we use a buzzer to set the alarm for the normal temperature of body. Thermometer displays the ambient temperature through a LCD display. It consists of two sections. One is that which senses the temperature. This is a temperature sensor LM 35. The other section converts the temperature value into a suitable number in Celsius scale which is done by the ADC0804.

Citation preview

Page 1: Digital Thermometer Final Report.docx

INTRODUCTION:-

This project works as a digital thermometer wherein we use a buzzer to set the alarm for

the normal temperature of body. Thermometer displays the ambient temperature through

a LCD display. It consists of two sections. One is that which senses the temperature. This

is a temperature sensor LM 35. The other section converts the temperature value into a

suitable number in Celsius scale which is done by the ADC0804.

BLOCK DIAGRAM:-

1

Page 2: Digital Thermometer Final Report.docx

WORKING:-

A digital thermometer can be easily made by interfacing a temperature sensor to the

microcontroller AT89C51. The temperature sensor used in the project isLM35. The LM

35 IC generates a 10mV variation to its output voltage for every degree Celsius change in

temperature. The Output of the temperature sensor is analog in nature so we need an

analog to digital convertor for converting the analog input to its equivalent binary output.

ADC 0804 is an analog to digital convertor IC used in the project. 0804 is a single

channel convertor which converts the analog input up to a range of 5V to an equivalent 8-

bit binary output.

CRCUIT DIAGRAM:-

2

Page 3: Digital Thermometer Final Report.docx

COMPONENTS USED AND THEIR DESCRIPTION:-

Microcontroller AT89C51 ADC0804 LM35 LCD Piezo Buzzer

Microcontroller AT89C51:-

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL

89C51 has 4KB of Flash programmable and erasable read only memory and 128 bytes of

RAM. It can be erased and program to a maximum of 1000 times. In 40 pin AT89C51,

there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional

ports, i.e., they can be used as both input and output ports. Except P0 which needs

external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these

3

Page 4: Digital Thermometer Final Report.docx

port pins, they are pulled high by the internal pull-ups and can be used as inputs. These

ports are also bit addressable and so their bits can also be accessed individually.

4

Page 5: Digital Thermometer Final Report.docx

PIN DESCRIPTION OF AT89C51:-

Pins 1-8: Port 1 Each of these pins can be configured as an input or an output.

Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents of

most registers. In other words, the positive voltage on this pin resets the microcontroller.

By applying logic zero to this pin, the program starts execution from the beginning.

Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or

output. Besides, all of them have alternative functions.

Pin 10: RXD Serial asynchronous communication input or Serial synchronous

communication output.

Pin 11: TXD Serial asynchronous communication output or Serial synchronous

communication clock output.

Pin 12: INT0 Interrupt 0 input.

Pin 13: INT1 Interrupt 1 input.

Pin 14: T0 Counter 0 clock input.

Pin 15: T1 Counter 1 clock input.

Pin 16: WR Write to external (additional) RAM.

Pin 17: RD Read from external RAM.

Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies

operating frequency is usually connected to these pins. Instead of it, miniature ceramics

5

Page 6: Digital Thermometer Final Report.docx

resonators can also be used for frequency stability. Later versions of microcontrollers

operate at a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground.

Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are

configured as general inputs/outputs. In case external memory is used, the higher address

byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity

of 64Kb is not used, which means that not all eight port bits are used for its addressing,

the rest of them are not available as inputs/outputs.

Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears

on it every time the microcontroller reads a byte from memory.

Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower

address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from

the ALE pin, the external register (usually 74HCT373 or 74HCT375 add-on chip)

memorizes the state of P0 and uses it as a memory chip address. Immediately after that,

the ALU pin is returned its previous logic state and P0 is now used as a Data Bus. As

seen, port data multiplexing is performed by means of only one additional (and cheap)

integrated circuit. In other words, this port is used for both data and address transmission.

Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address

transmission with no regard to whether there is internal memory or not. It means that

even there is a program written to the microcontroller, it will not be executed. Instead, the

program written to external ROM will be executed. By applying logic one to the EA pin,

the microcontroller will use both memories, first internal then

external (if exists).

6

Page 7: Digital Thermometer Final Report.docx

Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as

general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the

ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low

(0).

Pin 40: VCC +5V power supply.

ADC0804:-

ADC0804 is a very commonly used 8-bit analog to digital convertor. It is a single

channel IC, i.e., it can take only one analog signal as input. The digital outputs vary from

0 to a maximum of 255. The step size can be adjusted by setting the reference voltage at

pin9. ADC0804 needs a clock to operate. The time taken to convert the analog value to

digital value is dependent on this clock source. An external clock can be given at the

Clock IN pin. ADC 0804 also has an inbuilt clock which can be used in absence of

external clock. A suitable RC circuit is connected between the Clock IN and Clock R pins

to use the internal clock.

7

Page 8: Digital Thermometer Final Report.docx

PIN DESCRIPTION OF ADC0804:

Pin 1: It is a chip select pin and activates ADC, active low

Pin 2: It is an input pin; high to low pulse brings the data from internal registers to the

output pins after conversion

8

Page 9: Digital Thermometer Final Report.docx

Pin 3: It is an input pin; low to high pulse is given to start the conversion

Pin 4: It is a clock input pin, to give external clock

Pin 5: It is an output pin, goes low when conversion is complete

Pin 6: Analog non-inverting input

Pin 7: Analog inverting input, it’s normally ground

Pin 8: Ground (0V)

Pin 9: It is an input pin, sets the reference voltage for analog input

Pin 10: Ground (0V)

Pin 11 – Pin 18: It is an 8-bit digital output pins

Pin 19: Is used with clock IN pin when internal clock source is used

Pin 20: Supply voltage; 5V

LM35:-

LM35 is a temperature sensor with its output proportional to the temperature (in oC). The

operating temperature range is from -55°C to 150°C. The output voltage varies by 10mV

in response to every oC rise/fall in ambient temperature.

9

Page 10: Digital Thermometer Final Report.docx

LCD 16x2:-

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this

LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,

namely, Command and Data. The command register stores the command instructions

given to the LCD. A command is an instruction given to LCD to do a predefined task like

initializing it, clearing its screen, setting the cursor position, controlling display etc. The

data register stores the data to be displayed on the LCD.

10

Page 11: Digital Thermometer Final Report.docx

PIN DESCRIPTION OF ADC0804:-

Pin 1: Ground (0V) 

Pin 2: Supply voltage; 5V 

Pin 3: Contrast adjustment; through a variable resistor

Pin 4: Selects command register when low; and data register when high

Pin 5: Low to write to the register; High to read from the register

Pin 6: Sends data to data pins when a high to low pulse is given

Pin 7-14: 8-bit data pins

Pin 15: Backlight VCC (5V)

Pin 16: Backlight Ground (0V)

PIEZO BUZZER:-

The buzzer produces sound irrespective of the voltage variation applied to it. It consists

of piezo crystals between two conductors. When a potential is applied across these

crystals, they push on one conductor and pull on the other. This, push and pull action,

results in a sound wave.

11

Page 12: Digital Thermometer Final Report.docx

SOFTWARE TOOLS

Kiel micro vision 3.1 VPL universal programmer

KIEL MICRO VISION 3.1:-

It is a software which is used to write the program for micro controller.

This software is an integrated development environment (IDE), which

integrated a text editor to write programs, a compiler and it will convert

our source code to hex files too.

12

Page 13: Digital Thermometer Final Report.docx

APPLICATIONS:-

Digital thermometers are often used in clinical settings on patients.

Thermometers are used to give air, atmosphere and water temperature readings.

Thermometers used for home health care, cooking, and monitoring temperature

on home appliances such as the refrigerator or swimming pool.

Laboratory use includes monitoring experiments and chemical reactions as well as

maintaining optimal laboratory environment.

CONCLUSION:-

The circuit is based on LM35 analog temperature sensor ADC0804 and AT89C51

microcontroller. It consist of two sections. One is that which senses the temperature and

the other section converts the temperature value into suitable number in Celsius and

Fahrenheit scale which is done by ADC0804. If the temperature range is in between 97 to

99 then the alarm will generate. The LM35 sensor generates a 10 mv variation to its

output voltage for every degree Celsius change in temperature. The output of temperature

sensor is analog in nature so we need an analog to digital converter for converting the

analog input to its equivalent binary output. ADC0804 is an analog to digital converter IC

used in this project.

13

Page 14: Digital Thermometer Final Report.docx

APPENDIX:-

SOURCE CODE:-

#include<reg51.h>

#define port P3

#define adc_input P1

#define dataport P2

#define sec 100

sbit rs = port^0;

sbit rw = port^1;

sbit e = port^2;

sbit wr= port^3;

sbit rd= port^4;

sbit intr= port^5;

sbit buzzer= port^6;

int test_intermediate3=0,

test_final=0,test_intermediate1[10],test_intermediate2[3]={0,0,0};

void delay(unsigned int msec )

{

int i ,j ;

for(i=0;i<msec;i++)

for(j=0; j<1275; j++);

14

Page 15: Digital Thermometer Final Report.docx

}

void lcd_cmd(unsigned char item)

{

dataport = item;

rs= 0;

rw=0;

e=1;

delay(1);

e=0;

return;

}

void lcd_data(unsigned char item)

{

dataport = item;

rs= 1;

rw=0;

e=1;

delay(1);

e=0;

return;

15

Page 16: Digital Thermometer Final Report.docx

}

void lcd_data_string(unsigned char *str)

{

int i=0;

while(str[i]!='\0')

{

lcd_data(str[i]);

i++;

delay(10);

}

return;

}

void shape()

{

lcd_cmd(64);

lcd_data(2);

lcd_data(5);

lcd_data(2);

lcd_data(0);

lcd_data(0);

16

Page 17: Digital Thermometer Final Report.docx

lcd_data(0);

lcd_data(0);

lcd_data(0);

}

void convert()

{

int s;

lcd_cmd(0x81);

delay(2);

lcd_data_string("TEMP:");

test_final=(((9*test_intermediate3)/5)+32);

s=test_final/100;

test_final=test_final%100;

lcd_cmd(0x88);

if(s!=0)

lcd_data(s+48);

else

lcd_cmd(0x06);

s=test_final/10;

test_final=test_final%10;

17

Page 18: Digital Thermometer Final Report.docx

lcd_data(s+48);

lcd_data(test_final+48);

lcd_data(0);

lcd_data('F');

lcd_data(' ');

test_final=test_intermediate3;

lcd_cmd(0xc1); //Setting cursor to first position of second line

delay(2);

lcd_data_string("TEMP:");

s=test_final/100;

test_final=test_final%100;

lcd_cmd(0xc8);

if(s!=0)

lcd_data(s+48);

else

lcd_cmd(0x06);

s=test_final/10;

test_final=test_final%10;

lcd_data(s+48);

lcd_data(test_final+48);

18

Page 19: Digital Thermometer Final Report.docx

lcd_data(0);

lcd_data('c');

lcd_data(' ');

delay(2);

if(test_final>35)

{

buzzer=1;

}

}

void main()

{

int i,j;

buzzer=0;

adc_input=0xff;

lcd_cmd(0x38);

lcd_cmd(0x0c);

delay(2);

lcd_cmd(0x01);

delay(2);

while(1)

19

Page 20: Digital Thermometer Final Report.docx

{

for(j=0;j<3;j++)

{

for(i=0;i<10;i++)

{

delay(1);

rd=1;

wr=0;

delay(1);

wr=1;

while(intr==1);

rd=0;

lcd_cmd(0x88);

test_intermediate1[i]=adc_input/10;

delay(1);

intr=1;

}

for(i=0;i<10;i++)

test_intermediate2[j]=test_intermediate1[i]+test_intermediate2[j];

}

20

Page 21: Digital Thermometer Final Report.docx

test_intermediate2[0]=test_intermediate2[0]/3;

test_intermediate2[1]=test_intermediate2[1]/3;

test_intermediate2[2]=test_intermediate2[2]/3;

test_intermediate3=test_intermediate2[0]+test_intermediate2[1]+test_intermediate2[2];

shape();

convert();

}

}

21

Page 22: Digital Thermometer Final Report.docx

REFERENCE:-

The 8051 Microcontroller And Embedded Systems Using Assembly And C, Muhammad Ali Mazidi.

MacKenzie Scott. The 8051 Microcontroller, Prentice Hall.

Yeralan and Ahluwalia. Programming and Interfacing the 8051 Microcontroller.

22