Vous êtes sur la page 1sur 59

(Accredited by NAAC, New Delhi)

(Affiliated to JNTU Hyderabad, Approved by APSCHE &AICTE)


Aushapur (v), Ghatkesar (m), R.R Dist, Hyderabad-501301
2018-19

A Mini Project Report On

TEMPERATURE CONTROLLED DC FAN USING 8051


MICROCONTROLLER

Submitted In partial fulfillment of the requirements


For the award of the degree of
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION ENGINEERING
SUBMITTED
BY
D.Priyanka (15P61A04B6)

M.Pavani (15P61A04A2)

K.Karthik Reddy (15P61A0466)

Under the Guidance of


Mr. P. Naveen Kumar
Assistant Professor
Department of
Electronics and Communication Engineering
(Accredited by NAAC, New Delhi)

Department of Electronics and Communication Engineering

CERTIFICATE

This is to certify that the MiniProject report titled on“TEMPERATURE CONTROLLED DC


FAN USING 8051 MICROCONTROLLER”,being submitted byD.Priyanka(15P61A04B6),
M.Pavani (15P61A04A2), K.Karthik Reddy (15P61A0466)inpartial fulfillment for the
award of the Degree of Bachelor of Technology in ELECTRONICS AND
COMMUNICATION ENGINEERING to Jawaharlal Nehru Technological
University,Hyderabad, is a record of a bonafide work carried out by them under my guidance
and supervision.

The resultsembodied in this project report have not been submitted to any other
University/Institution for the award of any Degree.

Internal Guide Head, Department of ECE


Mr. P. Naveen Kumar Dr. Y. Srinivas
Assistant Professor
(Accredited by NAAC, New Delhi)

Department of Electronics and Communication Engineering

CANDIDATE DECLARATION

We hereby declare that this MiniProject Report titled on “TEMPERATURE CONTROLLED DC


FAN USING 8051 MICROCONTROLLER”,submitted by us to the Department of Electronics and
Communication Engineering,VignanaBharathi Institute of Technology, Aushapur, to Jawaharlal
Nehru Technological University, Hyderabad, is a bonafide work undertaken byD.Priyanka
(15P61A04B6), M.Pavani (15P61A04A2), K.Karthik Reddy(15P61A0466)and it is not submitted to
any other University or Institution for the award of any degree.

D.Priyanka (15P61A04B6)
M.Pavani (15P61A04A2)
K.Karthik Reddy (15P61A0466)
(Accredited by NAAC, New Delhi)

ACKNOWLEDGEMENT
At the outset,I sincerely thank to the management and department of ECE for providing
concurrent support for my mini project to complete in stipulated time.

Firstly, I would thank the Management for providing constant support throughout the
completion of project. Secondly, I sincerely thank our beloved Principal,Dr. G. AmarendarRao
and Head of the Department,Dr. Y Srinivas, for their kind cooperation and encouragement for the
successful completion of project report and providing the necessary facilities.

I express my sincere gratitude to Mr. P. Naveen Kumar, Assistant Professor, project


coordinators Ch.Suneetha, Associate Professor, P.Vidyasagar, Associate Professor, S.Preethi,
Assistant Professor, D.Srilekha, Assistant Professorand other faculty members for providing lab
facilities during the project work.

I sincerely express thanks to our parents who have been a motivating factor during the
present stay in the college campus.

D.Priyanka(15P61A04B6)
M.Pavani(15P61A04A2)
K.KarthikReddy (15P61A0466)
ABSTRACT

Temperature controller can be done by using Electronic circuit, microcontroller .Now


microcontroller is advanced among all above circuits therefore we are using Microcontroller for
temperature controlling
Microcontroller is a low-power, high-performance CMOS 8-bit microcontroller with 8K 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 pin out. The on chip Flash allows the program to be reprogrammed in-system. By combining a
versatile 8-bit CPU with Flash on a monolithic chip, it provides a highly flexible and cost effective
solution so many embedded control applications.
In this project we are using FAN as output device. If temperature is above set point then Fan is
ON so that temperature will start to decrease and when the temperature is decrease the fan will
automatically off.
TABLE OF CONTENTS
PAGE NO.

Acknowledgement i

Abstract i

List of Tables iii

List of Figures iv

Abbreviations v

CHAPTER1: INTRODUCTION 1
1.1 Project Overview 1
1.2 Information Transfer 1
1.3 Components Overview 1
1.3.1 Microcontroller 2
1.3.2 LCD 2
1.3.3 ADC 0804 2
1.3.4 Temperature sensor 3
1.3.5 L293D IC 3
1.4 System Operation 3

CHAPTER2: PROBLEM DEFINITION

2.1 Block diagram 4

2.2 Circuit diagram 5

CHAPTER3: SYSTEM REQUIREMENT SPECIFICATION 6

3.1 Hardware Requirements 6


3.1.1 Microcontroller 6
3.1.1.2 architecture of 8051 microcontroller 7
3.1.1.3 pin diagram 8

3.1.1.4 pin description 9-12

3.1.1.5 special function registers 13

3.1.1.6 memory organization 13

3.1.2 ADC0804 14-15

3.1.2.1 pin description 16

3.1.3 Temperature Sensor 17

3.1.3.1 applications of LM35 temperature sensor 18

3.1.4 L293D 19-20

