Você está na página 1de 83

USMAN INSTITUTE OF TECHNOLOGY

Hamdard University
Department of Electrical Engineering
Major In Computer System Engineering
Batch 2009

WIRELESS BASED ENERGY EFFICIENT


HVAC SYSTEM
BY
Bakht Sardar
Asad Inam
Sherzaman
Uzair Nawaz

(09B-032-CE)
(09B-002-CE)
(09B-011-CE)
(09B-027-CE)

Project Internal
Engr. Atif Fareed
(Assistant Professor)

ST-13, Block 7, Gulshan-e-Iqbal, Abul Hasan Isphahani Road, Opposite Safari Park, P.O.
Box 75300, Karachi, Pakistan.Phone: 34978274-5; 34994305; 34982476
http://www.uit.edu.pk

TABLE OF CONTENT
Sno.

CONTENT

Page No.

INTRODUCTION

1.0

Overview

1.1
1.2
1.3
1.4
1.5
1.6

Motivation
History
Project Objectives
Application of the project
Block Diagram
Flow Chart

1
2
3
4
5
6

SYSTEM EXPLANATION

2.0

Description Of Project
2.0.1 HVAC

7
7

2.0.2 Heating

2.0.3 Ventilation

2.0.4 Air conditioning

2.0.5 Power Management

2.0.6 Controls

2.1

System Explanation

2.2

System Working

2.3

Mechanical Part Of Project

10

2.4

Electronics Part Of Project

11

SYSTEM DESIGN

3.0

Mechanical Design

13

3.1.2 Air Portion Of The System


3.1.3 Introduction to Peltier Devices
3.2 Electronic Structure
3.3 Components Used In Project
3.4 PIC Introduction
3.3.1 PIC16F877A Features

14
15
16
16
17
18

3.3.1.1 High Speed RISC CPU

18

3.3.1.2 Peripheral Features

19

3.3.1.3 Analog Features

20

3.3.1.4 Special Microcontroller Features

20

3.3.1.5 CMOS Technology

21

3.3.1.6 PIN Diagram

22

3.3.1.7 Comparison Of PIC

22

3.4 Temperature Sensor Introduction


3.4.1 LM35 Temperature Sensor
3.4.1.1

Features

3.5 Humidity Sensor Introduction


3.5.1 Humidity Sensor HS-1101
3.5.1.1 Features

23
23
24
25
26
26

3.6 SPDT Relays

27

3.7 Thermostat

28

3.8 IR Sensor

28

3.9 Valve Controlled DC Motor

29

3.9.1 Brushed DC Motor

29

3.9.2 Brushless DC Motor

30

3.10 LDR Introduction

30

3.11 LCD

31

3.12 User Interface

32

3.12.1 Professional User Interface

32

3.12.2 Occupant User Interface

33

BMS

4.0 BMS

34

4.1 BMS Architecture

35

4.2 Service Level

35

4.3 Management Level

36

4.4 Control level

37

4.5 Major Components Of BMS

37

4.5.1 HVAC

37

4.5.2 Power Management

37

4.6 HVAC System

38

4.6.1 Heating

38

4.6.2 Ventilation

38

4.6.3 Air Conditioning

39

CIRCUIT, SIMULATION & PCB

5.0 Circuit Diagram

40

5.1 RF Module Schematic

41

5.2 IR Proximity Sensor Schematic

42

SOFTWARE

6.0 Microcontroller Programming (MPLABXIDE)

43

6.1 Software For GUI

45

6.2 ORCAD

46

6.2.1 Orcad Capture

47

6.2.2 Features and Capabilities

48

REAL HARDWARE PICTURES

7.0

PIC Board

49

7.1

Other Pictures

49

7.2

Overall System

50

CONCLUSION

8.0 Conclusion

51

8.1 Future Enhancement

51

APPENDIX A

CODING

52

APPENDIX B

DATASHEETS

65

DEDICATION
We dedicate this report to our

Parents and teachers

Their love, guidance and support helped us to accomplish our project work. We are grateful
to them for their valuable time and their support for provide us everything that we needed
regarding the project accomplishment.

ACKNOWLEDGEMENT

We dedicate our endeavor to Allah by whom it was possible to begin this project, continue
this project and to end this project.
We would also like to thanks Engr.Atif fareed,our project supervisor and internal who helped
us out a great deal through out our project development up till now we hope that the cooperation would remain till the end of the project submission.we would also like to thank all
the other course instructor who imparted their technical knowledge to us in a most benefiting
manner,which not only enable us to learn about the different programming tools and
electronic devices, but also make sure that what ever knowledge they provided would be
beneficial for us and for the completion of our final year project in the given course of time.

ABSTRACT

The Intelligent HVAC System will control Heating, Ventilating, and Air Conditioning
(HVAC) of a residence. The project will consist of two modules that can be easily added to a
homes existing HVAC system. The Central Thermostat Unit (CTU) will control the general
heat, air conditioning, and fan levels of the residence and communicate wirelessly to one or
more Individual Room Controllers (IRC). Users can set their desired room temperatures with
a simple user interface, and the Individual Room Controllers will adjust vent openings to
meet the users comfort levels. The project will be demonstrated by simulating temperature
conditions (with compressed air and a hair dryer). LEDs will be used to display the CTUs
operation and the IRC will control standard-sized

CHAPTER 1
INTRODUCTION

1.0

OVERVIEW

Heating, ventilation, and air conditioning commonly known as HVAC are a


Fundamental consideration when designing for comfort. The efficient design of
HVAC services not only increases the occupants sense of well-being, it can also
create considerable savings in building operation costs.
The running of HVAC services will be most efficient when pipes and ducts are
insulated.
This will:
Reduce energy costs, prevent condensation and freezing
Provide thermal insulation
As we all know our country Pakistan is facing the energy problem, because of
that common men and as well as industries and companies have to face problem
of load shedding, due to this Pakistan is lacking behind even the third world
countries. We can reduce this problem by making the use of energy in an
intelligent way and this can be done by Power Management and Energy Saving
systems.

1.1 MOTIVATION
All Buildings have some form of mechanical and electrical services in order to
provide the facilities necessary for maintaining a comfortable working
environment. These services have to be controlled by some means to ensure, for
example, that there is adequate hot water for sinks, that the hot water in the
radiators is sufficient to keep an occupied space warm, that heating with
ventilation and possibly cooling is provided to ensure comfort conditions
wherever, irrespective of the number of occupants or individual preferences.
Basic controls take the form of manual switching, time clocks or temperature
switches that provide the on and off signals for enabling pumps, fans or valves
etc.
1

So, We decided to make such a system more effective in one of the major aspect
of daily life so we focused on power saving and load management as our
country is going through the power crisis nowadays.

1.2 HISTORY
The HVAC industry ongoing using Scotch Maine type boilers with oil and gas
burners and induces or strained type fans were used. A system which brings
downward the temperature to 10 degree Fahrenheit but increase the humidity to
rough levels was made. The Rational Psychometric Formulae for elemental
calculations was made-up. A forced air system which uses a fan was made. The
first centrifugal refrigeration mechanism was made for air conditioning large
spaces. The three main functions of the HVAC system, heating, ventilation, and
air conditioning, is interconnected in that all seek to provide thermal reassure,
adequate air quality and reasonable putting in place, operation and maintenance
costs. These aspects honestly affect the quality of the air in your working area.
Poor air superiority unconstructively affects the health of workers.
Pumps and radiators started to be used in the air conditioning systems for
circulating water in the system. The first refrigeration with a compressor was
completed. The first suburban air conditioning was made. Room coolers that use
the technology of the refrigerators were made. Panels for heating floors and
ceilings started to be made. The first man walks on moon with life support and
cooling systems.

