temp meter

51
Microcontroller Based Temperature Meter Chapter 1 Introductio n 1.1 OVERVIEW Measuring the impact of environmental constraints is important for proper data analysis and control. Different types of data loggers and data acquisition systems are available in the market to perform this task well. Temperature measurement is today more common. The ambient temperature keeps varying during different times of the day and night at different places. Temperature measurement can be done for weather forecast or for automation in electronics devices and industries. Here we describe a temperature measurement device which uses microcontroller AT89C51, temperature sensor and other components. The temperature is measured at a user-defined interval. Each time the current temperature goes above the user-defined threshold value, the buzzer sounds The Project is used to indicate the temperature and it is also used as controller. The system will get the temperature from the IC and it will display the temperature over the seven segment display and this temperature was compared with the value stored by the user and if the Room temperature goes beyond the Preset temperature then an alarm is switched ON until the stop switch is pressed. The System is fully controlled by the microcontroller Compiled by:- Kuldeep kumar (L-C07561) Page 1 of 51 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

description

microcontroller based temperature meter

Transcript of temp meter

Page 1: temp meter

Microcontroller Based Temperature Meter

Chapter 1

Introduction

1.1 OVERVIEW

Measuring the impact of environmental constraints is important for proper data analysis and

control. Different types of data loggers and data acquisition systems are available in the market to

perform this task well. Temperature measurement is today more common. The ambient temperature

keeps varying during different times of the day and night at different places. Temperature

measurement can be done for weather forecast or for automation in electronics devices and

industries. Here we describe a temperature measurement device which uses microcontroller

AT89C51, temperature sensor and other components. The temperature is measured at a user-

defined interval. Each time the current temperature goes above the user-defined threshold value, the

buzzer sounds

The Project is used to indicate the temperature and it is also used as controller. The system will get

the temperature from the IC and it will display the temperature over the seven segment display and

this temperature was compared with the value stored by the user and if the Room temperature goes

beyond the Preset temperature then an alarm is switched ON until the stop switch is pressed. The

System is fully controlled by the microcontroller AT89C51. It is a popular 8 bit microcontroller.

The circuit consists of four switches, in which two buttons are used to increment and decrement the

temperature value and the next button is to start the Thermostat function and the other button is

used to stop the thermostat function. All the above functions are monitored and controlled by the 8

bit microcontroller AT89C51.

Compiled by:- Kuldeep kumar (L-C07561) Page 1 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 2: temp meter

Microcontroller Based Temperature Meter

1.2 LITERATURE SURVEY

Temperature is by far the most measured parameter. It impacts the physical, chemical and

biological world in numerous ways. Yet, a full appreciation of the complexities of temperature and

its measurement has been relatively slow to develop.

Intuitively, people have known about temperature for a long time: fire is hot and snow is cold.

Greater knowledge was gained as man attempted to work with metals through the bronze and iron

ages. Some of the technological processes required a degree of control over temperature, but to

control temperature you need to be able to measure what you are controlling. In industrial

environment where big machines are used generally there are no parameters which can check the

increase or decrease in the temperature of the surrounding temperature.the project is aimed at

providing a suitable,efficient and low cost method to perform this kind of operation.

The study of a microprocessor based controller for temperature measurement was taken into

consideration . The controller capacity were useful in autonomous systems that were monitoring in

remote areas. The controller is totally automatic and did not need any operator interference unless

needed. Another study had given a microprocessor based temperature controller aimed at just

showing the increase in temperature by means of leds .they didn’t modified the temperature as it is

done in our project so,that was not an efficient way to be implemented in a professional

environment. Temperature variations in environmental parameters caused by fog, rain, snow.,

distance from the location where the temperature sensor was lcoated, the system did not affect

proper measurement when the system tries to vary its parameters. The various books and links

which we have followed in our report are given below.

1) The 8051 Microcontroller and Embedded Systems,(2nd Edition)by Muhammad Ali Mazidi,

Janice Mazidi, and Rolin McKinlay All the basic fundamentals of programming of

microcontroller 8051 were studied from this book.

2) http://www.8051projects.net/i2c-twi-tutorial/8051-DS1307-example.php:- The interfacing

issues of LCD with Microcontroller 8051 were studied from the document present at this link.

3) www.digchip.com/datasheets/parts/datasheet/ADC-0804.php:-The interfacing issues of ADC

with Microcontroller 8051 were studied from the document present at this link.

Compiled by:- Kuldeep kumar (L-C07561) Page 2 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 3: temp meter

Microcontroller Based Temperature Meter

1.3 OBJECTIVE

We the students of Chandigarh College of Engg. & Tech. are going to be graduates in Electrical &

Electronics Communication Engg. & we should have the theoretical as well as practical knowledge

of various electronic components being used in various electronic circuits.

The main objective of making this project is to grab practical knowledge of electronic

components. We have done our major project (Microcontroller based temperature meter) in which

we used various electronic components like diodes, IC’s etc. We have also practiced soldering,

disordering, testing of components & fabrication of components on PCB.

Another Objective behind choosing the project is to understand the use of microcontroller in

various electronic circuits.

1.4 ORGANISATION OF REPORT

This report has been written in manner in which the development of the project has been made.

Certain modifications has been made in order to make the understanding simpler. This report has

been divided into various chapter. Brief description of these chapters is discussed below.

Chapter 1

It deals with the general introduction of the project. It gives as overview to the project by covering

the literature that had been surveyed to get all relevant information. This chapter ends with the

objective of this project which also covers some practical aspects of the projects.

Chapter 2

This chapter deals with the decription of various section of the project along with the program of

the microcontroller.

Chapter 3