3.1.4.1 working of L293D 20

3.1.5 LCD display 21

3.1.6 important signals 23

3.1.6.1 enable 23

3.1.6.2 register select 23

3.1.6.3 read and write pin 24

3.1.6.4 DC motor 25

3.2 software requirements 27

3.2.1 keil C 27

3.2.2 steps for writing program in keil C 28-31

CHAPTER4: SYSTEM MODELLING AND DESIGN

4.1 Functional Description 32-33


CHAPTER5: IMPLEMENTATION
5.1 Microcontrollers-LCD Interfacing 34
5.1.1 LCD initialization 34
5.1.2 sending data to LCD 35
5.2 Microcontroller-Lm35 Sensor Interfacing 35

5.3 Microcontroller-L293d Interfacing 36

CHAPTER6: TESTING
6.1 Validity Check & Display 37
6.2 Results 38

CHAPTER7: ADVANTAGES AND APPLICATIONS


7.1 Advantages 39
7.2 Disadvantages 39
7.3 Applications 39

CONCLUSION & FUTURE SCOPE


Conclusion 40
Future Scope 40

REFERENCES 41

APPENDIX 42-46
LIST OF TABLES

• Table 3.1 10
• Table 3.2 11
• Table 3.3 17
• Table 3.4 19
• Table 3.5 23
• Table 3.6 25
LIST OF FIGURES

• Figure 2.1 4
• Figure 2.2 5
• Figure 3.1 7
• Figure 3.2 8
• Figure 3.3 16
• Figure 3.4 18
• Figure 3.5 20
• Figure 3.6 21
• Figure 3.7 26
• Figure 3.8 28
• Figure 3.9 28
• Figure 3.10 29
• Figure 3.11 29
• Figure 3.12 30
• Figure 3.13 30
• Figure 4.1 32
• Figure 4.2 34
• Figure 6.1 37
• Figure 6.2 38
ABBREVATIONS

• DIP Dual In-Line Package


• CMOS Complementary Metal Oxide
semiconductor
• ADC Analog To Digital Convertor
• DC Direct Current
• PWM Pulse Width Modulation
• IC Intergrated Circuit
• PCB Printed Circuit Board
• UART Universal Asynchronuous Receiver
Transmitter
Temperature controlled dc fan using 8051 microcontroller

CHAPTER 1: INTRODUCTION

1.1 PROJECT OVERVIEW

The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with


8K 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 pin out. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with in-system programmable
Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which
provides a highly-flexible and cost-effective solution to many embedded control
applications.
The proposed system temperature controlled fan using microcontroller is used to
control the speed of the fan according to the temperature and specify the temperature in
the display. The required components are microcontroller, temperature sensor, motor;
16*2 LCD display, ADC, power supply, L293D IC.

1.2 INFORMATION TRANSFER

In this the information transfer is carried out in four stages, first the temperature
is detected by temperature sensor and is transferred to ADC where the information is
converted to digital form. The digital output from the ADC is send to microcontroller in
which the operations are performed and the resultant output is displayed on the LCD
based on which the DC fan rotates.

Department of ECE, VBIT 1


Temperature controlled dc fan using 8051 microcontroller

1.3 COMPONENTS OVERVIEW

This system uses the following components.

1.3.1 Microcontroller

The Intel 8051 is an 8-bit microcontroller which means that most available
operations are limited to 8 bits. There are 3 basic "sizes" of the 8051: Short, Standard,
and Extended. The Short and Standard chips are often available in DIP (dual in-line
package) form, but the Extended 8051 models often have a different form factor, and are
not "drop-in compatible". All these things are called 8051 because they can all be
programmed using 8051 assembly language, and they all share certain features (although
the different models all have their own special features).

1.3.2 LCD

The temperature controlled dc fan uses JHD 16*2A LCD for displaying the text
data. It is 16character x 2 line display module. But in practice, it should be replaced by
the large multiline, multicolor commercial display units.
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. The data is the ASCII value of the character
to be displayed on the LCD.
1.3.3 ADC0804
The ADC0804 family are CMOS 4-Bit, successive approximation A/D converters
which use a modified potentiometric ladder and are designed to operate with the 8080A
control bus via three-state outputs. These converters appear to the processor as memory
locations or I/O ports, and hence no interfacing logic is required. The differential analog
voltage input has good common- mode-rejection and permits offsetting the analog zero-
input voltage value. In addition, the voltage reference input can be adjusted to allow
encoding any smaller analog voltage span to the full 8 bits of resolution.

Department of ECE, VBIT 2


Temperature controlled dc fan using 8051 microcontroller

1.3.4 Temperature Sensor


LM35 is a precision IC temperature sensor with its output proportional to
the temperature (in oC). The sensor circuitry is sealed and therefore it is not subjected to
oxidation and other processes. With LM35, temperature can be measured more
accurately than with a thermistor. It also possess low self heating and does not cause
more than 0.1 oC temperature rise in still air.
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, i.e., its scale
factor is 0.01V/ oC..