1.3 PROJECT OBJECTIVES


The HVAC industry ongoing using Scotch Maine type boilers with oil and gas
burners and induces or strained type fans were used. A system which brings
downward the temperature to 10 degree Fahrenheit but increase the humidity to
rough levels was made. The Rational Psychometric Formulae for elemental
calculations was made-up. A forced air system which uses a fan was made. The
first centrifugal refrigeration mechanism was made for air conditioning large
spaces. The three main functions of the HVAC system, heating, ventilation, and
air conditioning, is interconnected in that all seek to provide thermal reassure,
adequate air quality and reasonable putting in place, operation and maintenance
costs. These aspects honestly affect the quality of the air in your working area.
Poor air superiority unconstructively affects the health of workers.
Pumps and radiators started to be used in the air conditioning systems for
circulating water in the system. The first refrigeration with a compressor was
completed. The first suburban air conditioning was made. Room coolers that use
the technology of the refrigerators were made. Panels for heating floors and
ceilings started to be made. The first man walks on moon with life support and
cooling systems.

1.4 APPLICATION OF THE PROJECT


We can apply this project in buildings, malls, hospitals, schools, etc.
This type of system can also be installed in submarines and ships.
HVAC is sometimes referred to as climate control and is predominantly
important in the structure of most industrial and office buildings, and in
marine environments such as aquariums, where humidity and temperature
must all be closely synchronized even as maintaining safe and healthy

conditions within.
It can be used in banks
The system is also very feasible in multi-national companies offices
This can also be implemented in universities
With few alterations this system is also very good for concept of modern

automated houses.
It can be used for server rooms
It can be used in hospitals.
Can be a part of five star hotels.

1.5 BLOCK DIAGRAM


BLOCK DIAGRAM HVAC

Diagram For Control Room

RF Tranceiver
Module

Diagram for Room 1 & 2

Peltier
Device

IR
Sensor

Computer
Software

LCD
Display
PIC
Micro
Controller
RELAY
outputs

Limit
Switch

Room Temp
Other Inputs

RF Tranceiver
Module

1.6 FLOW CHART

CHAPTER 2
SYSTEM EXPLANATION

2.0 DESCRIPTION OF PROJECT


2.0.1 HVAC
HVAC (Heating, Ventilating, and Air Conditioning) refers to technology of
indoor or automotive environmental comfort. HVAC systems

senses

temperature and maintains the temperature of the particular place accordingly,


and the feature of this system is that it is being controlled with the concept of
PID(ProportionalIntegralDerivative) and automated by MASTER-SLAVE
configuration and all the parameters of the systems would be displayed on
screen and can easily be controlled through it.

2.0.2 HEATING
In central location the system contains the boiler or air. To distribute the air, the
system contains either ductwork or piping to share out required air or heated
liquor respectively. In boiler fed or beaming heating systems, most have a pump
to circulate the water to make sure an equal supply of heat to the radiators.
Forced air systems send heat through ductwork, which can also be used for airconditioning.

2.0.3 VENTILATION
Ventilating is the progression of replacing air in any space to organize the
temperature or remove wetness, odor, heat, dust and above ground bacteria.
Ventilation includes both the exchange of air to the outer surface as well as the
circulation of air within the structure. This characteristic of the system is
dependable for maintaining acceptable indoor air worth.

2.0.4 AIR CONDITIONING


Air conditioning is the process by which heat is uninvolved from the air, which
can be done through radiation, convection and conduction. These processes use
medium such as water, ice, air and chemicals that are referred to as refrigerants.
Typically, air conditioning systems provide cooling, ventilation and humidity
control for all or part of a structure.

2.0.5 POWER MANAGEMENT


Power management is a quality of some electrical appliance that turns off the
power or switches the system to a low-power state when stationary. In
computing this is known as PC power management and is built around a
standard called ACPI (Advanced configuration and power interference). This
supersedes APM (Advanced power management). All recent (consumer) have
ACPI maintain.
ACPI: the Advanced Configuration and Power Interface (ACPI) specification
provides an open standard for device arrangement and power management by
the operating system.

2.0.6 CONTROLS
All systems may be operated by manual operation of the appropriate electrical
switches or fully automatic operation is also available using appropriate control
panels and system to control the recirculation mode, temperature or any other
parameters.

2.1 SYSTEM EXPLANATION


In this system all the variables that is temperature, air flow, humidity level,
smoke detection, presence detection in specified area and power management
would be monitored and controlled. In order to bring thermal comfort
conditions, temperature is set by the user with the help of thermostat. The
sensors would give electrical signals which would be processed through the
software programmed and the output in turn would operate the valve
proportionally, placed in the ducts which in turn controls the air flow and
maintains the required temperature conditions. There is also a power
management feature which provides the use of energy in efficient manner by
bringing power loads into inactive mode when they are not in use.

2.2 SYSTEM WORKING


To maintain proper control of the process the variables involved should always
be monitored. The temperature, humidity level, smoke detection, air flow,
power management and presence detection are screened by sensors at all times.
The data from the sensors are obtained and readable by input ports of their local
controls. The input is then processed by the software and necessary adjustments,
resulting either from these readings or a pre-specified schedule, are made. These
adjustments appear at output ports as electrical signals. Thus the whole system
works as the combination of sensors sending input signals to the local controls
and then to a master control and valves been operated via an output based on
processing of the software and the set of programs fed into the local control of
each location.

2.3 MECHANICAL PART OF PROJECT

The intention of an HVAC (heating, ventilating, and air-conditioning) system is


to manage the temperature, humidity, air movement, and air cleanliness,
normally with mechanical means, to achieve thermal reassure.
Centralized HVAC system installations utilize a number of separate components
that are field assembled to serve the specific needs of an individual building.
A central plant has 3 principle elements:
Service Generators (e.g. boilers, chillers);

Distribution Mechanism (e.g. air distribution ducts, pipes);

Delivery Apparatus (e.g. diffusers, radiators).

10

Distribution components communicate a heating or cooling standard from


source-located service generators to portion of a building that requires
conditioning. Delivery apparatus serve as an interface between the distribution
system and occupied spaces

11

2.4 ELECTRONIC PART OF THE PROJECT

12

The figure is a complete block diagram of a single unit of a project. This is a


single local control of a project. In this project four local controls are available
in order to monitor and control four different locations. Each local control is
connected to a master control unit which is connected to a BOS (building
operating system) through nRF24L01 module to control and monitor the on
field conditions, as mentioned in the figure. There is also a LCD which displays
the on field parameters to the field worker in order to avoid any unusual
condition.

13

CHAPTER 3
SYSTEM DESIGN

3.0 MECHANICAL DESIGN