This project explains the hardware model of the project. Coding of the microcontroller and

datasheets of various components used are also included in this report.

Compiled by:- Kuldeep kumar (L-C07561) Page 3 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 4: temp meter

Microcontroller Based Temperature Meter

CHAPTER 2

MODULAR DESCRIPTION

1. Power supply

2.Control Unit

3. Display Section

4. Temperature Sensing Lm35 Temperature Sensor

5. Buzzer & Switches

Fig2.1 Block diagram of temperature monitoring systems

Compiled by:- Kuldeep kumar (L-C07561) Page 4 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 5: temp meter

Microcontroller Based Temperature Meter

2.1.1 Power supply

Fig2.2 Block diagram of a power supply

Fig2.3 Requirements of a power supply

Above is the circuit of a basic unregulated dc power supply. A bridge rectifier D1 to D4 rectifies the

ac from the transformer secondary, which may also be a block rectifier such as WO4 or even four

individual diodes such as 1N4004 types. The principal advantage of a bridge rectifier is you do not

need a centre tap on the secondary of the transformer. A further but significant advantage is that the

ripple frequency at the output is twice the line frequency (i.e. 50 Hz or 60 Hz) and makes filtering

somewhat easier.

. 2.1.2 LM 7805:

Compiled by:- Kuldeep kumar (L-C07561) Page 5 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 6: temp meter

Microcontroller Based Temperature Meter

DESCRIPTION:

The LM7805 series of three terminal positive regulators are available in the TO-220/D-PAK

package and with several fixed output voltages, making them useful in a wide range of applications.

Each type employs internal current limiting, thermal shut down and safe operating area

protection,making it essentially indestructible. If adequate heat sinking is provided, they can deliver

over 1A output current. Although designed primarily as fixed voltage regulators, these devices

can be used with external components to obtain adjustable voltages and currents.

Fig2.4 Voltage regulator 7805

FEATURES:

• Output Current up to 1A

• Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V • Thermal Overload Protection

• Short Circuit Protection

• Output Transistor Safe Operating Area Protection

WORKING:

Voltage regulator limits the voltage that passes through it. Each regulator has a voltage

rating; For example, the 7805 IC (these regulators are often considered to be ICs) is a 5-volt voltage

regulator. What that means is that no matter how many volts you put into it, it will output only 5

volts. This means that you can connect a 9-volt battery, a 12-volt power supply, or virtually

anything else that's over 5 volts, and have the 7805 give you a nice supply of 5 volts out. There are

also 7812 (12-volt) and 7815 (15-volt) threepin regulators in common use.

The pin-out for a three pin voltage regulator is as follows:

1.Voltage-in

Compiled by:- Kuldeep kumar (L-C07561) Page 6 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 7: temp meter

Microcontroller Based Temperature Meter

2.Ground

3.Voltage out

For example, with a 9-volt battery, you'd connect the positive end to pin 1 and the negative (or

ground) end to pin 2. A 7805 would then give you +5 volts on pin 3.Voltage regulators are simple

and useful. There are only two important drawbacks to them: First, the input voltage must be higher

than the output voltage. For example, you cannot give a 7805 only 2 or 3 volts and expect it to give

you 5 volts in return. Generally, the input voltage must be at least 2 volts higher than the desired

output voltage, so a 7805 would require about 7 volts to work properly. The other problem: The

excess voltage is dissipated as heat. At low voltages (such as using a 9-volt battery with a 7805),

this is not a problem. At higher voltages, however, it becomes a very real problem and you must

have some way of controlling the temperature so you don't melt your regulator. This is why most

voltage regulators have a metal plate with a hole in it; That plate is intended for attaching a heat

sink to-Do not confuse three-pin voltage regulators with a device known as a TRIAC (short for

triode AC switch). It is easy to associate them with each other, since they look similar (both have

three pins) and they both regulate power. However, the 78XX types of regulators are used for

regulating DC current, while TRIACs are used for AC current.

2.2 Control Unit:

Microcontroller is used to control our hardware using programs which we

make according to our requirement. In our project the device connected with the Microcontroller

are :

a)Display unit

b) temperature monitoring unit

c)switches.

Output of IC is given to microcontroller and as per our requirement controller controls the

hardware according to temperature condition and side by side it displays the temperature

in decimal number system on LCD.

2.3 Display Section

Compiled by:- Kuldeep kumar (L-C07561) Page 7 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 8: temp meter

Microcontroller Based Temperature Meter

LCD is used for display purpose. It stands for Liquid crystal display. These are finding widespread

use in various applications. They are preferred because of ease of programming for characters and

numbers. Liquid crystal displays (LCD) is a alphanumeric display and widely used in recent years

as Compared to LEDs. This is due to the declining prices of LCD, the ability to display numbers,

characters and graphics, incorporation of a refreshing controller into the LCD, their by relieving the

CPU of the task of refreshing the LCD and also the ease of programming for characters and

graphics. We have used JHD162 LCDs .

2.4)Temperature Monitoring Unit

It consists of two components:

A) Temperature Sensor:

In our environment all the quantities like temperature, humidity; pressure, velocity etc

are available in analog form. To control and measure these quantities we must first

convert these quantities into electrical voltage. Sensor is nothing but a transducer which

converts any form of energy into electrical energy. In our case temperature sensor convert

temperature into corresponding voltage

b)Analog to digital convertor

Analog to digital converter are among the most widely used devices for data acquisition.

Digital computers use binary (discreet) values but in physical world everything is analog

(continuous).Temperature, pressure, humidity and velocity are few examples of physical

quantities that we deal with everyday. Although there are sensors for temperature,

velocity, pressure, light and many other natural quantities ,they produce an output that is

