24
THE AUTOMATED PIC MICROCONTROLLER BASED TEMPERATURE CONTROL OF FAN SPEED DESIGN Nur Khairunnisa Binti Muhammad Alwy BEKC 2009

The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

Embed Size (px)

Citation preview

Page 1: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

THE AUTOMATED PIC MICROCONTROLLER BASED

TEMPERATURE CONTROL OF FAN SPEED DESIGN

Nur Khairunnisa Binti Muhammad Alwy

BEKC

2009

Page 2: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

“I hereby declared that I have read through this report and found that it has

comply the partial fulfillment for awarding the degree of Bachelor of Electrical

Engineering

(Control, Instrumentation and Automation)”

Signature : ………………………………………………

Supervisor‟s Name : ……………………………………………….

Date : ……………………………………………….

Page 3: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

THE AUTOMATED PIC MICROCONTROLLER BASED

TEMPERATURE CONTROL OF FAN SPEED DESIGN

NUR KHAIRUNNISA BINTI MUHAMMAD ALWY

A report submitted in partial fulfillment of requirements for the degree

of Bachelor in Electrical Engineering (Control, Instrumentation And

Automation)

Faculty Of Electrical Engineering

UNIVERSITI TEKNIKAL MALAYSIA MELAKA

2009

Page 4: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

I hereby declared that this report entitle “The Automated PIC Microcontroller

Based Temperature Control Of Fan Speed Design” is the result of my own

research except as cited in the reference. The report has not been accepted for

any degree and is not concurrently submitted in candidature of any other

degree.

Signature : ………………………………………………

Name : ……………………………………………….

Date : ……………………………………………….

Page 5: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

“To dear mum and dad,

Zuraidah Bt Abu and Muhammad Alwy B Mohammad Amin”

Page 6: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

ACKNOWLEDGEMENT

Alhamdulilah, praise be to Allah, for enabling me to complete this PIC

Microcontroller control for home automation system project and report for my

“Projek Sarjana Muda”.

I would like to express my profound gratitude to my Final Year Project

(FYP) supervisor, Mr. Hyreil Anuar Bin Hj Kasdirin for his invaluable support,

guidance, supervision and useful suggestions throughout this report. His

contribution, moral support and continuous encouragement enabled me to

complete my report successfully.

I am indebted to my friends for their aid, ideas and advice and others

who helped me in completing this project directly or indirectly.

Last, but not least, special thanks extended to my beloved parents, Mr.

Muhammad Alwy Bin Mohammad Amin and Ms, Zuraidah Bt Abu, for their

love, patience and understanding provided during these years, and also for their

great support in difficult moments.

Page 7: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

ABSTRACT

This project is to design and develop a “The automated PIC

microcontroller based temperature control of fan speed design”. This project

will present the design, construction, development, control and analysis that

can be implemented for home automation system. The home automation

system is PIC microcontroller based project which focused on a system to

automatically control the speed of a ceiling fan according to the surrounding

temperature. This ceiling fan system contains combination of sensor,

controller, driver and motor with integration of embedded controlled

programming which means in this case using PIC16F876A as the main

controller. This project also presents the expected performance of the

automatic fan system, construction of hardware and software development to

gather the performance data. Finally, this system performance will be analysed

by comparing performance data to the theoretical. End of this project will

produce an advance technology with programmable features and control where

the speed of the fan is depending on the changes in room temperature.

Page 8: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

ABSTRAK

Project ini adalah bertujuan untuk mereka bentuk dan membangunkan

satu “Mikrokawalan PIC yang automatik untuk mengawal kelajuan sebuah

kipas bergantung kepada suhu sekeliling”. Projek ini akan mempersembahkan

reka bentuk, pembinaan, pembangunan, kawalan dan analisis yang telah dapat

dilaksanakan untuk sistem automasi di rumah. Sistem automasi ini adalah

berdasarkan mikropengawal PIC di mana ia menumpukan kepada sebuah

system yang secara automatik mengawal kelajuan satu kipas siling

berpandukan suhu sekeliling. Sistem ini juga mengandungi gabungan

elektronik seperti penderia, pengawalan, pemandu dan motor (iaitu kipas)

dengan integrasi pengaturcaraan yang terkawal yang mana dalam projek ini

menggunakan PIC16F876A sebagai pengawal utama. Projek ini juga

membentangkan tentang prestasi dijangka untuk sistem kipas automatik,

pembinaan bagi perkakasan dan pembangunan perisian untuk mengumpul

prestasi data. Akhirnya, prestasi sistem ini akan dianalisis dengan

membandingkan prestasi data secara teori. Akhir sekali, projek ini akan

menghasilkan satu teknologi maju kepada kipas dengan ciri-ciri boleh

diprogram dan dikawalan di mana kelajuan kipas adalah terserah perubahan