1.3.5 L293D IC
L293D is a dual H-bridge motor driver integrated circuit (IC). Motor drivers act
as current amplifiers since they take a low-current control signal and provide a higher-
current signal. This higher current signal is used to drive the motors.
L293D contains two inbuilt H-bridge driver circuits. In its common mode of
operation, two DC motors can be driven simultaneously, both in forward and reverse
direction. The motor operations of two motors can be controlled by input logic at pins 2
& 7 and 10 & 15. Input logic 00 or 11 will stop the corresponding motor. Logic 01 and
10 will rotate it in clockwise and anticlockwise directions, respectively.
1.4 SYSTEM OPERATION
The operation of the system is very simple. In this the information transfer is
carried out in four stages, first the temperature is detected by temperature sensor and is
transferred to ADC where the information is converted to digital form. The digital output
from the ADC is send to microcontroller in which the operations are performed and the
resultant output is displayed on the LCD based on which the DC fan rotates.For
developing this we need to have some common peripherals including
ADC,microcontroller, LCD (Liquid crystal display) temperature sensor, DC fan, power
supply and some connecting wires.

Department of ECE, VBIT 3


Temperature controlled dc fan using 8051 microcontroller

CHAPTER 2: PROBLEM DEFINITION

Electronic devices produce heat by daily usage then afterwards for a certain length of
time, damages its main components and causes its malfunction.

Objectives:
● To use microcontroller in controlling the speed of a DC fan
● Reduce overheating problem
● To provide an effective low cost device

2.1 Block Diagram:

Fig 2.1: block diagram

Department of ECE, VBIT 4


Temperature controlled dc fan using 8051 microcontroller

2.2 CIRCUIT DIAGRAM OF THE SYSTEM

Fig 2.2: circuit diagram

Department of ECE, VBIT 5


Temperature controlled dc fan using 8051 microcontroller

CHAPTER 3: SYSTEM REQUIREMENT SPECIFICATION


3.1 HARDWARE REQUIREMENTS
3.1.1 Microcontroller

The AT89S52 is a low-power, high-performance CMOS 8-bit


microcontroller with 8K 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 pin out. The on-chip
Flash allows the program memory to be reprogrammed in-system or by a conventional
nonvolatile memory programmer. By combining a versatile 8-bit CPU with in-system
programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many
embedded control applications.

The AT89S52 provides the following standard features: 8K bytes of Flash,


256 bytes of RAM, 32 I/O lines, two data pointers, three 16-bit timer/counters, a six-
vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and
clock circuitry. In addition, the AT89S52 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.

Department of ECE, VBIT 6


Temperature controlled dc fan using 8051 microcontroller

3.1.1.2 Architecture of 8051 Microcontroller

Fig 3.1: architecture of 8051

Department of ECE, VBIT 7


Temperature controlled dc fan using 8051 microcontroller

3.1.1.3 Pin diagram:

Fig 3.2: pin diagram of AT89S52

Department of ECE, VBIT 8


Temperature controlled dc fan using 8051 microcontroller

3.1.1.4 Pin Description

● VCC Supply voltage

● GND Ground

Port 0:

Port 0 is an 8-bit open drain bidirectional 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.

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 bidirectional 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.

In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external


count I Input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively,
as shown in the following table. Port 1 also receives the low-order address bytes during
Flash programming and verification.

Department of ECE, VBIT 9


Temperature controlled dc fan using 8051 microcontroller

PORT PINS ALTERNATE FUNCTIONS

P1.0 T2(external count input to timer / counter 2),clock – out

P1.1 T2EX(timer / counter 2 capture / reload trigger and direction


control)

P1.5 MOSI (used for in- system programming)

P1.6 MISO (used for in -system programming)

P1.7 SCK(used for in –system programming)

Table 3.1

Port 2:

Port 2 is an 8-bit bidirectional 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.

Department of ECE, VBIT 10


Temperature controlled dc fan using 8051 microcontroller

Port 3:

Port 3 is an 8-bit bidirectional 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 also serves the functions of various special features of the AT89S52, as
shown in the following table. Port 3 also receives some control signals for Flash
programming and verification.

Port pins 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)

P3.7 RD (external data memory read strobe)

Table 3.2

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 96 oscillator periods after the

Department of ECE, VBIT 11


Temperature controlled dc fan using 8051 microcontroller

Watchdog times out. The 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 AT89S52 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.

Department of ECE, VBIT 12


Temperature controlled dc fan using 8051 microcontroller

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.

3.1.1.5 Special Function Registers

A map of the on-chip memory area called the Special Function Register (SFR).
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.

User software should not write 1s to these unlisted locations, since they may be
used in future products to invoke new features. In that case, the reset or inactive values
of the new bits will always be 0.

Timer 2 Registers:

Control and status bits are contained in registers T2CON (shown in Table 2) and
T2MOD (shown in Table 3) for Timer 2. The register pair (RCAP2H, RCAP2L) are the
Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.

Interrupt Registers:

The individual interrupt enable bits are in the IE register. Two priorities can be
set for each of the six interrupt sources in the IP register

Department of ECE, VBIT 13


Temperature controlled dc fan using 8051 microcontroller

3.1.1.6 Memory Organization:

MCS-51 devices have a separate address space for Program and Data Memory.
Up to 64K bytes each of external Program and Data Memory can be addressed.

Program Memory:

If the EA pin is connected to GND, all program fetches are directed to external
memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses
0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H
through FFFFH are to external memory.

Data Memory:

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes
occupy a parallel address space to the Special Function Registers. This means that the
upper 128 bytes have the same addresses as the SFR space but are physically separate
from SFR space.