The success of a building depends on the ability to provide thermal comfort
with the least operating costs (maintenance, energy, or replacement). This
depends on the HVAC system design, equipment and controls.
As far as system design is concern we use HVAC system in a DISTRIBUTED
SYSTEM manner, in which centralized system is consist of AIR SYSTEM
(moderate ducting) and terminal unit is consist of FAN COILS. Air Systems
deliver a combination of heated/cooled air to control aspects of comfort.
In an Air system air is used for providing required conditions in the
conditioned space. The air is cool or heat in a central plant. The complete
system consists of a central plant for cooling or heating of air, ducting system
with fans for conveying air, water pipelines and a room terminal. The room
terminal may be in the form of a fan coil unit, an induction unit or a radiation
panel. Figure below shows the schematic of a basic air system.

The latent energy primarily from outside air is removed in a dedicated air
handling unit, which distributes conditioned air for ventilation and
pressurization to indoor space.

13

3.1 ELECTRONIC STRUCTURE


The electronic structure of this project includes various electronic equipments.
They include various sensors to sense

Temperature
Presence
Humidity
Smoke

There is PIC microcontrollers used which is used in controlling the project, the
project also include motors, relay and various types of ICs. The project is also
using a wireless communication protocol which is the nRF24L01 protocol
which is used to take data to the GUI (graphical user interface).

3.2 COMPONENTS USED IN PROJECT

PIC microcontroller (16F877A)


LM 35 temperature sensor
Humidity Sensor HS-1101
SPDT Relay
IR Sensor
Motors
ICs
LCD

3.3 PIC INTRODUCTION


PIC microcontroller from microchip are very popular microcontroller. PICs are
easily programmable cheap microcontroller. PICs is the name for the microchip
microcontroller family (peripheral interface controller). Consisting of a
microprocessor, I/O ports, timer(s), and other internal integrated hardware. a
16

wide range of chip sizes( from eight-pin up), great availability of compilers and
source code and easy programming. Flash-type devices are re-programmable incircuit, while OTP versions are very cheap to use at the final stage. PICmicro
chips have a Harvard architecture, and instruction words are unusual sizes.
Originally, 12-bit instructions included 5 address bits to specify the memory
operand, and 9-bit branch destinations. Later revisions added opcode bits,
allowing additional address bits.There are many different varieties of PICs that
run at many frequencies, have different memory size, and different internal
peripherals. The most famous MCU that microchip produces are:
12cxxx,12fxxx,16cxxx,16fxxx and 18fxxx.
Prefix 12 is for chips with 8 pins.
Prefix 16 is for 14-bit core chip with more than 8 pins.
Prefix 18 is for 16-bit core chip.
The letter after number tells the memory type:
C is for EPROM (OTP)
F is for flash chips
The number (2 or 3 digits) after this letter identifies specific chip version.
Improved new version of certain PICs types are identified by appending
an (A)

3.3.1 PIC 16F877A FEATURES


17

It is high-performance; enhance PIC Flash microcontroller in 40-pin DIP. The


PIC16F877A CMOS FLASH-based 8-bit microcontroller is upward compatible
with the PIC16C5x, PIC12Cxxx and PIC16C7x devices. It features 200 ns
instruction execution, 256 bytes of EEPROM data memory, self programming,
an ICD, 2 Comparators, 8 channels of 10-bit Analog-to-Digital (A/D) converter,
2 capture/compare/PWM functions, a synchronous serial port that can be
configured as either 3-wire SPI or 2-wire I2C bus, a USART, and a Parallel
Slave Port.0.
The deeper description is given as below:

3.3.1.1 HIGH-PERFORMANCE RISC CPU


Only 35 single-word instructions to learn
All single-cycle instructions except for program Branches, which are twocycle
Operating speed: DC 20 MHz clock input DC 200 ns instruction cycle
Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data
Memory (RAM), Up to 256 x 8 bytes of EEPROM Data Memory
Pin out compatible to other 28-pin or 40/44-pin PIC16CXXX and
PIC16FXXX microcontrollers

3.3.1.2 PERIPHERAL FEATURES


Timer0: 8-bit timer/counter with 8-bit prescaler

18

Timer1: 16-bit timer/counter with prescaler, can be incremented during Sleep


via external crystal/clock
Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
Two Capture, Compare, PWM modules
- Capture is 16-bit, max. Resolution is 12.5 ns
- Compare is 16-bit, max. Resolution is 200 ns
- PWM max. Resolution is 10-bit
Synchronous Serial Port (SSP) with SPI (Master mode) and I2C
(Master/Slave)
Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI)
with 9-bit address detection
Parallel Slave Port (PSP) 8 bits wide with external RD, WR and CS controls
(40/44-pin only)
Brown-out detection circuitry for Brown-out Reset (BOR)

3.3.1.3 ANALOG FEATURES


10-bit, up to 8-channel Analog-to-Digital Converter (A/D)
Brown-out Reset (BOR)
Analog Comparator module with:
- Two analog comparators
- Programmable on-chip voltage reference (VREF) module
19

- Programmable input multiplexing from device inputs and internal voltage


reference
- Comparator outputs are externally accessible

3.3.1.4 SPECIAL MICROCONTROLLER FEATURES


100,000 erase/write cycle Enhanced Flash program memory typical
1,000,000 erase/write cycle Data EEPROM memory typical
Data EEPROM Retention > 40 years
Self-reprogrammable under software control
In-Circuit Serial Programming (ICSP) via two pins
Single-supply 5V In-Circuit Serial Programming
Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable
operation
Programmable code protection
Power saving Sleep mode
Selectable oscillator options
In-Circuit Debug (ICD) via two pins.
3.3.1.5 CMOS TECHNOLOGY:
Low-power, high-speed Flash/EEPROM technology
Fully static design
Wide operating voltage range (2.0V to 5.5V)
Commercial and Industrial temperature ranges
Low-power consumption
20

3.3.1.6 PIN DIAGRAM

3.3.1.7 COMPARISON OF MICROCONTROLLERS

Controller

Controller 8051

PIC16f877A

PIC 18f452

AVR
Atmega328

Operating
Voltage Volts

2.7 5.5

2.0 5.5

2.0 5.5

1.8 5.5

10bit
(8 channel)

10bit
(8 channel)

10bit
(8 channel)

10bit
(8 channel)

Flash Memory
(K bytes)

32

32

Pin
Configuration

40

40

40

28

ADC

21

PIC16F877A is the best choice for our project considering our needs,cost
effectiveness and easy availability.

3.4 TEMPERATURE SENSORS INTRODUCTION


Temperature sensors are vital to a variety of everyday products. For example,
household ovens, refrigerators, and thermostats all rely on temperature
maintenance and control in order to function properly. Temperature control also
has applications in chemical engineering. Examples of this include maintaining
the temperature of a chemical reactor at the ideal set-point, monitoring the
temperature of a possible runaway reaction to ensure the safety of employees,
and maintaining the temperature of streams released to the environment to
minimize harmful environmental impact.
While temperature is generally sensed by humans as hot, neutral, or cold,
chemical

engineering

requires

precise,

quantitative

measurements

of

temperature in order to accurately control a process. This is achieved through


the use of temperature sensors, and temperature regulators which process the
signals they receive from sensors.
From a thermodynamics perspective, temperature changes as a function of the
average energy of molecular movement. As heat is added to a system, molecular
motion increases and the system experiences an increase in temperature. It is
difficult, however, to directly measure the energy of molecular movement, so
temperature sensors are generally designed to measure a property which
changes in response to temperature. The devices are then calibrated to
traditional temperature scales using a standard (i.e. the boiling point of water at
known pressure).

3.4.1 LM35 TEMPERATURE SENSOR


22