dalam suhu bilik.

Page 9: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

TABLE OF CONTENTS

CHAPTER TITLE PAGE

DECLARATION iii

DEDICATION iv

ACKNOWLEDGEMENT v

ABSTRACT vi

TABLE OF CONTENTS viii

LIST OF TABLE xi

LIST OF FIGURE xii

LIST OF ABBREVIATIONS xv

LIST OF APPENDICES xvii

1 INTRODUCTION

1.1 Background 1

1.2 Problem Statement 2

1.3 Objectives 3

1.4 Scope Of Project 3

1.5 Organization 4

2 LITERATURE REVIEW 5

2.1 Preface 5

2.2 Temperature-Rated Electric Fan 5

Page 10: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

2.3 Types of Speed Variable 6

2.3.1 Wall-Mounted Control 6

2.3.2 Pulled-Chain 8

2.3.3 Remote Controlled 8

2.3.4 Hand-clapped Control 10

2.4 Type of Controller 12

2.4.1 Microprocessor 12

2.4.2 Microcontroller 14

2.4.3 Microchip PIC16F876A 16

2.5 LM35DZ Temperature Sensor 18

2.6 Subsumtion 20

3 METHODOLOGY 21

3.1 Preface 21

3.2 Project Flowchart 22

3.3 Practice of Project 23

3.4 System Development 25

3.4.1 Hardware Development 26

3.4.2 Software Development 30

3.4.3 Firmware Development 33

3.5 Project Operation 33

3.6 Subsumtion 35

4 RESULT AND ANALYSIS 36

4.1 Preface 36

4.1 Project Analysis 37

4.2 Hardware Analysis 38

4.2.1 12V and 5V Power Supply

Circuit

40

4.2.2 PIC16F876A Basic Circuit 45

4.2.3 Temperature Sensor Circuit 53

4.2.4 External Equipment Drive

Page 11: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

Circuit 58

4.2.5 Motor (Fan) Drive Circuit 62

4.2.6 Interface PIC16F876A With

LCD (216 Characters)

69

4.3 Software Analysis 74

4.3.1 PIC Basic Programming 75

4.3.2 ADC Programming 76

4.3.3 Threshold for ADC Input 80

4.3.4 Multiple Thresholds for

ADC Input

82

4.3.5 LCD Output Display 86

4.4 Firmware Analysis 87

4.4.1 Serial Interface 87

4.5 Subsumtion 88

5 CONCLUSION AND

RECOMMENDATION

88

5.1 Conclusion 88

5.2 Recommendation 88

REFERENCE 93

APPENDICES 95

Page 12: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

LIST OF TABLE

NO TITLE PAGE

4.1 The output waveforms for power

supply circuit.

40

4.2 The capacitor selection for crystal

operation.

47

4.3 The RC oscillator component

selection

50

4.4 The OUTV result from the

experiment.

55

4.5 The measured value of output

voltage of LM35DZ.

57

4.6 The voltage supply to motor. 65

4.7 The motor operation. 66

4.8 The operation of H-Bridge. 68

4.9 LCD driver Pin out 71

Page 13: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

LIST OF FIGURE

NO TITLE PAGE

2.1 Wall-mounted control of ceiling fan 7

2.2 Pulled-chain of ceiling fan 8

2.3 Remote control of ceiling fan 9

2.4 The schematic diagram of (a) Transmitter

and (b) Receiver for Infra-red remote

control [27].

10

2.5 Hand-clapped control of ceiling fan 11

2.6 Microcomputer Architecture [2]. 13

2.7 Components of a typical full-featured

microcontroller

15

2.8 The pin diagram of PIC16F873

microcontroller

16

2.9 (a) Appearance and (b) Symbol of

LM35DZ.

18

3.1 The Automated PIC based Temperature

Control of Fan Speed Design and

Construction

22

3.2 The block diagram for PIC microcontroller

based fan.

25

3.3 The flow chart for hardware work process. 26

3.4 Illustration of automatic PIC based

temperature control of speed for ceiling fan.

29

3.5 The flowchart for the software development. 31

3.6 The process of the automatic ceiling fan 34

Page 14: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

process.

4.1 The schematic diagram of the

microcontroller based fan temperature

control system.

38

4.2 Block diagram of the microcontroller based

fan temperature control system.

39

4.3 The 5V and 12V power supply circuit. 40

4.4 Output voltage from 5V power supply

circuit.

42

4.5 Output voltage from 12V power supply

circuit.

43

4.6 The power supply block diagram. 43

4.7 The basic circuitry for Microchip

PIC16F876A microcontroller.

45

4.8 Crystal operation as clock oscillator. 47

4.9 The RC mode circuitry. 49

4.10 The reset circuit with external reset button. 51

4.11 The simple Reset circuit by using the Power