When an instruction accesses an internal location above address 7FH, the


address mode used in the instruction specifies whether the CPU accesses the upper 128
bytes of RAM or the SFR space.

Instructions which use direct addressing access of the SFR space. For example,
the following direct addressing instruction accesses the SFR at location 0A0H (which is
P2).

MOV 0A0H, #data

Instructions that use indirect addressing access the upper 128 bytes of RAM.
For example, the following indirect addressing instruction, where R0 contains 0A0H,
accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H).

MOV @R0, #data

Department of ECE, VBIT 14


Temperature controlled dc fan using 8051 microcontroller

Note that stack operations are examples of indirect addressing, so the upper 128 bytes of
data RAM are available as stack space

3.1.2 ADC 0804


Analog to digital converters find huge application as an intermediate device to
convert the signals from analog to digital form. These digital signals are used for further
processing by the digital processors. Various sensors like temperature, pressure, force etc.
convert the physical characteristics into electrical signals that are analog in nature.
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. When this pin is not connected, the default reference voltage is the operating
voltage, i.e., VCC. The step size at 5V is 19.53mV (5V/255), i.e., for every 19.53mV rise
in the analog input, the output varies by 1 unit. To set a particular voltage level as the
reference value, this pin is connected to half the voltage.
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.

Department of ECE, VBIT 15


Temperature controlled dc fan using 8051 microcontroller

Pin diagram:

Fig 3.3: pin diagram of ADC0804

Department of ECE, VBIT 16


Temperature controlled dc fan using 8051 microcontroller

3.1.2.1 Pin Description

Pin
Function Name
No
1 Activates ADC; Active low Chip select
Input pin; High to low pulse brings the data from internal
2 Read
registers to the output pins after conversion
3 Input pin; Low to high pulse is given to start the conversion Write
4 Clock Input pin; to give external clock. Clock IN
5 Output pin; Goes low when conversion is complete Interrupt
6 Analog non-inverting input Vin(+)
7 Analog inverting Input; normally ground Vin(-)
Analog
8 Ground(0V)
Ground
9 Input pin; sets the reference voltage for analog input Vref/2
10 Ground(0V) Digital Ground
11 D7
12 D6
13 D5
14 D4
8 bit digital output pins
15 D3
16 D2
17 D1
18 D0
19 Used with Clock IN pin when internal clock source is used Clock R
20 Supply voltage; 5V Vcc

Table 3.3: pin description of ADC08704

Department of ECE, VBIT 17


Temperature controlled dc fan using 8051 microcontroller

3.1.3 Temperature Sensor:


Usually, a temperature sensor is a thermocouple or a resistance temperature
detector (RTD) that gathers the temperature from a specific source and alters the
collected information into understandable type for an apparatus or an observer.
Temperature sensors are used in several applications namely HV system and
AC system environmental controls, medical devices, food processing units, chemical
handling, controlling systems, automotive under the hood monitoring.
The most frequent type of temperature sensor is a thermometer, used to
determine the temperature of solids, liquids, and gases. It is also mostly used for non-
scientific purposes as it is not so accurate. The different kinds of sensors are categorized
by the sensing capacity of the sensor as well as the range of applications.
The LM35 does not need any exterior calibration and maintains an exactness of
+/-0.4°C at room temperature and +/-0.8°C over a range of 0°C to +100°C.One more
significant characteristic of this sensor is that it draws just 60 micro amps from its supply
and acquires a low self-heating capacity.
The LM35 temperature sensor available in many different packages like T0-46
metal can transistor-like package, TO-92 plastic transistor-like package, 8-lead surface
mount SO-8 small outline package.

Fig 3.4: Temperature sensor

Department of ECE, VBIT 18


Temperature controlled dc fan using 8051 microcontroller

1 Vcc Input voltage is +5V for typical applications

2 Analog output There will be the increase in 10mv for raise of every
1ºC can range from -1v(-55ºC) to 6V (150ºC)

3 Ground Connected to the ground terminal of the circuit

Table 3.4: pin description of LM35 sensor

3.1.3.1 Applications of LM35 Temperature Sensor:


The applications of LM35 temperature sensor include the following

● Measuring temperature of a particular environment and HVAC applications


● Providing thermal shut down for a component/ circuit
● Checking Battery Temperature

3.1.4 L293D
L293D is a typical Motor driver or Motor Driver IC which allows DC motor to
drive on either direction. L293D is a 16-pin IC which can control a set of two DC motors
simultaneously in any direction. It means that you can control two DC motor with a
single L293D IC.
It works on the concept of H-bridge. H-bridge is a circuit which allows the
voltage to be flown in either direction. As you know voltage need to change its direction
for being able to rotate the motor in clockwise or anticlockwise direction, Hence H-
bridge IC are ideal for driving a DC motor.
In a single L293D chip there are two h-Bridge circuit inside the IC which can
rotate two dc motor independently. Due its size it is very much used in robotic
application for controlling DC motors. Given below is the pin diagram of a L293D mot
or controller.There are two Enable pins on l293d. Pin 1 and pin 9, for being able to drive

Department of ECE, VBIT 19


Temperature controlled dc fan using 8051 microcontroller

the motor, the pin 1 and 9 need to be high. For driving the motor with left H-bridge you
need to enable pin 1 to high. And for right H-Bridge you need to make the pin 9 to high.
If anyone of the either pin1 or pin9 goes low then the motor in the corresponding section
will suspend working. It’s like a switch.