The LM35 series are precision integrated-circuit temperature sensors, whose


output voltage is linearly proportional to the Celsius (Centigrade) temperature.
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 14C at room
temperature and 34C over a full 55 to +150C temperature range. Low cost
is assured by trimming and calibration at the wafer level. The LM35s 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.1C in still air. The
LM35 is rated to operate over a 55 to +150C temperature range, while the
LM35C is rated for a 40 to +110C range (10 with improved accuracy). The
LM35 series is available packaged in hermetic TO-46 transistor packages, while
the LM35C, LM35CA, and LM35D are also available in the plastic TO-92
transistor package. The LM35D is also available in an 8-lead surface mount
small outline package and a plastic TO-220 package.

3.4.1.1 FEATURES
Calibrated directly in Celsius (Centigrade)
Linear + 10.0 mV/C scale factor
0.5C accuracy guarantee able (at +25C)
23

Rated for full 55 to +150C range


Suitable for remote applications
Low cost due to wafer-level trimming
Operates from 4 to 30 volts
Less than 60 A current drain
Low self-heating, 0.08C in still air
Nonlinearity only 14C typical
Low impedance output, 0.1 for 1 mA load

3.5 HUMIDITY SENSOR INTRODUCTION


Humidity is one of the most frequently measured quantities in different fields,
such as industrial processing, agricultural, climate research, pharmaceutical
engineering, etc. A humidity sensor is a device used to measure the humidity of
air or any gas in a given area. It can be used in both indoors and outdoors. The
humidity sensor is able to assists people in daily life in an invisible way. For
example, to prevent the paper jam problem, the inside humidity sensor would
detect the relative humidity at first, then the microchip would determine
whether to warm up the printer to reduce the water vapour. The amount of water
vapor in the atmosphere determines humidity. The humidity plays an important
24

role in the numerous measurement situations. Hygrometry is in fact a branch of


applied physics in which the multitude of techniques is an indication of the
complexity of the problem, and of the fact that no one solution will meet all
requirements at all times and in all places. Nowadays, there are many different
types of humidity sensor to be set in various fields. To fabricate a ideal humidity
sensor is a tough task due to the complex requirements. The ideal humidity
sensor should have some characteristics:
(1) suitable for wide temperature
(2)wide humidity range
(3)long-life usage
(4)good stability
(5)fast response speed
(6) suitable in the harsh environments.
To achieve these requirements, the materials chemistry and microcircuit field
contribute numerous effects. In recent years, the almost market share of
humidity sensor is consists of capacitive humidity sensor.

3.5.1 HUMIDITY SENSOR HS-1101


Based on a unique capacitive cell, these relative humidity sensors are designed
for high volume, cost sensitive applications such as office automation,
automotive cabin air control, home appliances, and industrial process control
systems. They are also useful in all applications where humidity compensation
is needed.

25

3.5.1.1 FEATURES:
Full interchangeability with no calibration required in standard conditions
Instantaneous de-saturation after long periods in saturation phase
Compatible with automatized assembly processes, including wave soldering,
reflow and water immersion
High reliability and long term stability
Patented solid polymer structure
Suitable for linear voltage or frequency output circuitry
Fast response time
Individual marking for compliance to stringent traceability requirements.

3.6 SPDT RELAYS


(Single Pole Double Throw Relay) an electromagnetic switch, consist of a coil
(terminals 85 & 86), 1 common terminal (30), 1 normally closed terminal (87a),
and one normally open terminal (87) in FIGURE 1.13.

26

When the coil of an SPDT relay (FIGURE 1.6) is at rest (not energized), the
common terminal (30) and the normally closed terminal (87a) have continuity.
When the coil is energized, the common terminal (30) and the normally open
terminal (87) have continuity.
The diagram below center (Figure 2) shows an SPDT relay at rest, with the coil
not energized. The diagram below right (Figure 3) shows the relay with the coil
energized. As you can see, the coil is an electromagnet that causes the arm that
is always connected to the common (30) to pivot when energized whereby
contact is broken from the normally closed terminal (87a) and made with the
normally open terminal (87).
When energizing the coil of a relay, polarity of the coil does not matter unless
there is a diode across the coil. If a diode is not present, you may attach positive
voltage to either terminal of the coil and negative voltage to the other, otherwise
you must connect positive to the side of the coil that the cathode side (side with
stripe) of the diode is connected and negative to side of the coil that the anode
side of the diode is connected.

FIGURE 1.13

3.7 THERMOSTAT
A thermostat is

the component of

a control

system which

regulates

the temperature of a system so that the system's temperature is maintained near


a desired set point temperature. The thermostat does this by switching heating or
cooling devices on or off, or regulating the flow of a heat transfer fluid as
27

needed, to maintain the correct temperature. The name is derived from the
Greek words thermos "hot" and statos "a standing".
A thermostat may be a control unit for a heating or cooling system or a
component part of a heater or air conditioner. Thermostats can be constructed in
many ways and may use a variety of sensors to measure the temperature. The
output of the sensor then controls the heating or cooling apparatus.

3.8 IR SENSOR
A passive infrared sensor (PIR sensor) is an electronic sensor that measures
infrared (IR) light radiating from objects in its field of view. All objects above
absolute zero emit heat energy in the form of infrared radiation (infrared light).
Usually infrared light is invisible to the human eye. Infrared radiation enters
through the front of the sensor, known as the 'sensor face'. At the core of a PIR
sensor is a solid state sensor or set of sensors, made from pyroelectric materials
materials which generate energy when exposed to heat. Strictly speaking,
individual PIR sensors do not detect motion; rather, they detect abrupt changes
in temperature at a given point. As an object, such as a human, passes in front of
the background, such as a wall, the temperature at that point will rise from room
temperature to body temperature, and then back again. This quick change
triggers the detection. Moving objects of identical temperature will not trigger
detection.

28

3.9 VALVE CONTROLLED DC MOTOR


A DC motor is an electric motor that runs on direct current (DC) electricity.

3.9.1 BRUSHED DC MOTOR:


The brushed DC electric motor generates torque directly from DC power
supplied to the motor by using internal commutation, stationary magnets
(permanent or electromagnets), and rotating electrical magnets.
Like all electric motors or generators, torque is produced by the principle
of Lorentz force, which states that any current-carrying conductor placed within
an external magnetic field experiences a torque or force known as Lorentz
force. Advantages of a brushed DC motor include low initial cost, high
reliability, and simple control of motor speed. Disadvantages are high
maintenance and low life-span for high intensity uses. Maintenance involves
regularly replacing the brushes and springs which carry the electric current.
These components are necessary for transferring electrical power from outside
the motor to the spinning wire windings of the rotor inside the motor.

29

3.9.2 BRUSHLESS DC MOTOR:


Brushless DC motors use a rotating permanent magnet or soft magnetic core in
the rotor, and stationary electrical magnets on the motor housing. A motor
controller converts DC to AC. This design is simpler than that of brushed
motors because it eliminates the complication of transferring power from
outside the motor to the spinning rotor. Advantages of brushless motors include
long life span, little or no maintenance, and high efficiency. Disadvantages
include high initial cost, and more complicated motor speed controllers. Some
such brushless motors are sometimes referred to as "synchronous motors"
although they have no external power supply to be synchronized with, as would
be the case with normal AC synchronous motors.

3.10 LDR INTRODUCTION


A light dependent resistor alternatively called

