digital temperature using atmel 8051 microcontroller

23
1 Digital thermometer USING ATMEL 8051 MICROCONTROLLER Abstract Present generation is the generation of electronic gadgets. The development in the field of microcontrollers and microprocessors has made a significant leap in the past few years. There is a huge competition and development in the embedded systems design and implementation for various purposes. To be a part of this revolution we should have a firm foundation of microcontrollers and embedded systems. Our project is an attempt to understanding and implementation of microcontrollers in the embedded systems. In this project, an attempt has been made in the understanding, working and implementation of microcontrollers.

Upload: mani-sekar

Post on 25-Oct-2015

279 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Digital Temperature Using Atmel 8051 Microcontroller

1

Digital thermometer

USING ATMEL 8051 MICROCONTROLLER

Abstract

Present generation is the generation of electronic gadgets. The development in the field of

microcontrollers and microprocessors has made a significant leap in the past few years. There is a

huge competition and development in the embedded systems design and implementation for various

purposes. To be a part of this revolution we should have a firm foundation of microcontrollers and

embedded systems. Our project is an attempt to understanding and implementation of microcontrollers

in the embedded systems.

In this project, an attempt has been made in the understanding, working and implementation of

microcontrollers.

Page 2: Digital Temperature Using Atmel 8051 Microcontroller

2

CHAPTER 1

INTRODUCTION

Aim of our project is to learn about interfacing of temperature sensor with ATMEL microcontroller

by means of ADC, to display the temperature on a 16x2 LCD and to rotate a DC motor at two

different speeds at various temperatures.

In our project, we have given a temperature input to a temperature sensor which changes it to

a corresponding a analog voltage which will be given to an ADC. To convert the analog data into

digital waveform, based on a reference voltage which is fed to a microcontroller the

temperature will be displayed on a 16x2 LCD. We control a DC motor in such a way that it should

run at two different speeds based on this temperature.

Page 3: Digital Temperature Using Atmel 8051 Microcontroller

3

CHAPTER 2

STUDY OF ESSENTIAL COMPONENTS

2.1 AT89C51 Microcontroller:

Page 4: Digital Temperature Using Atmel 8051 Microcontroller

4

ADC0804:

Page 5: Digital Temperature Using Atmel 8051 Microcontroller

5

Timing diagram :

LM35:

Page 6: Digital Temperature Using Atmel 8051 Microcontroller

6

Why LM35 ?

The LM35 thus has an advantage over linear temperature sensors calibrated in ° 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

of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature range. Low cost is

assured by trimming and calibration at the wafer level. The LM35’s low output impedance, linear

output, and precise inherent calibration make interfacing to readout or control circuitry especially easy.

It can be used with single power supplies, or with plus and minus supplies. As it draws only 60 μA

from its supply, it has very low self-heating, less than 0.1°C in still air. The LM35 is rated to operate

over a −55° to +150°C temperature range, while the LM35C is rated for a −40° to +110°C range

2.6 LCD DISPLAY:

A liquid crystal display (LCD) is a thin, flat electronic visual display that uses the light modulating

properties of liquid crystals (LCs). LCs do not emit light directly. LCDs therefore need a light source

and are classified as "passive" displays.

The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other

which are compatible with HD44580.

In the project LCD has been used for display of static text files.

Fig4. Character LCD type HD44780 Pin diagram

Page 7: Digital Temperature Using Atmel 8051 Microcontroller

7

Table2. Character LCD pins with 1 Controller

Pin No. Name Description

Pin No.1 VSS Power supply(GND)

Pin No.2 VCC Power supply(+5V)

Pin No.3 VEE Contrast adjustment

Pin No.4 RS 0-instruction input

1-Data input

Pin No.5 R/W 0 = Write to LCD module

1 = Read from LCD module

Pin No.6 EN Enable signal

Pin No. 7 D0 Data bus line 0 (LSB)

Pin No.8 D1 Data bus line 1

Pin No.9 D2 Data bus line 2

Pin No.10 D3 Data bus line 3

Pin No.11 D4 Data bus line 4

Pin No.12 D5 Data bus line 5

Pin No.13 D6 Data bus line 6