Fig 3.5: Pin diagram of L293D IC

3.1.4.1 Working of L293D:

There are 4 input pins for l293d, pin 2,7 on the left and pin 15 ,10 on the right as
shown on the pin diagram. Left input pins will regulate the rotation of motor connected
across left side and right input for motor on the right hand side. The motors are rotated on
the basis of the inputs provided across the input pins as LOGIC 0 or LOGIC 1.

Department of ECE, VBIT 20


Temperature controlled dc fan using 8051 microcontroller

In simple you need to provide Logic 0 or 1 across the input pins for rotating the motor.

3.1.5 LCD Display

One of the most common devices attached to an microcontroller is an LCD


display. Some of the most common LCDs connected to the Atmega328 are 16x2 and
20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by
2 lines, respectively. In recent years the LCD is finding widespread use replacing LED‟s.
This is due to the following reasons:

1. Declining prices.
2. Ability to display numbers, characters and graphics.
3. Incorporation of a refreshing controller into the LCD.
4. Ease of programming.

Fig 3.6: LCD display

Fortunately, a very popular standard exists which allows us to communicate with


the vast majority of LCDs regardless of their manufacturer. The standard is referred to as
HD44780U, which refers to the controller chip which receives data from an external
source and communicates directly with the LCD. The 44780 standard requires 3 control
lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the
LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the
LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus).
If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines
plus the 8 lines for the data bus).

Department of ECE, VBIT 21


Temperature controlled dc fan using 8051 microcontroller

Sl. Pin Pin Pin Type Pin Description Pin Connection


No No. Name

1 Pin Ground Source Pin This is a ground Connected to


1 pin of LCD the ground
of the MCU/
Power source

2 Pin VCC Source Pin This is the supply Connected to the supply
2 voltage pin of LCD pin of Power source

3 Pin V0/VEE Control Pin Adjusts the Connected to a variable


3 contrast of the POT that can source 0-
LCD. 5V

4 Pin Register Control Pin Toggles between Connected to a MCU


4 Select Command/Data pin and gets either 0 or
Register 1.
0 -> Command Mode
1-> Data Mode

5 Pin Read/W Control Pin Toggles the LCD Connected to a MCU


5 rite between pin and gets either 0 or
Read/Write 1.
Operation 0 -> Write Operation
1-> Read Operation

6 Pin Enable Control Pin Must be held high Connected to MCU and
6 to perform always held high.
Read/Write

Department of ECE, VBIT 22


Temperature controlled dc fan using 8051 microcontroller

Operation

7 Pin Data Data/Comm Pins used to send In 4-Wire Mode


7-14 Bits (0- and Pin Command or data Only 4 pins (0-3)
7) to the LCD. is connected to MCU
In 8-Wire Mode
All 8 pins(0-7) are
connected to MCU

8 Pin LED LED Pin Normal LED like Connected to +5V


15 Positive operation to
illuminate the LCD

9 Pin LED LED Pin Normal LED like Connected to ground


16 Negativ operation to
e illuminate the LCD
connected with
GND.

Table 3.5: Pin Description of LCD


3.1.6 Important Signals

The following pins are important to LCD‟s while programming

3.1.6.1 Enable (EN)

The EN line is called "Enable." This control line is used to tell the LCD that you
are sending it data. To send data to the LCD, your program should make sure this line is
low (0) and then set the other two control lines and/or put data on the data bus. When the
other lines are completely ready, bring EN high (1) and wait for the minimum amount of

Department of ECE, VBIT 23


Temperature controlled dc fan using 8051 microcontroller

time required by the LCD datasheet (this varies from LCD to LCD), and end by bringing
it low (0) again.

3.1.6.2 Register Select (RS)

The RS line is the "Register Select" line. When RS is low (0), the data is to be
treated as a command or special instruction (such as clear screen, position cursor, etc.).
When RS is high (1), the data being sent is text data which should be displayed on the
screen. For example, to display the letter "T" on the screen you would set RS high.

3.1.6.3 Read/Write (R/W)

The RW line is the "Read/Write" control line. When RW is low (0), the
information on the data bus is being written to the LCD. When RW is high (1), the
program is effectively querying (or reading) the LCD. Only one instruction ("Get LCD
status") is a read command. All others are write commands--so RW will almost always be
low. Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation
selected by the user). In the case of an 8-bit data bus, the lines are referred to as DB0,
DB1, DB2, DB3, DB4, DB5, DB6, and DB7.
The LCD panel's Enable and Register Select is connected to the Control Port.
The Control Port is an open collector / open drain output. While most Parallel Ports have
internal pull-up resistors, there is a few which don't. Therefore, by incorporating the two
10K external pull up resistors, the circuit is more 18 portable for a wider range of
computers, some of which may have no internal pull up resistors.
We make no effort to place the Data bus into reverse direction. Therefore, we hard
wire the R/W line of the LCD panel, into write mode. This will cause no bus conflicts on
the data lines. As a result we cannot read back the LCD Internal busy flag is noticed if the
LCD has accepted and finished processing the last instruction. This problem is overcome
by inserting known delays into our program.
The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy
here. As with all the examples, I've left the power supply out. You can use a bench power