an LDR, Photoresistor

or photocell, is a variable resistor whose value decreases with increasing


incident light intensity.
An LDR is made of a high-resistance semiconductor, often cadmium-sulfide. If
light falling on the device is of high enough frequency, photons absorbed by the
semiconductor give bound electrons enough energy to jump into the conduction
band. The resulting free electron (and its hole partner) conduct electricity,
thereby lowering resistance.
A photoelectric device can be either intrinsic or extrinsic. In intrinsic devices,
the only available electrons are in the valence band, and hence the photon must
have enough energy to excite the electron across the entire bandgap. Extrinsic
devices have impurities added, which have a ground state energy closer to the
conduction band - since the electrons don't have as far to jump, lower energy
photons (i.e. longer wavelengths and lower frequencies) are sufficient to trigger
the device.
30

Two of its earliest applications were as part of smoke and fire detection systems
and camera light meters. Because cadmium sulfide cells are inexpensive and
widely available,LDRs are still used in electronic devices that need light
detection capability, such as security alarms, street lamps, and clock radios

3.11 LCD
A liquid crystal display (LCD) is a flat panel display, electronic visual
display, video display that uses the light modulating properties of liquid
crystals(LCs). LCDs does not emit light directly. We are using 16*2 LCD for
temperature & humidity display.

31

3.12 USER INTERFACES


Systems shall be accessed through the Building Operating System (BOS).
System must have two main user interface types:
Professional user interface
Occupant user interface.

3.12.1 PROFESSIONAL USER INTERFACE


The system shall enable a client-based User Interface for professional usage and
for central monitoring of systems (Service Center usage). The professional User
Interface shall allow for at least the following:
Alarm monitoring and alarm handling by multiple operators
Intruder alarms
Fire alarms
Alarms from electrical and mechanical systems
System maintenance alarms
Video monitoring
Set point adjustment
Control optimization
Remote diagnostics of system/devices
Preventive maintenance
Consumption reports for energy management
Logs and reporting
Access rights management

32

The professional User Interface shall be implemented as a client application,


which includes an automatically adapting tree structure of the building,
buildings parts, individual spaces, different systems and parts of systems. The
tree structure can be used for navigation through the system. All systems
connected to Building Operating System can be accessed through the same
graphical User Interface.
The professional User Interface shall show system views, floor plan views,
trend view, alarm view and event log view per building and system layer. Any
alarm shall be shown in red color in both graphical views and tree structure.
Each alarm message shall include shortcut to relevant graphical system and
floor plan view.

3.12.2 OCCUPANT USER INTERFACE


The browser-based occupant User Interface shall be generated automatically
using the structure of the building defined in the Building Information Model.
The user interfaces shall provide easy access to frequently needed functionality,
such as lighting controls, temperature set point modifications, alarms, and
configuration of scenes and modes of the space. The same user interface
functionality shall be usable through any device with a browser.
The browser-based occupant User Interface shall allow for at least the following
actions:
Changing the mode of the space
Modifying the mode settings of the controlled devices
Changing the set points
Modifying the control settings
Manual controls
Camera views
33

Alarm list browsing

34

CHAPTER 4
BUILDING MANAGEMENT SYSTEM

4.0 BMS (Building Management System)