voltage(or current).Therefore, we need analog-to-digital converter to translate the analog

signals to digital numbers so that the microcontroller can read them.

2.5)Switches & Piezo buzzer

The circuit consists of four switches, in which two buttons are used to increment and

decrement the temperature value and the next button is to start the Thermostat function

and the other button is used to stop the thermostat function. Whenever the measured temperature

rises above the threshold value, the piezoelectric buzzer at sounds until the temperature becomes

lower than these threshold value

Compiled by:- Kuldeep kumar (L-C07561) Page 8 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 9: temp meter

Microcontroller Based Temperature Meter

Fig 1 Circuit of microcontroller based temperature meter

Circuit description:

Fig. 1 shows the circuit of the microcontroller based temperature meter.

It comprises a) microcontroller AT89S51,

b) an LCD display unit & a few discrete components

c) analog to digital converter ADC0804,

d) temperature sensor LM35,

e) voltage regulator 7805

.

Compiled by:- Kuldeep kumar (L-C07561) Page 9 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 10: temp meter

Microcontroller Based Temperature Meter

a)Microcontroller AT89S51

The given capture shows the pins and basic requirement of microcontroller to make it functional.

Detailed description of the contr1ler is given as follow:

AT89S51 is an ATMEL controller with the core of Intel MCS-51. It has same pin configuration as

give below. The AT89S51 is a low-power, high-performance CMOS 8-bit microcomputer with 8K

bytes of Downloadable Flash programmable and erasable read only memory and 2K bytes of

EEPROM. The device is manufactured using Atmel’s high density nonvolatile memory technology

and is compatible with the industry standard 80C51 instruction set and pin out. The on-chip

Downloadable Flash allows the program memory to be reprogrammed in-system through an SPI

serial interface or by a conventional nonvolatile memory programmer. By combining a versatile 8-

bit CPU with Downloadable Flash on a monolithic chip, the Atmel AT89S51 is a powerful

microcomputer which provides a highly flexible and cost effective solution to many embedded

control applications. The AT89S51provides the following standard features: 8K bytes of

Downloadable Flash, 2K bytes of EEPROM, 256 bytes of RAM, 32 I/O lines, programmable

watchdog timer, two Data Pointers, three 16-bit timer/counters, a six-vector two-level interrupt, a

full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the

Compiled by:- Kuldeep kumar (L-C07561) Page 10 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 11: temp meter

Microcontroller Based Temperature Meter

AT89S51 is designed with static logic for operation down to zero frequency and supports two

software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM,

timer/counters, serial port, and interrupt system to continue functioning. The Power down Mode

saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next

interrupt or hardware reset.

The Downloadable Flash can be changed a single byte at a time and is accessible through the SPI

serial interface. Holding RESET active forces the SPI bus into a serial programming interface and

allows the program memory to be written to or read from unless Lock Bit 2 has been activated.

Features

• Compatible with MCS-51™Products

• 8K bytes of In-System Reprogrammable Downloadable Flash Memory

- SPI Serial Interface for Program Downloading

- Endurance: 1,000 Write/Erase Cycles

• 4.0V to 5.5V Operating Range

• Fully Static Operation: 0 Hz to 33 MHz

• 256 x 8 bit Internal RAM

• 32 Programmable I/O Lines

• Three 16 bit Timer/Counters

• Eight Interrupt Sources

• Full Duplex UART Serial Channel

• Low Power Idle and Power Down Modes

• Interrupt Recovery From Power Down Mode

Advantages

Less power consumption

Low cost

Less space required& High speed

DescriptionThe AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K

bytes of In-System Programmable Flash memory. The device is manufactured using

Atmel’s high-density nonvolatile memory technology and is compatible with the industry-

standard 80C51 instruction set and pinout. The on-chip Flash allows the program

memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer.

Compiled by:- Kuldeep kumar (L-C07561) Page 11 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 12: temp meter

Microcontroller Based Temperature Meter

By combining a versatile 8-bit CPU with In-System Programmable Flash on

a monolithic chip, the Atmel AT89S51 is a powerful microcontroller which provides a

highly-flexible and cost-effective solution to many embedded control applications.

The AT89S51 provides the following standard features: 4K bytes of Flash, 128 bytes of

RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a fivevector

two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and

clock circuitry. In addition, the AT89S51 is designed with static logic for operation

down to zero frequency and supports two software selectable power saving modes.

The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and

interrupt system to continue functioning. The Power-down mode saves the RAM contents

but freezes the oscillator, disabling all other chip functions until the next external

interrupt or hardware reset.

Pin DescriptionVCC Supply voltage (all packages except 42-PDIP).

GND Ground (all packages except 42-PDIP; for 42-PDIP GND connects only the logic core and

the

embedded program memory).

VDD Supply voltage for the 42-PDIP which connects only the logic core and the embedded

program

memory.

PWRVDD Supply voltage for the 42-PDIP which connects only the I/O Pad Drivers. The

application

board MUST connect both VDD and PWRVDD to the board supply voltage.

PWRGND Ground for the 42-PDIP which connects only the I/O Pad Drivers. PWRGND and GND

are

weakly connected through the common silicon substrate, but not through any metal link. The

application board MUST connect both GND and PWRGND to the board ground.

Port 0 Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink

eight

TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance

inputs.

Port 0 can also be configured to be the multiplexed low-order address/data bus during

accesses to external program and data memory. In this mode, P0 has internal pull-ups.

Compiled by:- Kuldeep kumar (L-C07561) Page 12 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 13: temp meter

Microcontroller Based Temperature Meter

Port 0 also receives the code bytes during Flash programming and outputs the code bytes