Department of ECE, VBIT 24


Temperature controlled dc fan using 8051 microcontroller

supply set to 5V or use a onboard +5 regulator. Remember a few de-coupling capacitors,


especially if you have trouble with the circuit working properly.

Table 3.6: LCD commands


3.1.6.4 DC motor
A DC motor is any of a class of rotary electrical machines that converts direct
current electrical energy into mechanical energy. The most common types rely on the
forces produced by magnetic fields. Nearly all types of DC motors have some internal
mechanism, either electromechanical or electronic, to periodically change the direction of
current flow in part of the motor.

DC motors were the first type widely used, since they could be powered from
existing direct-current lighting power distribution systems. A DC motor's speed can be
controlled over a wide range, using either a variable supply voltage or by changing the
strength of current in its field windings. Small DC motors are used in tools, toys, and

Department of ECE, VBIT 25


Temperature controlled dc fan using 8051 microcontroller

appliances. The universal motor can operate on direct current but is a


lightweight brushed motor used for portable power tools and appliances. Larger DC
motors are used in propulsion of electric vehicles, elevator and hoists, or in drives for
steel rolling mills. The advent of power electronics has made replacement of DC motors
with AC motors possible in many applications.

Fig3.7: Dc motor with fan

3.2 SOFTWARE REQUIREMENTS

3.2.1 Keil C

Keil development tools for the 8051 Microcontroller Architecture support every
level of software developer from the professional applications engineer to the student just
learning about embedded software development.
The industry-standard Keil C Compilers, Macro Assemblers, Debuggers, Real-
time Kernels, Single-board Computers, and Emulators support all 8051 derivatives and
help you get your projects completed on schedule.
The Keil 8051 Development Tools are designed to solve the complex problems facing embedded
software developers.

Department of ECE, VBIT 26


Temperature controlled dc fan using 8051 microcontroller

• When starting a new project, simply select the microcontroller you use from the
Device Database and the µVision IDE sets all compiler, assembler, linker, and
memory options for you.
• Numerous example programs are included to help you get started with the most
popular embedded 8051 devices.
• The Keil µVision Debugger accurately simulates on-chip peripherals (I²C, CAN,
UART, SPI, Interrupts, I/O Ports, A/D Converter, D/A Converter, and PWM
Modules) of your 8051 device. Simulation helps you understand hardware
configurations and avoids time wasted on setup problems. Additionally, with
simulation, you can write and test applications before target hardware is available.
When you are ready to begin testing your software application with target
hardware, use the MON51, MON390, MONADI, or FlashMON51 Target Monitors, the
ISD51 In-System Debugger, or the ULINK USB-JTAG Adapter to downlad and test
program code on your target system.

The Keil C51 C Compiler for the 8051 microcontroller is the most popular 8051
C compiler in the world. It provides more features than any other 8051 C compiler
available today.

The C51 Compiler allows you to write 8051 microcontroller applications in C


that, once compiled, have the efficiency and speed of assembly language. Language
extensions in the C51 Compiler give you full access to all resources of the 8051.

The C51 Compiler translates C source files into relocatable object modules which
contain full symbolic information for debugging with the µVision Debugger or an in-
circuit emulator. In addition to the object file, the compiler generates a listing file which
may optionally include symbol table and cross reference information.

Department of ECE, VBIT 27


Temperature controlled dc fan using 8051 microcontroller

3.2.2 Steps for writing the program in keil c:

Fig 3.8: selecting the device type

Fig3.9: adding the existing file to source group

Department of ECE, VBIT 28


Temperature controlled dc fan using 8051 microcontroller

Fig 3.10: writing the program in keil c

Fig3.11: creating the hex file

Department of ECE, VBIT 29


Temperature controlled dc fan using 8051 microcontroller

Fig 3.12: compiling the program in keil c

Fig 3.13: uploading program into the microcontroller

Department of ECE, VBIT 30


Temperature controlled dc fan using 8051 microcontroller

Features:

▪ Nine basic data types, including 32-bit IEEE floating-point,


▪ Flexible variable allocation with bit, data, b data, I data, x data, and p data
memory types,
▪ Interrupt functions may be written in C,
▪ Full use of the 8051 register banks,
▪ Complete symbol and type information for source-level debugging,
▪ Use of AJMP and ACALL instructions,
▪ Bit-addressable data objects,
▪ Built-in interface for the RTX51 Real-Time Kernel,
▪ Support for dual data pointers on Atmel, AMD, Cypress, Dallas Semiconductor,
Infineon, Philips, and Triscend microcontrollers,
▪ Support for the Philips 8xC750, 8xC751, and 8xC752 limited instruction sets,
▪ Support for the Infineon 80C517 arithmetic unit.

Department of ECE, VBIT 31


Temperature controlled dc fan using 8051 microcontroller

CHAPTER 4: SYSTEM MODELLING AND DESIGN

4.1 Functional description:

Fig 4.1 : functional decomposition diagram

Department of ECE, VBIT 32


Temperature controlled dc fan using 8051 microcontroller

The constituent parts involved in the process are:


● Microcontroller
● L293D IC
● LM35 sensor
● ADC0804
● 16*2 LCD
First the temperature sensor senses the temperature and sends the data to the
ADC. The ADC converts the data to the digital form and sends it to the
microcontroller where the entire operation is performed. The microcontroller
sends the result to the LCD as well as l293D IC so that the fan rotates based on
the temperature