Pin No.14 D7 Data bus line 7 (MSB)

Table3. Character LCD pins with 2 Controllers

Pin No. Name Description

Pin No.1 D7 Data bus line 7(MSB)

Pin No.2 D6 Data bus line 6

Pin No.3 D5 Data bus line 5

Pin No.4 D4 Data bus line 4

Pin No.5 D3 Data bus line 3

Pin No.6 D2 Data bus line 2

Pin No.7 D1 Data bus line 1

Pin No.8 D0 Data bus line 0 (LSB)

Pin No.9 EN1 Enable signal for row 0 and

1 (1stcontroller)

Pin No.10 R/W 0 = Write to LCD module

1 = Read from LCD module

Pin No.11 RS 0 = Instruction input

1 = Data input

Page 8: Digital Temperature Using Atmel 8051 Microcontroller

8

Pin No.12 VEE Contrast adjust

Pin No.13 VSS Power supply (GND)

Pin No.14 VCC Power supply (+5V)

Pin No.15 EN2 Enable signal for row 2 and

3 (2nd

controller)

Pin No.16 NC Not Connected

2.7 VOLTAGE REGULATOR:

A voltage regulator is an electrical regulator designed to automatically maintain a constant voltage

level. In the project we have used L7805 which coverts 9V to 5V.

Fig5. 78L05 pin diagram

Table4. Parameters of 78L05

78L05

Vout(min)(V) 4.936

Vout(max)(V) 5.064

Vin(min)(V) 5.9

Vin(max)(V) 20

Page 9: Digital Temperature Using Atmel 8051 Microcontroller

9

CHAPTER 3

SOFTWARES USED

3.1PROTEUS:

Proteus is a software for microcontroller simulation, schematic capture and

printed circuit board design. It is developed by Labcenter electronics.

The proteus design suite includes:

ISIS: A networking tool to simulate programming ICs like PIC, Atmel etc.,

The model was successfully simulated. This simulated model was then used for assembling the

hardware.

3.2COMPILERS

Programming can be done by any ATMEL program compilers.

ATMEL is used for the project. This compiler has in built libraries for development of code for the

project.

Page 10: Digital Temperature Using Atmel 8051 Microcontroller

10

CHAPTER 4

CIRCUIT DIAGRAM AND ANALYSIS

4.1. TEMPERATURE SENSOR:

Transducers convert physical data such as temperature, light intensity, flow, and

speed to electrical signals. Depending on the transducer ,the output produced is in the form of voltage,

current, resistance, or capacitance. For example, temperature is converted to electrical signals using a

transducer called a thermistor. A thermistor responds to a temperature change by changing resistance,

but its response is non linear. The complexity associated with writing software for such non linear

devices is very high. So we use a linear temperature sensor to respond for a temperature change.

So here in our circuit, we use the sensor LM35. The LM35 series sensors are

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

Celsius (centigrade) temperature. The LM35 requires no external calibration since it is internally

calibrated. It outputs 10mv for each degree of centigrade temperature.

We gives a temperature input to this sensor. It converts this temperature change to analog

voltage output which will be given to an ADC.

4.2. ANALOG TO DIGITAL CONVERTER:

Page 11: Digital Temperature Using Atmel 8051 Microcontroller

11

The ADC used is ADC0804. The ADC0804 IC is an 8 bit parallel ADC. It works with

+5 volts and has an 8 bit resolution. In this IC the conversion time depends upon CLK IN signal but it

cannot be faster than 110us. Here the clock source is coming from the crystal of microcontroller.

The analog data output coming from sensor is fed to ADC which converts this analog

signal into digital binary output.

ADC converts this analog voltage as follows:

(1) We need to fix a reference voltage which is normally 1.28V.

(2) ADC uses 8 bit data resolution.

So the step size = max. input voltage/2^(8)

= 2*reference voltage/2^(8)

= 2.56/256

= 10 mV. So

we conclude that the output of ADC will be changing for every 10mV change in the input signal.

4.3. DC MOTOR:

There are several applications with dc motors in our daily life. We may require different speeds

at different instants depending on the applications. There are several techniques to control the speed of