during program verification. External pull-ups are required during program verification.

Port 1 Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can

sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being

pulled low will source current (IIL) because of the internal pull-ups.

Port 1 also receives the low-order address bytes during Flash programming and verification.

Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can

sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being

pulled low will source current (IIL) because of the internal pull-ups.

Port 2 emits the high-order address byte during fetches from external program memory and

during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this

application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to external

data memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special

Function Register.

Port 2 also receives the high-order address bits and some control signals during Flash programming

and verification.

Port Pin Alternate Functions

P1.5 MOSI (used for In-System Programming)

P1.6 MISO (used for In-System Programming)

P1.7 SCK (used for In-System Programming)

5

AT89S51

2487B–MICRO–12/03

Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can

sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being

pulled low will source current (IIL) because of the pull-ups.

Port 3 receives some control signals for Flash programming and verification.

Port 3 also serves the functions of various special features of the AT89S51, as shown in the

following table.

RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets

the device. This pin drives High for 98 oscillator periods after the Watchdog times out. The

Compiled by:- Kuldeep kumar (L-C07561) Page 13 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 14: temp meter

Microcontroller Based Temperature Meter

DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default

state of bit DISRTO, the RESET HIGH out feature is enabled.

ALE/PROG Address Latch Enable (ALE) is an output pulse for latching the low byte of the

address during

accesses to external memory. This pin is also the program pulse input (PROG) during Flash

programming.

In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may

be used for external timing or clocking purposes. Note, however, that one ALE pulse is

skipped during each access to external data memory.

If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set,

ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled

high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution

mode.

PSEN Program Store Enable (PSEN) is the read strobe to external program memory.

When the AT89S51 is executing code from external program memory, PSEN is activated

twice each machine cycle, except that two PSEN activations are skipped during each access

to external data memory.

EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to

fetch

code from external program memory locations starting at 0000H up to FFFFH. Note, however,

that if lock bit 1 is programmed, EA will be internally latched on reset.

EA should be strapped to VCC for internal program executions.

This pin also receives the 12-volt programming enable voltage (VPP) during Flash

programming.

XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2 Output from the inverting oscillator amplifier

Port Pin Alternate Functions

P3.0 RXD (serial input port)

P3.1 TXD (serial output port)

P3.2 INT0 (external interrupt 0)

P3.3 INT1 (external interrupt 1)

P3.4 T0 (timer 0 external input)

P3.5 T1 (timer 1 external input)

P3.6 WR (external data memory write strobe)

Compiled by:- Kuldeep kumar (L-C07561) Page 14 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 15: temp meter

Microcontroller Based Temperature Meter

P3.7 RD (external data memory read strobe)

6 AT89S51

2487B–MICRO–12/03

SpecialFunctionRegisters

A map of the on-chip memory area called the Special Function Register (SFR) space is shown

in Table 1.

Note that not all of the addresses are occupied, and unoccupied addresses may not be implemented

on the chip. Read accesses to these addresses will in general return random data,

and write accesses will have an indeterminate effect

Compiled by:- Kuldeep kumar (L-C07561) Page 15 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 16: temp meter

Microcontroller Based Temperature Meter

LCD DISPLAY UNIT

LCD Display

Liquid crystal displays (LCD) is a alphanumeric display and widely used in recent years as

compared to LEDs. This is due to the declining prices of LCD, the ability to display numbers,

characters and graphics, incorporation of a refreshing controller into the LCD, their by relieving the

CPU of the task of refreshing the LCD and also the ease of programming for characters and

graphics. We have used JHD162A advanced version of HD44780 based LCDs .

LCD pin description

The LCD discuss in this section has the most common connector used for the Hitatchi JHD162A

LCD is 16 pins in a row and modes of operation and how to program and interface with

microcontroller is describes in this section

Compiled by:- Kuldeep kumar (L-C07561) Page 16 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 17: temp meter

Microcontroller Based Temperature Meter

VCC, VSS, VEE

The voltage VCC and VSS provided by +5V and ground respectively while VEE is used for controlling

LCD contrast. Variable voltage between Ground and Vcc is used to specify the contrast (or

"darkness") of the characters on the LCD screen.

RS (register select)

There are two important registers inside the LCD. The RS pin is used for their selection as follows.

If RS=0, the instruction command code register is selected, then allowing to user to send a

command such as clear display, cursor at home etc.. If RS=1, the data register is selected, allowing

the user to send data to be displayed on the LCD.

R/W (read/write)

The R/W (read/write) input allowing the user to write information from it. R/W=1, when it read and

R/W=0, when it writing.

EN (enable)

The enable pin is used by the LCD to latch information presented to its data pins. When data is

supplied to data pins, a high power, a high-to-low pulse must be applied to this pin in order to for

the LCD to latch in the data presented at the data pins.

D0-D7 (data lines)

The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the

LCD’s internal registers. To displays the letters and numbers, we send ASCII codes for the letters

A-Z, a-z, and numbers 0-9 to these pins while making RS =1. There are also command codes that

can be sent to clear the display or force the cursor to the home position or blink the cursor.

We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the information.

The busy flag is D7 and can be read when R/W =1 and RS =0, as follows: if R/W =1 and RS =0,

when D7 =1(busy flag =1), the LCD is busy taking care of internal operations and will not accept

any information. When D7 =0, the LCD is ready to receive new information.

Interfacing of ADC0804 with LM35 temperature sensor:

We have interfaced LCD and ADC0804 for this section. Interfacing of LCD has already been

explained above. For sensing temperature we have used LM35.

Compiled by:- Kuldeep kumar (L-C07561) Page 17 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 18: temp meter

Microcontroller Based Temperature Meter