on Reset.

52

4.12 The temperature sensor (LM35) interface

with PIC16F876A.

53

4.13 Full-Range Centigrade Temperature Sensor. 54

4.14 The Temperature vs. Output Voltage Graph. 55

4.15 The schematic diagram of temperature

sensor (LM35) circuit.

56

4.16 The OUTV reading at room temperature. 56

4.17 The oscillating temperature sensor display. 57

4.18 The basic external drive circuit. 58

4.19 The operation of external equipment drives

circuit.

59

4.20 The transistor switch (a) cut-off open switch

(b) saturation-closed switch.

60

Page 15: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

4.21 The external drive circuit using optocoupler. 61

4.22 The motor drive circuit used in the

microcontroller based fan temperature

control system.

62

4.23 The simplified motor drive circuit. 63

4.24 Fan is operating at lower speed in Speed 1. 64

4.25 Fan is operating in Speed 2. 64

4.26 Fan is operating in Speed 3. 65

4.27 The connection of motor and relay. 66

4.28 The basic structure of an H-bridge. 67

4.29 The pin connection of L293B H-Bridge

Motor Driver.

68

4.30 The circuit diagram of LCD display. 69

4.31 LED as speed output display. 72

4.32 The 7 segment as output display for speed

and room temperature reading.

73

4.33 The flow chart of the overall software for

the microcontroller based fan temperature

control system.

74

4.34 The simulation to test the ADC

programming.

77

4.35 The flow chart for ADC programming. 77

4.36 The threshold for ADC input circuit

construct in PROTEUS 7.

80

4.37 The flowchart of combination of ADC with

LED output indicator.

81

4.38 The multiple thresholds for ADC input. 82

4.39 The flow chart for multiple output

indicators.

83

4.40 The actual requirement for the

microcontroller based fan temperature

control system.

85

4.41 The circuit diagram of RS232 with 87

Page 16: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

PIC16F876A.

5.1 The microcontroller based fan temperature

control system.

90

5.2 The more sophisticated microcontroller

based fan temperature control system.

91

Page 17: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

LIST OF ABBREVIATIONS

UTeM - Universiti Teknikal Malaysia Melaka

FYP - Final Year Project

PIC - Peripheral Interface Controller

PWM - Pulse Width Modulation

CCP - Capture/ Compare/ PWM

AC - Alternate Current

DC - Direct Current

IR - Infra-Red

VLSI - Very-Large-Scale-Integration

CPU - Central Processor Unit

I/O - Input/Output

IC - Integrated Circuit

RAM - Random Access Memory

ROM - Read Only Memory

A/D - Analog-To-Digital

D/A - Digital-To Analog

EPROM - Erasable Programmable Read-Only Memory

EEPROM - Electrically Erasable Programmable Read Only Memory

MCU - Microcontroller

SFR - Special Function Register

PWM - Pulse Width Modulation

LED - Light Emitting Diode

PC - Personal Computer

LCD - Liquid Crystal Display

ADC - Analog to Digital Converter

Page 18: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

EMF - Electromagnetic Field

NC - Normally Close

NO - Normally Open

VB - Visual Basic

TX - Transmit Data

RX - Received Data

RC - Resistor/capacitor

XT - ceramic resonator

HS - High speed crystal or ceramic resonator

LP - Low power crystal

POR - Power On Reset

RS - Register Selection

EN - Enable

R/W - Read write

DDRAM - Display Data Ram

Page 19: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

LIST OF APPENDICES

NO TITLE PAGE

A PIC16F876A Configuration 95

B Project Gantt Chart 97

C ADC Programming 99

D Threshold for ADC Input Programming 100

E Multiple Threshold for ADC Input

Programming

101

F The CCS C language programming

Automated PIC Microcontroller Based

Temperature Control Of Fan Speed Design

102

G The Hardware for the Automated PIC

Microcontroller Based Temperature

Control of Fan Speed Design

104

Page 20: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

CHAPTER 1

INTRODUCTION

1.1 Background

Electric fan is defined as a device used to produce airflow for the

purpose of creature comfort, ventilation, exhaust, or any other gaseous

transport. Meanwhile, a ceiling fan is a device suspended from the ceiling of a

room, which employs hub-mounted rotating paddles to circulate air in order to

produce a cooling or destratification effect. The first ceiling fans appeared in

the 1860s and 1870s, in the United States. At that juncture, they were not

powered by any form of electric motor. Instead, a stream of running water was

used, in conjunction with a turbine, to drive a system of belts which would turn

the blades of two-blade fan units. Afterwards, the electrically-powered ceiling

fan was invented in 1882 by Philip Diehl. Electric fans are designed to create a

breeze and circulate air in a room. A good fan can make a room feel 10-15

degrees cooler when used properly [26]. Electric fans are pretty simple in their