the motor. Here we control the speed of the dc motor using PWM technique. In this system we are

using a 12V DC Motor. There are many situations where signals and data are to be transferred from

one system to another within a piece of electronics equipment, or from one piece of equipment,

without making a direct electrical connection. Often this is because the source and the destination are

(or may be at times) at very different levels of voltage, like a microprocessor which is operating from

12V DC but being used to control a TRIAC which is switching 240V AC. In such situations the link

between the two must be an isolated one, to protect the microcontroller from over voltage damage.

The working principle of a DC motor is as follows:

DC motors are configured in many types and sizes, including brush less, servo and gear motor

types. A motor consists of a rotor and a permanent magnetic field stator. The magnetic field is

Page 12: Digital Temperature Using Atmel 8051 Microcontroller

12

maintained using either permanent magnets or electromagnetic windings. DC motors are most

commonly used in variable speed and torque.

Motion and controls cover a wide range of components that in some way are used to generate

and/or control motion. Areas within this category include bearings and bushings, clutches and brakes,

controls and drives, drive components, encoders and resolvers, integrated motion control, limit

switches, linear actuators, linear and rotator motion components, linear positions sensing, motors (both

AC and DC motors), orientation position sensing, pneumatics and pneumatic components, positioning

stages, slides and guides, power transmission (mechanical), seals, slips, rings, solenoids and springs.

Motors are the devices that provide the actual speed and torque in a drive system. This family

includes AC motors types (single and multiphase motors, universal, servo motors, induction,

synchronous, and gear motor) and DC motors.

PWM TECHNIQUE:

A Pulse Width Modulator (PWM) is a device that may be used as an efficient light dimmer or

DC motor speed controller. A PWM works by making a square wave with a variable on-to-off ratio,

the average on time may be varied from 0 to 100 percent. In this manner, a variable amount of power

is transferred to the load. The main advantage of a PWM circuit over a resistive power controller is the

efficiency – at 50% level, the PWM will use about 50% of full power, almost all of which is

transferred to the load and a resistive controller at 50% load power would consume about 71% of full

power (50% of the power goes to the load and the remaining 21% is wasted in heating the series

resistor). Load efficiency is almost always a critical factor in systems using solar power and other

alternative energies. One additional advantage of PWM is that the pulses reach the full supply voltage

and will produce more torque in a motor by being able to overcome the internal motor resistances

more easily. Finally, in a PWM circuits, common small potentiometers may be used to control a wide

variety of loads whereas large and expensive high power variable resistors are needed for resistive

controllers.

PWM consists of three signals, which are modulated by a square wave. The duty cycle or high

time is proportional to the amplitude of the square wave. The effective average over one cycle is the

duty cycle times the peak-to-peak voltage. Thus, the average voltage follows a square wave. In fact,

this method depends on the motor inductance to integrate out the PWM frequency.

Page 13: Digital Temperature Using Atmel 8051 Microcontroller

13

A very simply off line motor drive can be built using a TRIAC and a control IC. This circuit

can control the speed of a universal motor. A universal motor is a series wound DC motor. The circuit

uses phase angle control to vary the effective motor voltage.

4.4. Applications:

1).We can use it in laptops, computers for temperature control.

Page 14: Digital Temperature Using Atmel 8051 Microcontroller

14

CHAPTER 5

SIMULATION AND SOURCE CODE

We completed the software modeling for the project:

5.1Simulation and source code:

Fig.13 proteus model for digital thermometer

Page 15: Digital Temperature Using Atmel 8051 Microcontroller

15

The following code was used:

ORG 0H

MOV A,#38H

ACALL COMNWRT

ACALL DELAY

MOV A,#0EH

ACALL COMNWRT

ACALL DELAY

MOV A,#01H

ACALL COMNWRT

ACALL DELAY

MOV A,#06H

ACALL COMNWRT

ACALL DELAY

MOV A,#84H

ACALL COMNWRT

ACALL DELAY

MOV A,#'T'

ACALL DATAWRT

ACALL DELAY

MOV A,#'E'

ACALL DATAWRT

ACALL DELAY

MOV A,#'M'