This section includes two major component – temperature sensor and

analog to digital converter(ADC). We have used LM35 as temperature sensor and a 8 bit ADC

0804 for analog to digital conversion. The temperature sensor converts the temperature into

corresponding analog voltage .Every analog signal must be converted into digital form before

performing any control action with microcontroller.The analog voltage which is corresponding to

temperature is converted in digital form using ADC and after that the digital data is given to the

port 2 of microcontroller. The start of conversion pin of ADC is connected with the P1_2 pin of

microcontroller and EOC pin of ADC is connected with the P1_3.The LM35 series sensors are

precision integrated circuit temperature sensors whose voltage output is linearly proportional to the

Celsius temperature. LM35 needs no external calibration since it is internally calibrated.

IC LM35 (IC3) is a three-terminal, precision temperature sensor whose output voltage is

linearly proportional to the Celsius temperature with 110.0 mV/’C scale factor. It thus has an

advantage over linear temperature sensors calibrated in o Kelvin, as the user is not required to

subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35

does not require any external calibration or trimming to provide typical accuracies. It is rated for

full -55'C to +50’C range and operates off 4V-30V input. It gives 0V output for OoC temperature.

The analogue output (Vout) at pin 2 of LM35 is fed to Vin (+) pin 6 of analogue-to-digital

converter ADCO804 whose Vin (-) pin7 is connected to ground. Pin L of LM35 is connected to 5V

supply and pin 3 is grounded.

ADC0804 (IC2) is a CMOS, 8-bit, single-channel analogue-to-digital converter. It features

conversion time of less than 100 ms, differential analogue input voltage, TTl-compatible inputs and

outputs, on-chip clock generator, analogue voltage input range from 0V to 5V, and no zero

adjustment. The conversion time depends on resistor R3 and capacitor C6. The conversion rate in

free-running mode is 640 kHz. Digital and

Analogue ground should be separated in ADC0804 to avoid any interference in the circuit.

Compiled by:- Kuldeep kumar (L-C07561) Page 18 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 19: temp meter

Microcontroller Based Temperature Meter

-chapter 3

HARDWARE IMPLEMENTATION AND TESTING

Microcontroller AT89S51 is a low-power, high-performance CMOS 8-bit microcomputer

with 4 kB of Flash programmable and erasable read-only memory (PEROM). An 11.0592MH2

crystal is connected to pins 18 and L9 to provide basic clock to the microcontroller. Capacitors

C4 and C5 connected in parallel to the crystal maintain the resonance. Switch 51 is used to

manually reset the microcontroller, while the power-on reset signal for the microcontroller is

derived from the combination of capacitor C3 and resistor R2.

IC LM35 (IC3) is a three-terminal, precision temperature sensor not require any external

calibration or trimming to provide typical accuracies. It is rated for full -55'C to L50oC range and

operates

off 4V-30V input. It gives 0V output for OoC temperature. The analogue output (Vout) at pin 2 of

LM35 is fed to Vcc (+) pin 6 of analogue-to-digital converter ACDO804, whose Vin (-) pin7

is connected to ground. Pin 1 of LM35 is connected to 5V supply and pin 3 is grounded.

Interfacing The Lm35 To At89s52

Signal conditioning is widely used in the world of data acquisition. The most common transducer

produces an output in the form of voltage, current, charge, capacitance and resistance. However, we

need to convert these signals to voltage in order to send input to analog to digital converter. This

conversion is commonly called signal conditioning. Signal conditioning can be a current to voltage

conversion or a signal amplification. Now in case of connecting an LM35 to an ADC0804, since the

ADC0804 has 8 bit resolution with a maximum of 256 steps and LM35 produces 10mV for every

degree of temperature change , we can condition Vin of the ADC0804 to produce Vout of 2560mV

(2.56V) for full scale output. Therefore, in order to produce full scale Vout of 2.56V for the

ADC0804 ,we need to set Vref= 2.56V. This makes Vout of the ADC0804 directly to the

temperature as monitored by LM35.

The resolution of 8-bit ADC0804 is 19.53 mV, which doesn't match with the scale factor of LM35

and therefore can cause error. To avoid this error, the full-scale range of ADC0804 is made 0-2.56V

by adjusting the voltage at pin 9 (Vref/2) to 1.28V through l-kilo-ohm preset VR2. In ADC0804,

Compiled by:- Kuldeep kumar (L-C07561) Page 19 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 20: temp meter

Microcontroller Based Temperature Meter

the input analogue voltage is divided by its step size to give digital output. For each 10mV rise and

fall of the analogue input at Vin (+), digital out puts at DBO throughDB7 increase and decreases,

respectively he maximum input voltage that can be converted by the ADC is 2.55V (10mV x

2ll),giving full-scale output of FF hex value in this system. The 8-bit digital output o f

ADC0804 (DBO through DB7) is connected to 8-bit port p0 of the microcontroller. Signals RO,

WR and INTR of the ADC are connected to p27,pl5 and P2.5 of the microcontroller. These

signals of the ADC act as handshaking signals with microcontroller IC1. RD and l, VR are the input

pins of the ADC, while INITR is the output pin. Through signal, the microcontroller

gets to know when the con version from analogue into digital is completed by the ADC.

The microcontroller makes WR pin’ low' and RD pin ,high, to start the conversion. pin INIR goes

high for the end of conversion. A transition from high to low on INTR indicates

end of conversion. Then microcontroller makes RD low, WR high to read 8 bit data at DBO

through DB7 through microcontroller port P0. Through its firmware, the microcontroller multiplies

the digital input at port 0 with the step size value of ADC0804 and then divides with the