design and function. An electric motor spins the blades, which are shaped to

move air from the back of the fan out through the front of the fan. The

important parts of a ceiling fan are the electric motor, paddles or blades, down

rod and switches.

Page 21: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

Since a fan creates its cooling effect by speeding, thus, the most

important part of a fan is its speed controller. Electric fan come in a different

ways of operating method, that is depend on the manufactures and style. The

conventional fans are operated by pull-chain control or capacitor-stepped wall

control. In contemporary day nowadays, a luxurious feature offered on many

modern ceiling fans that speed is controlled by the hand-held wireless remote

control. These types of fan are typically has three or five of speed control.

Most ceiling fans sold in recent years have switch for turned the fan on and off

operation together with adjust the speed at which the blades rotate.

This invention relates to the field of devices for moving air in enclosed

spaces. More particularly it relates to an automatic PIC controlled fan. The PIC

microcontroller based ceiling fan is automatically switching the speed of fan

rotating according to the environment temperature changes. This project is as

further step for developing a smart home technology by fulfilling the

requirement of technologies “tomorrow will be more advanced than today”.

1.2 Problem Statement

Modern electronics has provided the consumer with the ability to

remotely control a variety of household appliances. However, there has not yet

been exploited with automatic control of ventilation devices, or more

particularly to the control of fan‟s speed.

In operation to control speed a fan, it is often necessary to physically

adjust the fan in order to increase the degree of ventilation provided, or

substantially change the direction of air flow. The ability to automatically

change the speed of fan via changes of surroundings temperature would allow

the user to feel comfort without physically to change the speed of fan.

The automatic control of this operation would further aid in the use of

such a fan by those who are sick, handicapped or elderly. Moreover, this

Page 22: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

device is very suitable to be used in extensive area, hospital and children‟s

room.

PIC microcontroller based ceiling fan is as further step to improve the

technology of a fan. This new invention will satisfy a person needs to make life

easier and better. All the mundane household chores are done without having

to think about those works.

1.3 Objectives

The aim of this project is to design a home automation system that is

ceiling fan based on the advanced technology without only using choke.

The main objectives are:

To design and develop a hardware and software of PIC

microcontroller based ceiling fan

To determine how PIC microcontroller based ceiling fan is

useful to all user

To identify the problem during use a PIC microcontroller based

ceiling fan

To analyse the output of the PIC microcontroller based ceiling

fan

1.4 Scope Of Project

This FYP project entitled “The Automated PIC Microcontroller Based

Temperature Control of Fan Speed Design” is divided into two parts: FYP 1

and 2. This project will be conducted throughout the final year of the

undergraduate program with FYP 1 and 2 conducted throughout the first and

second semester respectively.

Page 23: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

The emphasis is on the design, construction, development and analysis

for one of automation system that can be implemented at our home. Besides

that, the PIC microcontroller is also introduced in this report. The other aspect

such as maintenance and marketing will not be covered in this report.

1.5 Organization

This report is a progress report as the project “The Automated PIC

Microcontroller Based Temperature Control of Fan Speed Design” is a one

year project. Hence, this report basically reports and documents the process

and tasks accomplished through out FYP 1 and 2.

The organisation of this report is as follows: First, Chapter 1 describes

the background, problem statement objective and scope of the project. Second,

Chapter 2 presents the literature review for this project, analyse the information

about the article that related to the project design and discusses the advantages

and disadvantages of automatic PIC based temperature control of speed for a

ceiling fan. Next, Chapter 3 explains about methodology of the project; it

includes of material, project block diagram, flowchart and procedure of

automatic PIC based temperature control of speed for a ceiling fan.

Subsequently, Chapter 4 will be explains the result gets from doing this

project and analysis about hardware, software and firmware development that

adapted into this project. Conclusion about the project and recommendation

for future research for the project are stated in Chapter 5.

Page 24: The Automated PIC Microcontroller Based Temperature Control of Fan Speed Design - TJ233.P76 .N87 2009

CHAPTER 2

LITERATURE REVIEW

2.1 Preface

This chapter suppose explain the studies on paper or journal which

made by persons or those similar projects that has been undertaken by one

company. In this case there are no related journals and papers, thus, the

literature review that has been is based on the operation that related on the

speed variable for the conventional ceiling fan.

Apart from that, this chapter also contains study and information on

involved main components theory in implementing this project. This study is

conducted would be to ensure this project can be implemented smoothly and

orderly.

2.2 Temperature-Rated Electric Fan

Most of the common temperature-rated electric fans that exist in the

marketplace have largely been fitted with integrated circuit components as the

temperature control circuit. Some of the widely used temperature-control

components are pulse-rated fabrication technique that not only do not offer a

dependable temperature control effect but can produce excessive

electromagnetic noise at low cycles.