A building automation (BA) management system allows a building manager to
better handle his/her resources, improving operational efficiency and reducing
costs in control room. With today`s data communication technology and
sophisticated computer software, an intelligent building can be managed and
monitored centrally through a computerized building management system. It
supports the resilience and security of the facility and manages and monitors
core aspects of each facility, from power supply, temperature, and humidity,
fire, access and security. These systems also have.

Heating and Ventilation Control


Chillers
Boilers
Fire alarms
Monitoring system
Visual monitoring equipment

All of the building sub systems can be tied together. Such a holistic approach
allows us to average existing sub systems as we add new ones for all the
building automation needs.

4.1 BMS ARCHITECTURE


34

The system shall be implemented as an integrated, open solution, which enables


Service Center Connectivity through standard Building Operating System
(BOS) interface.
The System Architecture shall consist of four levels:
Service Level
Management Level
Control Level
Field Level
The system shall be completely modular in structure and freely expandable at
any stage. Each level of the system shall operate independently of the next level
up as specified in the system architecture. For example, Control Level shall
operate independently without support from Management Level.

4.2 SERVICE LEVEL


Service Level shall allow the systems to be connected without additional
software to one or several Service Center(s), for providing centralized remote
monitoring, alarm and fault detection of connected building management and
security systems. The Service Center shall be capable of accessing remotely the
systems through a standard interface through the BOS platform. The standard
connectivity shall enable providing advanced maintenance and security
services, such as security alarm monitoring, maintenance alarm monitoring,
remote diagnostics, main user capability, remote control and optimization of all
systems, energy optimization, trending and reporting services.
The Service Center shall support connectivity of multiple sites in multi-operator
environment. Predefined alarms from connected sites e.g. intruder alarms,
dirty filter notifications or leakage alarms, for example shall appear in the
alarm list with a specified priority. Alarms shall be stored in the central
database.
35

Remote diagnostics of site systems and devices shall enable proactive


maintenance of technical Systems, energy optimization and efficient
management of the infrastructure. Centralized monitoring of all connected sites
with main user capability shall enable e.g. set point changes, manual controls
and camera controls by using the remote connection.

4.3 MANAGEMENT LEVEL


Management Level shall provide a uniform view to all systems through the
open Building Operating System (BOS) platform. All the systems - controls of
cooling, ventilation and lighting, consumption measurements, access controls,
intruder alarms, fire alarms shall be integrated with the BOS using device
drivers.
The BOS shall offer at least the following common services to be used by all
connected systems:
Alarms
Historical trending
Logs and reporting
User profile and role management
To ensure fault-tolerant system functionality, the Management Layer shall not
be responsible for any controls. The critical control functionality is taken care of
by the intelligence on the Control Layer. The Management Layer shall provide
standard connectivity through the BOS platform with the Service Level, with
capability to support very advanced maintenance and security services. The
BOS software shall also be capable of acting as a gateway between systems
conveying messages.

4.4 CONTROL LEVEL


36

The Control Level shall consist of a distributed network of smart controllers,


which communicate to each other using MASTER-SLAVE configuration. The
controllers shall include all the intelligence of the system. All communication
shall be event based real-time peer-to-peer communication. All controllers shall
be capable of operating autonomously independently of Management Layer. For
example, all systems react to alarms on the Control Layer without interference
from upper layers. Each automation controller shall be capable of handling
several different systems in parallel through flexible distribution of I/O points.
Controllers shall utilize nRF24L01 (RF Module) connection between the
network controller and the interface panels.

4.5 MAJOR COMPONENTS OF BMS


4.5.1 HVAC
Intelligent zone valves, ducts, pumps, air-conditioners, ventilators allow
multiple zones and setbacks. Easy installation, reconfiguration, remote
diagnostics, and instant response to actual building conditions all enable better
energy management resulting in lower cost, reduced environmental impact and
better comfort control.

4.5.2 POWER MANAGEMENT


Power management is a feature of some electrical appliances, that turns off the
power or switches the system to a low-power state when inactive. In computing
this is known as PC power management and is built around a standard
called ACPI

(Advanced

configuration

and

power

interference).

This

supersedes APM (Advanced power management). All recent (consumer) have


ACPI support.

37

ACPI: the Advanced Configuration and Power Interface (ACPI) specification


provides an open standard for device configuration and power management by
the operating system.

4.6 HEATING VENTILATION AIR CONDIDTIONING


SYSTEM
The HVAC systems represented the greater part of the mechanical systems
automation tasks. These systems consist of air-handling units, refrigeration
equipment and systems providing called and hot water. The volume of air is
controlled by means of variable frequency drive (VFD) control of valves. All
enable better energy management resulting in lower costs, reduced
environmental impact and better comfort control.

4.6.1 HEATING
Heating is the process of adding heat energy causing a rise in temperature, or a
transfer of sensible heat into latent heat. Heating can take different forms
including electric and gas space heating, regenerative heating and
thermodynamic (reverse cycle) heating. A heating system transfer heat from a
source of energy through a distribution network to spaces to be heated. These
systems include central heating, direct-heating, direct-return; down-feed heating
and dry return heating systems.

4.6.2 VENTILATION
Ventilation is the process of supplying or removing air by natural or mechanical
means to or from any space. Such air may or may not have been conditioned
38

4.6.3 AIR CONDITIONING


The air conditioning process represents the combined treatment of the air in
enclosed spaces to control, as specified, temperature, relative humidity. Some
partial air conditioners that may not accomplish all of these controls are selected
for their capability to control specific phase for air treatment. Air conditioning
systems include Air-Water, central fan, cooling/heating, variable air flow and
modular air conditioning systems.

39

CHAPTER 5
CIRCUITS, PCB & SIMULATION

5.0 CIRCUIT DIAGRAM

T1O U T

LM 7805
9
10

104

1000 uf 25V

S u p p ly

8
7
1

1K

+5V

10uf
3

10K

C 2+

R 2 IN
T2O U T
C 1+

C 1-

13

Flame
Detector

10uf
C 2-

100K

+ 3

FLM

TO R F

LM 393

4K7

1
2
3

+12V

- 2

10K

LD R

+5V

2
V+ 6
V-

+12V

10uf
10uf

15

+5V

+12V

1K

LM 393

D3
D2
D1
D0
EN
RS
+5V

31
12
+5V

IN 4 007

R LY 1 TO 2

C 945A

FLM

+12V

C 945A

+5V

4 .7 K

L IM 1 T O 3

BUZ
BU ZZER

C 945A

+12V

LED

100R

28
29
30

R ELAY SPD T

5
6
7
8
9
10

1
2
3

10
9
8
7
6
5
4
3
2
1

220R
BU Z

1
2

PC 817
470R

L IM IT S W

LC D 16*2

IN P U T

IK
R L Y -1
R L Y -2

10K

20
21
22
23
24

L IM -1
L IM -2
L IM -3

R A 0 /A N 0
R D 1 /P S P 1
R A 1 /A N 1
R D 2 /P S P 2
R A 2 /A N 2 /V R E F - R D 3 /P S P 3
R B 0 /IN T
R C 4 /S D I/S D A
RB1
R C 5 /S D O
R C 0 /T 1 0 S 0 /T 1 C K I
R C 1 /T 1 0 S 1 /C C P 2
R D 0 /P S P 0
R C 3 / S C K / S C LR A 3 / A N 3 / V R E F +
R C 2 /C C P 1
R B 7 /P G D
R A 4 /T 0 C K I
R B 6 /P G C
R A 5 /A N 4 /S S
RB5
R E 0 /A N 5 /R D
RB4
R E 1 /A N 6 /W R
R B 3 /P G M
R E 2 /A N 7 /C S
RB2
R D 5 /P S P 5
VSS
R D 6 /P S P 6
VSS
R D 7 /P S P 7

27

+5V

2
3
4
33
34
15
16
19
18
17
40
39
38
37
36
35

R D 4 /P S P 4

- 6

LED

IN P U T

O S C 2 /C L K O U T

+ 5

+12V

+12V

14

26

+5V
10K

RESET

IR-1
IR-2

1
2
3
4

T O -I R

30p

R C 7 /R X/D T

25

20M H z

R C 5 /T X/C K

M C LR /V pp/E LA B

10K

P IC 1 6 F 8 7 7
O S C 1 /C L K IN

1
2
3

13

VD D
VD D

30p

+5V

11
32

LM 35

1
2
3

R 2O U T
T 2 IN

11

1
2
3

R 1IN

14

2-PIN IPCC

VC C

IC L 2 3 2

R 1O U T

LED

T 1IN

D6

12

1
2

+12V

+5V

GND

B R ID G E
1Amp

J1

VOUT

16

V IN

+12V

GND

+5V

+5V

U 13

+12V

T it le

H .V .A .C (R F )

S iz e
D ocum ent N um ber
C u s to m
D a te :

R ev
Sheet

40

of

50

5.2 IR PROXIMITY SENSOR SCHEMATIC

IR P r o x im it y S e n s o r

S iz e
D ocum ent N um ber
C u s to m< D o c >
S u n d a y , A p r il 2 9 , 2 0 1 2

Sheet

of

Single IR Sensor
+5V

+5V

+5V

+5V

VR 10K

D SC H G

4K7

LED
LM 393

2
3

47R

C V

6K8

100K

O U T

LM 555

+5V
+5V

103
10n

5
6

1
2
3

OUT
4

102
1n

470R

+5V

TR G
TH R
G N D

2
6

IR -R X

VC C

R ST

IR -T X

D a te :

R ev

T it le

1M

42

CHAPTER 6
SOFTWARE

6.0 MICROCONTROLLER PROGRAMMING (MPLAB X IDE)


The MPLAB X IDE is the new graphical, integrated debugging tool set for all
of Microchips more than 800 8-bit, 16-bit and 32-bit MCUs and digital signal
controllers, and memory devices. It includes a feature-rich editor, source-level
debugger, project manager, software simulator, and supports Microchips
popular hardware tools, such as the MPLAB ICD 3 in-circuit debugger,
PICkit 3, and MPLAB PM3 programmer. Based on the open-source
NetBeans platform, MPLAB X runs on Windows OS, MAC OS and Linux,
supports many third-party tools, and is compatible with many NetBeans plugins.
PIC and C fit together well; PIC is the most popular 8 bit chip in the world, used
in a wide variety of applications and C prized for its efficiency. MPLAB
provides a successful match featuring highly advance compiler, broad set of
hardware libraries, comprehensive documentation and plenty of ready to run
examples.
6.0.1 FEATURES
ANSI '89 compatibility
Integration with the MPLAB IDE for easy-to-use project
management and source-level debugging
Generation of re-locatable object modules for enhanced code reuse
Compatibility with object modules generated by the MPASM
assembler, allowing complete freedom in mixing assembly and C
programming in a single project
Transparent read/write access to external memory
43

MPLAB allows you to quickly develop and deploy complex applications


Write your c source code using the highly advanced code editor
Use the included micro c libraries to dramatically speed up the
development; data acquisition, memory, displays, conversions, and
communications.
Monitor your program structure, variables and functions in the code
explorer. Generate commented , human readable assembly and standard
HEX compatible with all programs
Inspect program flow and debug executable logic with integrated debugger.

45

6.1 SOFTWARE FOR GRAPHICAL USER INTERFACE(G.U.I)


GUI (graphical user interface) as the name implies provides a path between the
user and the machine through graphical representation. Thus VB is used for this
purpose in order to control and monitor all the parameters of the project.
Likewise in our project GUI is providing interface for each local room
consisting of temperature, humidity level, smoke detection, load consumption,
power management and data logging(controlling and monitoring) as well as
master control facilitated with start and stop option. There is also alarm
indication if any system malfunctions.

6.2 ORCAD

46

6.2.1 ORCAD CAPTURE


47

Accepted worldwide as the schematic design entry tool of choice.


Robust and universal, OrCAD Capture design entry is the world's most popular
schematic entry system because of its out-of-the-box ability. From designing a
new analog circuit, or revising digital schematic diagrams for an existing PCB,
to hierarchical block design the latest version of OrCAD Capture provides
everything you need to expedite your design, verification, and manufacturing
processes. OrCAD Capture is also available with an optional component
information system (CIS), which allows you to identify, utilize, and design with
preferred parts.

6.2.2 FEATURES AND CAPABILITIES


48

Fast, intuitive schematic editing technology


Boosts schematic editing efficiency by enabling you to reuse sub circuits
using hierarchical blocks
Create and edit parts in the library or directly from the schematic page
without interrupting your workflow
Automate the integration of FPGA and PLD devices into your system
schematic
Access any or all part, net, pin, and title block properties, and make changes
quickly through a single spreadsheet viewer/editor
Create basic bill of materials (BOMs) outputs extracting from the information
contained in the schematic database.

49

CHAPTER 7
REAL HARDWARE PICTURES

7.0 PIC BOARD

7.1 OTHER PICTURES

49

7.2 OVERALL SYSTEM

50

CHAPTER 8
CONCLUSION

8.0 CONCLUSION
The establishment of intelligent HVAC system with POWER MANAGEMENT
and control system optimization with technical measures and intelligent energy
efficiency has important practical significance; BAS (Building Automation
System) is the intelligent way to energy efficiency. Proper assortment of airconditioning system is crucial to achieve preferred presentation within
inexpensive restrictions.
A good sympathetic of the various types of marketable HVAC systems is
necessary for HVAC designer to meet the needs of fast track projects and at the
same time ensure that the building gets the environmental system that will best
fit its needs.
Working on the Project WIRELESS BASED ENERGY EFFICIENT HVAC
SYSTEM is quite a great experience. With this project, we hope to make BMS
much more convenient and reliable. And it can be further improved very much
by the addition of features as per described in Future Enhancements.

8.1 FUTURE ENHANCEMENT

Voice commands for controlling devices.


Improvement of Display
Improvement of user interface
Activation of the lights and setting of temperature from standalone

controller through voice input.


Implementation on PLC for extensive industrial purposes.

51

//=================================================================
=========
//==================inckude=================================
#include<pic.h>
//===============configuration==============================
__CONFIG (0x3F32);
//===============define IO port=============================
#define flame_detector RA4 //6
#define ir_sensor1
RA5 //7
#define ir_sensor2
RE0 //8
#define
#define

valve_open_lim RC3 //18


valve_close_lim RD0 //19

#define
#define

valve_open_rly RE1 //9


valve_close_rly RE2 //10

#define
buzz
RD4

//27

#define
#define
#define
#define
#define
#define

rs
en
lcd4
lcd5
lcd6
lcd7

RB2 //35
RB3 //36
RB4 //37
RB5 //38
RB6 //39
RB7 //40

#define CHANNEL0
0b10000001
#define CHANNEL1
0b10001001

// AN0
// AN1

//==============FUNCTION PTOTOTYPE=========================
void lcdinit (void);
void lcdreset (void);
void lcdcmd (unsigned char value);
void lcddata (unsigned char value);
void line1 (void);
void line2 (void);
void clear_lcd_screen (void);
void write_nibble (unsigned char data);
void lcd_pulse_command();
void lcd_pulse_data();
void project_message1();
void project_message2();
52

//=================================================================
=========
//==================inckude=================================
#include<pic.h>
//===============configuration==============================
__CONFIG (0x3F32);
//===============define IO port=============================
#define flame_detector RA4 //6
#define ir_sensor1
RA5 //7
#define ir_sensor2
RE0 //8
#define
#define

valve_open_lim RC3 //18


valve_close_lim RD0 //19

#define
#define

valve_open_rly RE1 //9


valve_close_rly RE2 //10

#define
buzz
RD4

//27

#define
#define
#define
#define
#define
#define

rs
en
lcd4
lcd5
lcd6
lcd7

RB2 //35
RB3 //36
RB4 //37
RB5 //38
RB6 //39
RB7 //40

#define CHANNEL0
0b10000001
#define CHANNEL1
0b10001001

// AN0
// AN1

//==============FUNCTION PTOTOTYPE=========================
void lcdinit (void);
void lcdreset (void);
void lcdcmd (unsigned char value);
void lcddata (unsigned char value);
void line1 (void);
void line2 (void);
void clear_lcd_screen (void);
void write_nibble (unsigned char data);
void lcd_pulse_command();
void lcd_pulse_data();
void project_message1();
void project_message2();
52

TRISD0=1;
//configure PORT as INput
TRISD4=0;
//configure PORT as output
TRISE0=1;
//configure PORT as input
TRISE1=0;
//configure PORT as output
TRISE2=0;
//configure PORT as output
///////////
//////setting ADCON1 Register///////////////
ADCON1=0b11000100;
// A/D
result right justified, conversion clk=fosc/64, just A0,A1,A3 as analog input
///////////
///////Configure UART////////////////////////
TRISC6=0;
//set
RC6 as output TX
TRISC7=1;
//set
RC7 as input RX
SPBRG=31//set baud rate as 9600 baud @XTAL=20MHZ
//BRGH=1;//baud rate high speed option
TXEN=1;//enable transmission
TX9 =0; //8-bit transmission
RX9 =0;//8-bit reception
CREN=1;//enable reception
SPEN=1;//enable serial port
///////////////////////////////////////////////////////
buzz=0;
valve_open_rly=1;
valve_close_rly=1;
set_temp=30;
counter=0;ir1_flage=0; ir2_flage=0;
lcdinit();
line1();
54

project_message1();
line2();
project_message2();
msdelay(532);
// 4sec switching tyme
clear_lcd_screen();
///////////////////////////////////////////////////////
while(1)
{

//

if ( RCIF==1 )
{
temperory=RCREG;
if ( temperory=='C' )
{
while ( RCIF==0 );
temperory=RCREG;
msdelay(4);

// 30 msec

msdelay(50);
TXREG='C';
while(TXIF==0);//only send the new data after the previous data finish sent
send_data();
}
if ( temperory=='c' )
{
while ( RCIF==0 );
set_temp=RCREG;
//
msdelay(4);
// 30 msec
msdelay(50);
TXREG='c';
while(TXIF==0);//only send the new data after the previous data finish sent
send_data();
}
}
flame_var='0';
if (flame_detector == 0)
flame_var='1';
ir1_var='0';
if (ir_sensor1 == 0)
55

{
ir1_var='1';
if (ir2_flage == 1)
{
if (counter > 0)
counter--;
ir2_flage = 0;
msdelay(266);
}
else
ir1_flage = 1;
}
ir2_var='0';
if (ir_sensor2 == 0)
{
ir2_var='1';
if (ir1_flage == 1)
{
counter++;
ir1_flage = 0;
msdelay(266);
}
else
ir2_flage = 1;
}
ADCON0=CHANNEL0;//ADCON0=0b10000001 =>conversion clk=fosc/64, CHANNEL0,
ADC ON
read_adc();
cur_temp = result/2;
bcd (cur_temp );
temp_msb = msb + 0x30;
temp_tenth = tenth + 0x30;
temp_lsb = lsb + 0x30;
get_temp_post_point_value (result);
//
ADCON0=CHANNEL1;//ADCON0=0b10001001 =>conversion clk=fosc/64, CHANNEL1,
ADC ON
//
read_adc();
//
bcd ((result*12)/100);
//
humidity_msb = msb + 0x30;
//
humidity_tenth = tenth + 0x30;
//
humidity_lsb = lsb + 0x30;
bcd (counter );
pc_msb = tenth + 0x30;
56

pc_lsb = lsb + 0x30;


line1();
lcddata('T');
lcddata('E');
lcddata('M');
lcddata('P');
lcddata(':');
lcddata(' ');
display_temperature();
lcddata(',');
lcddata(' ');
lcddata('I');
lcddata('R');
lcddata('1');
lcddata(':');
lcddata(' ');
lcddata(ir1_var);
line2();
lcddata('I');
lcddata('R');
lcddata('2');
lcddata(':');
lcddata(ir2_var);
lcddata(',');
lcddata(' ');
lcddata('F');
lcddata('L');
lcddata('A');
lcddata('M');
lcddata(':');
lcddata(flame_var);
lcddata(',');
lcddata(' ');
lcddata('P');
lcddata('C');
lcddata(':');
lcddata(pc_msb);
lcddata(pc_lsb);
if (counter > 0)
{
difference=set_temp-cur_temp;
if (difference <= 0)
{
difference=cur_temp-set_temp;
}
if (difference <= 4)
{
57

valve_open_rly=1;
valve_close_rly=0;
while (valve_close_lim==1);
valve_open_rly=1;
valve_close_rly=1;
}
else
{
if (difference <= 11)
{
if (valve_open_lim == 1)
{
if (valve_close_lim == 1)
{
msdelay(1);
}
else
{
valve_close_rly=1;
valve_open_rly=0;
msdelay(25);
valve_close_rly=1;
valve_open_rly=1;
}
}
else
{
valve_open_rly=1;
valve_close_rly=0;
msdelay(25);
valve_open_rly=1;
valve_close_rly=1;
}
}
else
{
valve_close_rly=1;
valve_open_rly=0;
while (valve_open_lim==1);
valve_close_rly=1;
valve_open_rly=1;
}
}
58

}
}
}
///////////////////////////////////////////////////////
void lcdinit()
{
lcdreset();
lcdcmd(0x28);
lcdcmd(0x0c);
lcdcmd(0x01);
lcdcmd(0x02);
}
///////////////////////////////////////////////////////
void lcdreset()
{
msdelay(3); //22msec
write_nibble(0x03);
lcd_pulse_command();
msdelay(2);
//15msec
write_nibble(0x03);
lcd_pulse_command();
msdelay(1);
//7.5msec
write_nibble(0x03);
lcd_pulse_command();
msdelay(1);
//7.5msec
write_nibble(0x02);
lcd_pulse_command();
msdelay(1);
//7.5msec
}
///////////////////////////////////////////////////////
void lcdcmd (unsigned char value)
{
unsigned char tempr;
tempr = value >>4;
write_nibble(tempr);
lcd_pulse_command();
write_nibble(value);
lcd_pulse_command();
msdelay(1);

//7.5msec

}
59

///////////////////////////////////////////////////////
void lcddata (unsigned char value)
{
unsigned char tempr;
tempr = value >>4;
write_nibble(tempr);
lcd_pulse_data();
write_nibble(value);
lcd_pulse_data();
msdelay(1);
}

//7.5msec

///////////////////////////////////////////////////////
void line1()
{
lcdcmd(0x80);
}
///////////////////////////////////////////////////////
void line2()
{
lcdcmd(0xc0);
}
///////////////////////////////////////////////////////
void clear_lcd_screen ()
{
lcdcmd(0x01);
}
///////////////////////////////////////////////////////
void write_nibble (unsigned char data)
{
lcd4 = data & 0x01;
data = data >>1;
lcd5 = data & 0x01;
data = data >>1;
lcd6 = data & 0x01;
data = data >>1;
lcd7 = data & 0x01;
}
///////////////////////////////////////////////////////
void lcd_pulse_command()
{
rs = 0;
60

en = 1;
en = 0;
}
///////////////////////////////////////////////////////
void lcd_pulse_data()
{
rs = 1;
en = 1;
en = 0;
}
///////////////////////////////////////////////////////
void project_message1()
{
unsigned char x;
unsigned char project_name1[]= "
HVAC
for (x=0;x<16;x++)
{
lcddata(project_name1[x]);
}
}
///////////////////////////////////////////////////////
void project_message2()
{
unsigned char x;
unsigned char project_name2[]= "
SSUET
for (x=0;x<16;x++)
{
lcddata(project_name2[x]);

";

";

}
}
///////////////////////////////////////////////////////
void read_adc(void)
{
unsigned char i;
unsigned long result_temperary=0; // 4 byte long
for(i=200;i>0;i-=1)
//looping 200 times for getting average value
{
//
msdelay(4);
//30msec
ADGO = 1;//ADGO is the bit 2 of the ADCON0 register,,start conversion
while(ADGO==1);//ADC start, ADGO=0 after finish ADC progress
result=ADRESH;
result=result<<8;//shift to left for 8 bit
result=result|ADRESL;//10 bit result from ADC ,, or function
result_temperary+=result;// result_temperary = result_temperary + result
61

}
result = result_temperary/200;//getting average value
}
///////////////////////////////////////////////////////
void bcd (unsigned int value)
{
unsigned char i;
i=value/10;
lsb=value%10;
msb=i/10;
tenth=i%10;
}
///////////////////////////////////////////////////////
void get_temp_post_point_value (unsigned int value)
{
unsigned char i;
i=value%2;
temp_post_point=(i*10)/2;
temp_post_point=temp_post_point + 0x30;
}
///////////////////////////////////////////////////////
void display_temperature ()
{
lcddata(temp_msb);
lcddata(temp_tenth);
lcddata(temp_lsb);
lcddata('.');
lcddata(temp_post_point);
lcddata('C');
}
///////////////////////////////////////////////////////
void display_humidity ()
{
lcddata(humidity_msb);
lcddata(humidity_tenth);
lcddata(humidity_lsb);
lcddata('%');
}
///////////////////////////////////////////////////////
void send_data ()
{
TXREG=temp_msb;
62

while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=temp_tenth;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=temp_lsb;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG='.';
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=temp_post_point;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
// TXREG=humidity_msb;
//while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
// TXREG=humidity_tenth;
//while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
// TXREG=humidity_lsb;
//while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=flame_var;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=ir1_var;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=ir2_var;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=pc_msb;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
TXREG=pc_lsb;
while(TXIF==0);//only send the new data after the previous data finish sent
// msdelay(4);
// 30 msec
63

msdelay(50);
}
///////////////////////////////////////////////////////
void msdelay (unsigned int itime)
{
unsigned int i,j;
for (i=0;i<itime;i++)
for (j=0;j<1275;j++);
}

64

APPENDIX B
DATASHEET

Você também pode gostar