Temperature/volt scale factor of LM35 to give the measured and calibrated oC temperature.

The measured temperature is instantaneously displayed on the LCD. Port PL of the microcontroller

is connected to data port pins 7 through 14 of the LCD module. The handshake signals of the LCD

(RS, R/W and Enable) are connected to P3.2, P3.3 and P3.4 of the microcontroller

Switches S2, S3 and S4 connected to pins P2.2,P2.land p2.0 are treated as'Up,'

'down'and ,enter,buttons, respectively,.by the temperature setting of the microcontroller.

Measuring interval and threshold temperature values are to be entered by the user using switches

52, 53 and 34 whenever the microcontroller starts. The range of measuring interval is 1 second to

99 seconds. According to this measuring interval, the microcontroller measures the temperature

value in its flash memory. Whenever the measured temperature rises above the threshold value, the

piezoelectric buzzer at pin P2.4 sounds until the temperature becomes lower than these threshold

value.

Time between measurements of two temperature samples is treated as waiting time measuring

interval. So during waiting time, LED2 connected at pin P23 of the microcontroller glows. It is

turned off during measurement. Resistor R4 acts as the current limiter for LED2. Fig. 2 shows the

power supply circuit. The 230V S}Hz AC mains is stepped down by transformer X1 to deliver

secondary output of 9V, 500mA. The transformer output is rectified by a full-wave rectifier

comprising diodes D1 through D4, filtered by capacitor C1 and regulated by IC Zg05 [Ca) to

Compiled by:- Kuldeep kumar (L-C07561) Page 20 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 21: temp meter

Microcontroller Based Temperature Meter

provide +5V DC output. Capacitor C2 provides further filtering. LED1 indicates DC power

and R1 acts as the current limiter.

Software

The software it works as per the flow-chart shown in Fig .Code generated is burnt into the

microcontroller using a suitable Programmer. The ranges for measuring time interval (01 to 99

seconds) and threshold temperature value (20 degree C to 49 degree C) are set by the software. The

values of the measured temperature and the number of samples taken until power-,on, are

displayed on the LCD screen as shown in Fig The number of samples is updated according to the

measuring interval.

Each port of the microcontroller is made input through software by putting high on the respective

pin or port. By default, all the ports act as outputs. Instead of using timer, nested loops are used to

provide delays at various locations of the software. The values for the loops are calculated

Compiled by:- Kuldeep kumar (L-C07561) Page 21 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 22: temp meter

Microcontroller Based Temperature Meter

according to the crystal frequency and the machine cycles taken by the used instructions.

Functioning of all the keys (up, down and enter) is also handled by the software. pooling,

identification of keys, and limits forup and down are provided by the software.

ASSEMBLY LANGUAGE PROGRAM: Software’s used are:

1. Keil software for programming

2. Express PCB for lay out design

3. Express SCH for schematic design

What's New in µVision3?

µVision3 adds many new features to the Editor like Text Templates, Quick Function Navigation,

Syntax Coloring with brace highlighting Configuration Wizard for dialog based startup and

debugger setup. µVision3 is fully compatible to µVision2 and can be used in parallel with

µVision2.

What is µVision3?

µVision3 is an IDE (Integrated Development Environment) that helps you write, compile, and

debug embedded programs. It encapsulates the following components:

A project manager. A make facility. Tool configuration. Editor.

A powerful debugger.

help you get started, several example programs (located in the \C51\Examples, \C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided.

HELLO is a simple program that prints the string "Hello World" using the Serial Interface.

MEASURE is a data acquisition system for analog and digital systems.

TRAFFIC is a traffic light controller with the RTX Tiny operating system.

SIEVE is the SIEVE Benchmark. DHRY is the Dhrystone Benchmark.

WHET is the Single-Precision Whetstone Benchmark.

Additional example programs not listed here are provided for each device architecture.

Building an Application in µVision2

Compiled by:- Kuldeep kumar (L-C07561) Page 22 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 23: temp meter

Microcontroller Based Temperature Meter

To build (compile, assemble, and link) an application in µVision2, you must:

Select Project for example,166\EXAMPLES\HELLO\HELLO.UV2).

Select Project - Rebuild all target files or Build target. µVision2 compiles, assembles, and links

the files in your project.

Creating Your Own Application in µVision2

To create a new project in µVision2, you must: 1. Select Project - New Project.

2. Select a directory and enter the name of the project file.

3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device

Database.

4. Create source files to add to the project.

5.Select Project - Targets, Groups, Files. Add/Files, select Source Group1, and add the source

files to the project.

6. Select Project - Options and set the tool options. Note when you select the target device from the

Device Database™ all special options are set automatically. You typically only need to configure

the memory map of your target hardware. Default memory model settings are optimal for most

applications.

7. Select Project - Rebuild all target files or Build target.

Debugging an Application in µVision2

To debug an application created using µVision2, you must:

1. Select Debug - Start/Stop Debug Session.

2. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the

Output Window to execute to the main C function.

3. Open the Serial Window using the Serial #1 button on the toolbar. Debug your program using

standard options like Step, Go, Break, and so on.

Compiled by:- Kuldeep kumar (L-C07561) Page 23 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 24: temp meter

Microcontroller Based Temperature Meter

Starting µVision2 and creating a Project

µVision2 is a standard Windows application and started by clicking on the program icon. To

create a new project file select from the µVision2 menu Project - New Project…. This opens a

standard Windows dialog that asks you

We suggest that you use a separate folder for each project. You can simply use the icon

Create New Folder in this dialog to get a new empty folder. Then select this folder and enter the file

name for the new project, i.e. Project1.

µVision2 creates a new project file with the name PROeECT1.UV2 which contains a default target