Department of ECE, VBIT 33


Temperature controlled dc fan using 8051 microcontroller

CHAPTER 5: IMPLEMENTATION

5.1 MICROCONTROLLER - LCD INTERFACING

Fig 5.1: microcontroller – LCD interfacing

5.1.1 LCD initialization


The steps that has to be done for initializing the LCD display is given below and these
steps are common for almost all applications.

● Send 38H to the 8 bit data line for initialization


● Send 0FH for making LCD ON, cursor ON and cursor blinking ON.
● Send 06H for incrementing cursor position.
● Send 01H for clearing the display and return the cursor.

Department of ECE, VBIT 34


Temperature controlled dc fan using 8051 microcontroller

5.1.2 Sending data to the LCD


The steps for sending data to the LCD module is given below. I have already said
that the LCD module has pins namely RS, R/W and E. It is the logic state of these pins
that make the module to determine whether a given data input is a command or data to be
displayed.

● Make R/W low.


● Make RS=0 if data byte is a command and make RS=1 if the data byte is a data to be
displayed.
● Place data byte on the data register.
● Pulse E from high to low.
● Repeat above steps for sending another data.

5.2 MICROCONTROLLER - LM35 SENSOR INTERFACING


8051 doesn’t has inbuilt ADC. So we have to use external ADC. There are many
ADCs available.
• ADC 0804
• ADC 0808
ADC0804
• Make Cs(chip select) low(0) to activate the ic. Here we are directly connecting
that CS into Ground instead of connecting into 8051.
• Make WR(write) pin low(0)
• Make RD(read) pin high (1).
• Make WR(write) pin high (1) after some delay small delay//This low to high
impulse at WR pin starts your conversion.
• Now check the INTR(interrupt) pin if it is high(1) conversion is runing if it is
low(0) the conversion is over.
• Make RD=low(0) .
This will bring the converted value to the 8 data output pins of ADC 0804.

Department of ECE, VBIT 35


Temperature controlled dc fan using 8051 microcontroller

LM35
LCD:
• RS : P0
• RW : P0
• EN : P0
• Data Lines : P2
ADC:
• RD : P0
• WR : P0
• INTR : P0
• Output : P1
Temperature Sensor:
Output of Temp sensor – Vin+ (6)

5.3 MICROCONTROLLER-L293D INTERFACING

• In this project I have used only one enable pin i.e. E1 to operate only one DC
motor (at 9v).
• The input pins (pin 2 and pin 7) of L293D are connected to pin P1^1 and P1^2 of
AT89S52 respectively.
• The output pins (pin 3 and pin 6) of L293D will serve as the negative and positive
terminals for the motor to drive.
• In the coding part “Mn” and “Mp” denote the negative and positive terminals of
the motor
• The IC 7805 voltage regulator provides a step down from 9V to 5V (ideal voltage
for AT89S52)

The Crystal provides the desired 11.0592 MHz frequency for the microcontroller to work
upon.

Department of ECE, VBIT 36


Temperature controlled dc fan using 8051 microcontroller

CHAPTER 6: TESTING

6.1 VALIDITY CHECK & DISPLAY


Microcontroller based temperature controller is a simple and useful
circuit which can be used to control the temperature above a set value using LM35
temperature sensor. Initially, circuit was selected and components where purchased and
the circuit was verified in bread board. Then we designed the PCB and the circuit was
soldered onto the PCB. The actual temperature and set value of temperature were getting
displayed on the LCD screen and the set temperature was found changing with the help
of preset buttons. Output was verified by setting the temperature at different levels and it
was found that the heater (bulb) turn on and off when the device crosses the set value.

6.2 RESULTS
Snapshots

Fig 6.1: snapshot of result 1

Department of ECE, VBIT 37


Temperature controlled dc fan using 8051 microcontroller

Fig 6.2: snapshot of result 2

Department of ECE, VBIT 38


Temperature controlled dc fan using 8051 microcontroller

CHAPTER 7: ADVANTAGES AND APPLICATIONS

7.1 ADVANTAGE

• It is very economical and easy to handle by the user.

• Speed varies automatically, so that it controls the speed with out using it manually
● It is helpful to disabled people
● It is very easy to install in houses, offices, etc.
● Save energy by slowing down its speed in low temperature

7.2 DISADVANTAGES

• Microcontroller is the heart of the circuit, if controller is damaged the whole


system will be interrupted
• Speed control is independent of individual preference

7.3 APPLICATIONS
● Temperature controlled DC fan can be used to control the temperature of devices
,rooms, electronics components etc, by monitoring the temperature.
● The circuit can be used in CPU to reduce the heat
● Can be extended to PWM based output, where the speed of the fan can be varied
according to the duty cycle of the PWM signal.

Department of ECE, VBIT 39


Temperature controlled dc fan using 8051 microcontroller

CONCLUSION AND FUTURE SCOPE


CONCLUSION
Basic idea of this project is to run the DC motor fan when temperature sensed by
the temperature sensor is greater than threshold value .in this project we have used
AT89S52 microcontroller the microcontroller uses the hex file to execute the program
.the temperature sensor output is connected to the microcontroller through ADC and it
gives the output to the LCD and motor driver IC which runs the motor .in tis way our
main objective of the project is achieved