Page 16: Digital Temperature Using Atmel 8051 Microcontroller

16

ACALL DATAWRT

ACALL DELAY

MOV A,#'P'

ACALL DATAWRT

ACALL DELAY

RAM_ADDR EQU 30H

ASCI_RESULT EQU 50H

R BIT P2.5

W BIT P2.6

INTR BIT P2.7

MYDATA EQU P0

MOV P0,#0FFH

SETB INTR

BACK5:MOV P3,#00H

CLR W

ACALL DELAY

ACALL DELAY

SETB W

HERE5:JB INTR,HERE5

CLR R

MOV A,MYDATA

ACALL CONVERSION

ACALL DATADISPLAY

SETB R

MOV R0,#31H

Page 17: Digital Temperature Using Atmel 8051 Microcontroller

17

MOV A,#1H

SUBB A,@R0

JC L3

CLR P3.0

SJMP BACK5

L3: MOV A,#6H

SUBB A,@R0

JC L1

HERE3:

MOV A,#3

SUBB A,@R0

JC L2

SETB P3.0

MOV R3,#25

ACALL DELAY2

CLR P3.0

MOV R3,#75

ACALL DELAY2

SJMP BACK5

L2: SETB P3.0

MOV R3,#65

ACALL DELAY2

CLR P3.0

MOV R3,#35

ACALL DELAY2

Page 18: Digital Temperature Using Atmel 8051 Microcontroller

18

SJMP BACK5

L1: SETB P3.0

MOV R3,#95

ACALL DELAY2

CLR P3.0

MOV R3,#5

ACALL DELAY2

SJMP BACK5

DELAY2:

RPT1: MOV R4,#20

RPT2: MOV R5,#100

RPT3: DJNZ R5,RPT3

DJNZ R4,RPT2

DJNZ R3,RPT1

RET

CONVERSION:

MOV R0,#RAM_ADDR

MOV A,P0

MOV B,#10

DIV AB

MOV @R0,B

INC R0

MOV B,#10

DIV AB

MOV @R0,B

Page 19: Digital Temperature Using Atmel 8051 Microcontroller

19

INC R0

MOV @R0,A

MOV R0,#RAM_ADDR

MOV R1,#ASCI_RESULT

MOV R2,#3

BACK: MOV A,@R0

ORL A,#30H

MOV @R1,A

INC R0

INC R1

DJNZ R2,BACK

RET

DATADISPLAY:

MOV A,#38H

ACALL COMNWRT

ACALL DELAY

MOV A,#0EH

ACALL COMNWRT

ACALL DELAY

MOV A,#01H

ACALL COMNWRT

ACALL DELAY

MOV A,#06H

ACALL COMNWRT

ACALL DELAY

Page 20: Digital Temperature Using Atmel 8051 Microcontroller

20

MOV A,#84H

ACALL COMNWRT

ACALL DELAY

MOV @R1,52H

MOV A,@R1

ACALL DATAWRT

ACALL DELAY

MOV @R1,51H

MOV A,@R1

ACALL DATAWRT

ACALL DELAY

MOV @R1,50H

MOV A,@R1

ACALL DATAWRT

ACALL DELAY

RET

COMNWRT:

MOV P1,A

CLR P2.0

CLR P2.1

SETB P2.2

ACALL DELAY

CLR P2.2

RET

DATAWRT:

Page 21: Digital Temperature Using Atmel 8051 Microcontroller

21

MOV P1,A

SETB P2.0

CLR P2.1

SETB P2.2

ACALL DELAY

CLR P2.2

RET

DELAY : MOV R3,#50

HERE22 :MOV R4,#255

HERE21:DJNZ R4,HERE21

DJNZ R3,HERE22

RET

END

Page 22: Digital Temperature Using Atmel 8051 Microcontroller

22

CHAPTER 6

CONCLUSION

Atmel architecture was studied successfully. LCD and ADC0804 interfacing with AtmelAT89C51 was

studied and implemented on Proteus and same was assembled on a PCB.Thus we have successfully made a

dc motor to run at different speeds by varying temperature.

Page 23: Digital Temperature Using Atmel 8051 Microcontroller

23