and file group name. You can see these names in the Project

Construction and testing

An actual-size, single-side PCB for the microcontroller-based temperature meter is shown in Fig. 3

and its component layout in Fig. 4. Wire the circuit on the PCB. Use bases for ICs AT89S51 and

ADC0804. program the AT89S51 with suitable programmer and put into the IC base after soldering

all the components and checking +5V at each Vcc point of the circuit. Also check continuity

between respective connections using a multimeter.

For proper measurement, adjust preset VR2 to give 1.28V at pin 9of the ADC. Initially, used preset

VR1, set the contrast level for proper display on the LCD.

single-side PCB for the microcontroller-based temperature meter

Compiled by:- Kuldeep kumar (L-C07561) Page 24 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 25: temp meter

Microcontroller Based Temperature Meter

Component layout for the pCB

The functional diagram of the ADC0804 series of A/D converters operates on the successive

approximation principle. Analog switches are closed sequentially by successive-approximation

logic until the analog differential input voltage [VlN (+) - VlN (-)] matches a voltage derived from a

tapped resistor string across the reference voltage. The most significant bit is tested first and after 8

comparisons (64 clock cycles), an 8-bit binary code (1111 1111 = full scale) is transferred to an

output latch. The normal operation proceeds as follows. On the high-to-low transition of the

input, the internal SAR latches and the shift-register stages are reset, and the output will be

set high. As long as the input and input remain low, the A/D will remain in a reset state.

Conversion will start from 1 to 8 clock periods after at least one of these inputs makes a low to high

transition. After the requisite number of clock pulses to complete the conversion, the INTR pin will

make a high-to-low transition. This can be used to interrupt a processor, or otherwise signal the

availability of a new conversion. A operation (with low) will clear the line high

again.The device may be operated in the free-running mode by connecting to the input

with = 0. To ensure start-up under all possible conditions, an external pulse is required

during the first power-up cycle. A conversion-in-process can be interrupted by issuing a second

start command. When interfacing is being done then gets lowered then only it allows the

controller to read the data, otherwise controller can not read the data. is always grounded.

Compiled by:- Kuldeep kumar (L-C07561) Page 25 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 26: temp meter

Microcontroller Based Temperature Meter

Applications

Temperature sensor:

What are sensors?

Sensors are devices that are used to measure physical variables like temperature, pH, velocity,

rotational rate, flow rate, pressure and many others.  Today, most sensors do not indicate a reading

on an analog scale (like a thermometer), but, rather, they produce a voltage or a digital signal that is

indicative of the physical variable they measure.  Those signals are often imported into computer

programs, stored in files, plotted on computers and analyzed to death.Sensors come in many kinds

and shapes to measure all kinds of physical variables. Temperature sensors are often sensing

devices embedded within some sort of insulation. The insulation may often be for electrical

purposes - to isolate the sensor electrically.  However, good electrical insulation is often also good

thermal insulation, and the presence of that insulation causes the sensor to respond tardily when the

sensor heats up. There are a few special situations that are examined : the case where the

temperature of the surroundings changes suddenly and has to come to equilibrium at the new

temperature. The case where the sensor is taken from a temperature then put into new surroundings

and allowed to cool (or rise?) to the temperature of the surroundings

 Temperature Measurement:How can I measure temperature? Temperature can be measured via a diverse array of sensors. All

of them infer temperature by sensing some change in a physical characteristic. Six types with which

the engineer is likely to come into contact are: thermocouples, resistive temperature devices (RTDs

and thermistors), infrared radiators, bimetallic devices, liquid expansion devices, and change-of-

state devices.

Semiconductor temperature sensors are available from a number of manufacturers. There are no

generic types as with thermocouple and RTDs, although a number of devices are made by more

than one manufacturer. The AD590 and the LM35 have traditionally been the most popular devices,

but over the last few years better alternatives have become available

These sensors share a number of characteristics - linear outputs, relatively small size, limited

temperature range (-40 to +120°C typical), low cost, good accuracy if calibrated but also poor

interchangeability. Often the semiconductor temperature sensors are not well designed thermally,

with the semiconductor chip not always in good thermal contact with an outside surface. Some

Compiled by:- Kuldeep kumar (L-C07561) Page 26 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 27: temp meter

Microcontroller Based Temperature Meter

devices are inclined to oscillate unless precautions are taken. Provided the limitations of the

semiconductor temperature sensors are understood, they can be used effectively in many

applications.

The most popular semiconductor temperature sensors are based on the fundamental temperature and

current characteristics of the transistor. If two identical transistors are operated at different but

constant collector current densities, then the difference in their base-emitter voltages is proportional

to the absolute temperature of the transistors. This voltage difference is then converted to a single

ended voltage or a current. An offset may be applied to convert the signal from absolute

temperature.

Which is the most appropriate semiconductor sensor??

A difficult question to answer, but the following selection process may help:

Decide on the accuracy required

Decide on the temperature range

Decide on a budget

Define the measuring instruments input capabilities

Select any sensor that satisfies all of the above (you will be lucky if one does), otherwise:

If accuracy is deficient, you will need to calibrate the sensor. Will a single point offset correction be

sufficient with any sensor? Select that sensor. Otherwise:

Will a two point calibration provide adequate accuracy by correcting for offset and slope? Select

that sensor.

Once you have decided that calibration will be required, the selection becomes easier. It makes little

difference if the initial un-calibrated error is large or small. The nature of the deviation from the

ideal response curve becomes the most important factor. If this deviation is a simple linear function,

a two-point calibration will yield excellent results. If the deviation is more complex, a multipoint

calibration will be required, followed by the fitting of a polynomial or a series of linear segments.