FUTURE SCOPE

The goals of this project were purposely kept within what was believed to be attainable
within the allotted timeline.as such, many improvements can be made upon this initial
design. That being said ,it felt that this design represents a functioning miniature scale
method which could be replicated to a much larger scale .
The following recommendations are provided as ideas for future expansion of this project

● Changeable temperature limits can be applied by adding matrix keypad


● High precision sensors such as platinum wire can be used. This makes it possible
to measure more range of temperature.
● Multiple sensors can be used to provide air conditioning over wider area.

Department of ECE, VBIT 40


Temperature controlled dc fan using 8051 microcontroller

REFERENCES
• “The 8051 Microcontroller and Embedded Systems : Using Assembly and C”
by Muhammad Ali Malzidi
This book focuses on 8051 microcontroller. The book also specifies the
software and hardware specifications for 8051 microcontroller. The chapters in
the book provide basic architecture of microcontrollers using assembly languages.
The chapters illustrate how microcontroller interfaces with necessary devices
using C and assembly languages. The microcontroller uses C and assembly
languages to interact with devices like LCDs, keyboards, sensors and stepper
motors. The other topics presented in the book are real time clock chips,
optoisolators.
• “Advanced Microprocessors and Peripherals by A K Ray and K M
Bhurchandi”
This Book integrates basics ,theory,design and real life applications
related to advanced microprocessors .this book provides a good foundation for
advanced microprocessors,principles and practices.the book enables the students
to write efficient programs in assembly level language of 8086 family of
processors the book is updated with topics like ARM architecture ,serial
communication standard USB,8051 microcontrollers,instruction set and
peripheral interfacing along with project design
• "ISO 4335: 1987", Information processing systems — Data Communication —
High-level data link control elements of procedures.
● "ISO 8877: 1987", Information processing systems — Interface connector and
contact assignments for ISDN basic access interface located at reference points
S and T

Department of ECE, VBIT 41


Temperature controlled dc fan using 8051 microcontroller

APPENDIX
#include <reg52.h>
#include <string.h>
#define ldata P2
void lcddata(unsigned char *str);
void lcdcmd(unsigned char cmd);
void msdelay(unsigned int itime);
void convert_display(unsigned char);
void datawrt(unsigned char );
unsigned char adc();
void fanon();
void fanoff();
unsigned char conv;
sbit rs=P0^0;
sbit rw=P0^1;
sbit en=P0^2;
sbit rd_adc =P0^3;
sbit wr_adc =P0^4;
sbit intr_adc =P0^5;
sbit fanP = P0^6;
sbit fanN = P0^7;
void main()
{
unsigned char get_value;
unsigned char x1,x2,x3;
ldata =0x00;
rs=rw=en=0;
intr_adc=1;
rd_adc=0;
wr_adc=0;

Department of ECE, VBIT 42


Temperature controlled dc fan using 8051 microcontroller

fanP = 0;
fanN = 0;
x1=x2=x3=0;
lcdcmd(0x38);
lcdcmd(0x0e);
lcdcmd(0x06);
lcdcmd(0x01);
lcdcmd(0x0c);
lcdcmd(0x80);
lcddata("Welcome...");

msdelay(1000);
lcdcmd(0x01);

msdelay(100);
lcddata("Temp:");

msdelay(100);
lcdcmd(0xC0);

msdelay(10);
fanon();
msdelay(2);
fanoff()
msdelay(10);

while(1)
{
get_value = adc();
lcdcmd(0x87);
msdelay(10);

Department of ECE, VBIT 43


Temperature controlled dc fan using 8051 microcontroller

x1=(get_value/100)+48;
datawrt(x1);
x2=((((get_value)/10)%10)+48);
datawrt(x2);
x3=(get_value%10)+48;
datawrt(x3);
datawrt(0x60);
datawrt('C');
msdelay(10);
if(( x2 >= 0x33) )
fanon()
else
fanoff()
}

}
void fanon()
{
fanP = 0;
fanN = 1;
msdelay(2000);
}
void fanoff()
{
fanP = 0;
fanN = 0;
msdelay(2000);
}
unsigned char adc()
{
wr_adc=0;

Department of ECE, VBIT 44


Temperature controlled dc fan using 8051 microcontroller

rd_adc=1;
wr_adc=1;
while(intr_adc==1);
rd_adc=0;
conv=P1;

return conv;
}
void datawrt(unsigned char y)
{
ldata =y;
rs=1;
rw=0;
en=1;
msdelay(1);
en=0;
}
void lcddata(unsigned char *str) //LCD data Function
{
while(*str != '\0')
{
ldata = *str;
rs=1;
rw=0;
en=1;
msdelay(1);
en=0;
str++;
}
}

Department of ECE, VBIT 45


Temperature controlled dc fan using 8051 microcontroller

void lcdcmd(unsigned char cmd) //LCD cammand Function


{
ldata=cmd;
rs=0;
rw=0;
en=1;
msdelay(1);
en=0;
}

void msdelay(unsigned int itime) //Delay Function


{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<125;j++);
}

Department of ECE, VBIT 46


Temperature controlled dc fan using 8051 microcontroller

Department of ECE, VBIT 47


Temperature controlled dc fan using 8051 microcontroller

Department of ECE, VBIT 48

Vous aimerez peut-être aussi