Escolar Documentos
Profissional Documentos
Cultura Documentos
Hamdard University
Department of Electrical Engineering
Major In Computer System Engineering
Batch 2009
(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.6 Controls
2.1
System Explanation
2.2
System Working
2.3
10
2.4
11
SYSTEM DESIGN
3.0
Mechanical Design
13
14
15
16
16
17
18
18
19
20
20
21
22
22
Features
23
23
24
25
26
26
27
3.7 Thermostat
28
3.8 IR Sensor
28
29
29
30
30
3.11 LCD
31
32
32
33
BMS
4.0 BMS
34
35
35
36
37
37
4.5.1 HVAC
37
37
38
4.6.1 Heating
38
4.6.2 Ventilation
38
39
40
41
42
SOFTWARE
43
45
6.2 ORCAD
46
47
48
7.0
PIC Board
49
7.1
Other Pictures
49
7.2
Overall System
50
CONCLUSION
8.0 Conclusion
51
51
APPENDIX A
CODING
52
APPENDIX B
DATASHEETS
65
DEDICATION
We dedicate this report to our
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
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.
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.
RF Tranceiver
Module
Peltier
Device
IR
Sensor
Computer
Software
LCD
Display
PIC
Micro
Controller
RELAY
outputs
Limit
Switch
Room Temp
Other Inputs
RF Tranceiver
Module
CHAPTER 2
SYSTEM EXPLANATION
senses
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.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.
10
11
12
13
CHAPTER 3
SYSTEM DESIGN
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
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).
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)
18
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.
engineering
requires
precise,
quantitative
measurements
of
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
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.
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
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
29
an LDR, Photoresistor
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
32
34
CHAPTER 4
BUILDING MANAGEMENT SYSTEM
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.
(Advanced
configuration
and
power
interference).
This
37
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
39
CHAPTER 5
CIRCUITS, PCB & SIMULATION
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
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
45
6.2 ORCAD
46
49
CHAPTER 7
REAL HARDWARE PICTURES
49
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.
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
#define
#define
#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
#define
#define
#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
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