For our project we have used a IC LM35 (IC3) is a three-terminal,precision temperature sensor

whoseoutput voltage is linearly proportional to the Celsius temperature It thus has an advantage

over linear temperature sensors calibrated in oKelvin, as the user is not required to subtract alarge

constant voltage from its output to obtain convenient Centigrade scaling

Compiled by:- Kuldeep kumar (L-C07561) Page 27 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 28: temp meter

Microcontroller Based Temperature Meter

Liquid Crystal Displays (LCD)

These components are “specialized” for being used with the microcontrollers, which means that

they cannot be activated by standard IC circuits. They are used for writing different messages on a

miniature LCD.

Amodel described here is for its low price and great possibilities most frequently used in practice. It

is based on the HD44780 microcontroller (Hitachi) and can display messages in two lines with 16

characters each . It displays all letters of alphabet, greek letters, punctuation marks, mathematical

symbols etc. In addition, it is possible to display symbols that user makes up on its own. Automatic

shifting message on display (shift left and right), appearance of the pointer, backlight etc. are

considered as useful characteristics.

Pins Functions

There are pins along one side of the small printed board used for connection to the microcontroller.

There are total of 14 pins marked with numbers (16 in case the background light is built in). Their

function is described in the table bellow:

Compiled by:- Kuldeep kumar (L-C07561) Page 28 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 29: temp meter

Microcontroller Based Temperature Meter

FunctionPin

NumberName

Logic State

Description

Ground 1 Vss - 0V

Power supply 2 Vdd - +5V

Contrast 3 Vee - 0 - Vdd

Control of

operating

4 RS0

1

D0 – D7 are interpreted as

commands

D0 – D7 are interpreted as data

5 R/W0

1

Write data (from controller to LCD)

Read data (from LCD to controller)

6 E

0

1

From 1 to

0

Access to LCD disabled

Normal operating

Data/commands are transferred to

LCD

LCD SCREEN

LCD screen consists of two lines with 16 characters each. Each character consists of 5x8 or 5x11

dot matrix. This book covers 5x8 character display because it is commonly used.

Contrast on display depends on the power supply voltage and whether messages are displayed in

one or two lines. For that reason, variable voltage 0-Vdd is applied on pin marked as Vee. Trimmer

potentiometer is usually used for that purpose. Some versions of displays have built in backlight

Compiled by:- Kuldeep kumar (L-C07561) Page 29 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 30: temp meter

Microcontroller Based Temperature Meter

(blue or green diodes). When used during operating, a resistor for current limitation should be used

(like with any LE diode).

If there are no characters on display or all of them are dimmed upon the display is on, the first thing that should be done is to check the potentiometer for contrast regulation. Is it properly adjusted? Same applies in case the operation mode is changed (writing in one or two lines).

.

Compiled by:- Kuldeep kumar (L-C07561) Page 30 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 31: temp meter

Microcontroller Based Temperature Meter

CONCLUSION

The minor project which is used to test the technical skills of the student is the only way to get the

technical knowledge. While working on this project we are in a position to conclude some of the

points.

This project has made us familiar with the components which we have studied in our text books

only. Interfacing of ADC and LCD to controller which we have studied in our books is more

familiar to us making this project which is now used in almost every project. In this project we

learnt very basics of electronics including soldering process and PCB designing. We also learnt a

lot the technique of assembling the project. A lot of components are tested by us which make us

more familiar with these components.

The troubleshooting of a project is the most difficult part in the making of a project because you

have to check your each and every connection of your circuit as well as your programming. There a

lot of doubts which are understood by us during the making of this project which will help us in

future. So overall this project has opened up our thinking to the engineering level.

At last, we would like to conclude that this project has increased our interest in electronics and we

have come to know the practical implementation of electronics.

RESULT

In the temperature monitoring system we have used four blocks those are temperature

sensor,ADC0804,AT89s52microcontroller,LCD.In this system the first block temperature sensor

senses the temperature in the atmosphere in analogue form and then sends this analogue signal to

ADC to convert into digital signal. This digital signal is fed to microcontroller through data lines.

By using the microcontroller process the data and send it to LCD in the form of ASCII code.

Finally LCD displays the external temperature in the atmosphere.

Compiled by:- Kuldeep kumar (L-C07561) Page 31 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 32: temp meter

Microcontroller Based Temperature Meter

References

1. Muhammad Ali Mazidi, Janice Mazidi, and Rolin McKinlay “The 8051 Microcontroller and

Embedded Systems”, 2nd Edition. Nov. 1992. PP.102-125

2. Scott Machenzie,Member IEEE “The 8051 Microcontroller” 3rd edition (July 29, 1998)

3. B L Theraja, Member IEEE “Electrical Technology” 3rd edition May 2008

4. Golding and Widdis, Electrical measurements and Measuring instruments.

Websites:

1. www.futurlec.com

2. www.wikipedia.org/ADC 0804/Analog-to-digita.htm

3. http://www.electronicsforu.com/efyhome/cover/home.htm

4. http://en.wikipedia.org/wiki/Diodegbridgefcolumn-one

5. http://www.allaboutcircuits.com/volg6/chptg5/index.html

6. http://www.beyondlogic.org/serial/serial.htmf1

7. http://geocities.com/SiliconValley/2072/electron.htm

8. http://www.national.com/opf/LM/LM7805C.htmlfDatasheet

Compiled by:- Kuldeep kumar (L-C07561) Page 32 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)

Page 33: temp meter

Microcontroller Based Temperature Meter

Compiled by:- Kuldeep kumar (L-C07561) Page 33 of 33 Ankaj Mohindroo (C07504) Arun Bhola (L-c07565)