Sie sind auf Seite 1von 26

HITEC University Taxila

Department of Electrical Engineering

Project Report Incubator


Team Leader:
Anum Zaheer Khan
Submitted To:
Team Members:
Hammad Shahnawaz Miss Munnazza
M.Ayub Khan


Date of Submission:
29 august, 2010
Project Report Incubator

HITEC University Taxila 2


Project Report Incubator

Dedication:-
This project report, the accompanying presentation and all the effort of our group is solely
dedicated to our beloved Parents.

ABSTRACT
HITEC University Taxila 3
Project Report Incubator

In this work we developed a PIC18 microcontroller based incubator, in order to check the
conditions of the environment provided to the premature, a humidity control system and software
that carries out the reading of the sensors...We use LM35 temperature sensor to sense the
temperature and LM35 requires an ADC because the readings of LM35 are analog and we
required a digital output. The temperature sensor used to sense and display the temperature on
LCD. We develop this Incubator for five different birds. In this project we use heater to provide
appropriate heat & cooler to control the temperature because constant temperature is not required
for all birds.

HITEC University Taxila 4


Project Report Incubator

ACKNOWLEDGEMENT
All praise to Almighty Allah, who bestowed upon us minute portion of His knowledge to
us by virtue of which we have accomplished this task. His benevolence and blessings have made
us capable of working on this project. Working on this project was a very hard task but we are
grateful to him for always being with us and helping.

We are expressing our profound` and cordial gratitude to our honorable internship
supervisor Miss Munnazza who generously devoted his precious time to guide us through his
golden advice. We think we are extremely indebted to him, whose generous suggestions,
guidance, and advice were greatly useful in bringing the task in to exercise.

We are also extremely thankful to our Managing Director Brig.Moazzam Ali whose
genius and competent technical advice enabled us to carry out systematic research and
development. We extend our gratitude to those who directly and indirectly helped and motivated
and guided us through the long and arduous writing process of this report and project as a whole.
Without their cooperation our effort would not have come to a success.

We are thankful to our parents and families who were a source of inspiration and
provided us encouragement to complete this work, with their prayers.

HITEC University Taxila 5


Project Report Incubator

TABLE OF CONTENTS
CHAPTER NO TITLE
PAGE NO
ABSTRACT 4
ACKNOWLEDGEMENT 5

1. INTRODUCTION 7

1.1 Incubator 7

1.1.1 EGG Handling 7

1.1.2 EGG Storage 7

1.1.3 Natural Incubation 8

1.1.4 Artificial Incubation 8

1.1.5 Understanding the meant for

Artificial incubation 11

1.1.5.1 Temperature 11

1.1.5.2 Humidity 11

Turning the EGGs 12

Candeling 12

1.2.1.5 Microcontroller

1.2.2 The Electrical Section

2. CONCLUSION

3. References

4. Appendix A

5 Appendix B

HITEC University Taxila 6


Project Report Incubator

1. INTRODUCTION
1.1 Incubator:-
Incubation is the term used to describe the process of applying heat to an egg so that the embryo
contained within develops into a chick. Aviculturists of today have three options regarding the
incubation of eggs and the procedure accordingly differs somewhat in each case. Each option has
some advantages and some
Disadvantages as compared to the other two. These options are as follows:
1. Incubation and hatching by the hen pheasant (=natural incubation),
2. Incubation and hatching by a broody domestic hen (=natural incubation by a surrogate
mother),
3. Incubation and hatching by artificial means (=incubation with electronic incubators Incubator
is medical equipment

1.1.1 Egg Handling:-


It is not difficult to appreciate that the egg is a very delicate life system. The developing embryo,
with its associated membranes and blood vessels, lives in a fluid environment and is therefore
not rigidly fixed to any supporting structure. Extreme care must be taken, therefore, whenever
handling fresh hatching eggs, to ensure that the embryo and its associated parts are not injured.
Rapid and jerky movements must be avoided, as abrupt changes in motion can cause membranes
or blood vessels within the egg to tear. If we move eggs by vehicle to the incubation facility, they
must be protected from vibration and jarring by setting them in foam rubber. Moreover, the eggs
should be transported as early in incubation as possible, before the vulnerable blood vessel
network starts to develop. Cleanliness is also important, and the one who takes care for the
transport of the eggs should do everything possible to prevent the transfer of pathogens to the
egg and/or incubator as well as prevent the build-up of body oils on the shell with repeated
handling.

1.1.2 EGG Storage:-


Most rare pheasant eggs which have received NO INCUBATION can be stored for several days
while retaining high probability that they will hatch. An exemption on this rule is the eggs of
peacock (Polyplectron sp.) and Argus pheasant (Argusianus sp.), which we believe are best
incubated immediately after laying. We recommend that pheasant eggs be stored only if proper
storage conditions are available and that they be stored for as short a time as possible, but no
longer than seven days. Proper storage temperature is 15 Celsius degrees at relative humidity of
75-80%. Proper position for an egg in pre-incubation storage is subject to debate. We have odd
success storing rare pheasant eggs with their large end in horizontal position and turning them
through 180 at least twice daily.

HITEC University Taxila 7


Project Report Incubator

1.1.3 Natural Incubation:-


Natural incubation is the incubation performed by a bird, be it a pheasant that laid the eggs, a
surrogate pheasant parent, or some type of nesting chicken. The hen pheasant can be left with the
job of incubation and hatching the eggs, and subsequently brooding them also. Many hens will
do a very satisfactory job since their instincts for these processes have not yet been erased due to
domestication as has happened in many poultry. The main advantage of this procedure is that one
does not have to worry about the correct temperature and relative humidity, turning of the eggs
and the preservation of the instincts in the succeeding generations. If a female parent will not
incubate the eggs, which is usually the case with many pheasant species in captivity, or also
when the eggs are pulled sequentially to enhance laying, then the eggs ideally should be placed
with a surrogate parent to obtain the initial seven to ten days of natural incubation. Various
aviculturists, however, have reportedly used chickens and ducks for incubation with varying
degrees of success, including, unfortunately, several broken eggs. It are in particularly those
species, which lay soft-shelled eggs, such as for instance the peacock pheasants (Polyplectron
sp.), where artificial incubation is to be recommended, to avoid broken eggs. Sometimes when a
hen Tragopan gets broody we leave the eggs of the last clutch in her basket for natural
incubation. We have had several occasions where both satyr and Temminck's hens successfully
incubated their eggs and raised their chicks to maturity. For this, however, it is important that the
male is removed from the hen and her chicks as he might disturb the incubating female
constantly and/or the young chicks once they start looking for food.

1.1.4 Artificial Incubation:-


We have been using electronic incubators, both still-air and forced-air, as a routine matter, since
we began keeping and breeding exotic pheasants and game birds. We believe we have a better
control on the various parameters, affecting proper incubation, such as temperature, relative
humidity, turning of the eggs, diseases and hatching. There is no denying the truth that the
aviculture of common, rare and endangered pheasants in Western Europe and Northern America
has come only on full swing when
New and reliable "small-scale incubators, with a capacity of 100 up to 200 pheasant eggs" were
made available. This was particularly the case during the last twenty five years. There is a wide
variety of incubators available in the avicultural marketplace "in the West", and undoubtedly
there are many that are suitable for incubating galliform eggs. We have consistently used the
"Grumbach" forced-air incubators, the model Compact S84. This type is used for incubating as
well as hatching and is a desirable unit for a number of reasons. It is specifically designed for
counter-top operation and
Therefore uses little space. It is easily cleaned, constructed from plastic materials, and is fairly
easy to use once the operator becomes familiar with the idiosyncrasies of each unit. We have
also been working with the "Multihatch" forced-air incubators, but in a lesser extend, as they can
not be used for counter-top operation and the control of temperature and humidity in such
machines can not be checked and regulated as easily as for instance in the Grumbach incubators.
We have found that the success of small incubators lies in their being located in a suitable room,
where temperature and humidity do not change that much. Artificial incubation is convenient
when there is a constant supply of steady voltage. In general, when there is a steady voltage of
the mains supply AND the voltage fluctuations are only very small, then artificial incubation is
far more practical than natural incubation. Low and very high voltages affect both the electronic

HITEC University Taxila 8


Project Report Incubator

instruments and the electronic thermostats as well and lead to poor incubation results. We have
experimented that electronic incubators are far more practical than broody hens, because of the
convenience of the operation and the more precise regulation of the temperature and humidity.
For this, however, it is important one has access to a reliable incubator. Many aviculturists in the
West use an electronic incubator exclusively for Incubation and hatching since, with our
advanced technology, we have things under better control than for instance aviculturists in Asia.

Temperature:-
Proper incubation temperature is critical for ensuring the maximum hatchability of the eggs as
well as the best physical condition of the chicks that hatch. Variation from the optimum
temperature affects growth rate and incidence of embryonic mortality and deformity. Use of
suboptimal conditions is evidenced by poor hatching success or by chicks hatching with
unrestricted yolk sacs, poor vigor, and developmental problems. We have successfully hatched
galliform eggs in incubator maintained at temperatures ranging from 37.6-37.8 degrees Celsius.
The optimum temperature seems to be 37.7 degrees Celsius. We have found that developing eggs
are very vulnerable to overheating but are somewhat less affected by short periods of cooling.
Safe incubator operation therefore requires a double temperature control system consisting of a
primary and secondary, or override, thermostat. The primary thermostat is simply the thermostat
which normally controls the incubator temperature. The secondary thermostat, which is adjusted
0.5 Celsius degrees higher than the primary, will assume control of the heating element if the
primary should fail, thus protecting the eggs from being overheated. Measuring the correct
temperature in the incubator is another very important aspect of the incubation procedure. We
use both mechanical (=both alcohol and mercury) and electronic thermometers to do this job
right. It is our experience that mechanical thermometers do work the best and give the most
reliable data. Therefore we do calibrate the digital instruments on basis of our standard
mechanical thermometers.

Humidity:-
Proper control of the incubator humidity is also critical for successful hatching of artificially
incubated eggs to reach the correct weight loss. Please consult the book for any greater details on
the egg weight loss for eggs. The level of humidity inside the cabinet can be maintained
automatically by the use of the humidistat which controls the evaporation of tiny water drops in
the water vessel, which is taken with by the air flow, which passes over the surface of its water
contents and transports these to the incubation cabinet, containing the eggs. For the eggs of most
pheasants, 48-50% relative humidity inside the forced-air incubator would be all right. Some
aviculturists, however, prefer to have a slightly lower humidity at the beginning and a slightly
higher lever at the middle and at the end of the incubation period. The incubation period (days)
for eggs of various pheasant species and other game birds are different. Measuring the correct
humidity in the incubator is a very important consideration.

HITEC University Taxila 9


Project Report Incubator

Turning of EGGs:-
Egg-turning during incubation is important as it prevents the developing embryo from sticking to
the shell membranes, a problem which develops if the egg lies too long in the same position. A
survey of the poultry literature indicates that for optimal hatchability an egg should be turned at
least eight times every 24 hours. Many incubators with automatic turning mechanisms, turn the
eggs once every hour or so as installed by the breeder. Regardless of the number of times an egg
is turned each day, the interval between turnings should be evenly spaced throughout the twenty-
four hour period. In addition, the eggs would be turned in alternate directions, as turning in only
one direction will increase embryo mortality. Eggs can of course be turned by hand if desired,
but maintaining regular turning intervals is frequently difficult if one is not always around
twenty-four hours per day to monitor the incubators. Automatic turning is, therefore, an
important feature of the incubator. We automatically turn the eggs in the incubators at least 4
times per day. The "Incubator" turning-mechanism consists of a sliding grid assembly and an
enclosed motor-gear assembly, as shown in the various pictures.

Candling:-
Candling is a technique which facilitates observation of the inner contents of an egg without
opening the shell. Useful not only to determine fertility and the extent of incubation, candling
can provide information about the condition of the egg shell and air cell as well as the condition
and position of the embryo.
If an egg is held against light, the developing embryo, with its blood vessels and the air cell at
the broader end are seen. The examination becomes easier if a small light-box made of either
wood or metal carrying a 40 watt electric bulb and a small window appropriate to the size of the
egg is used in a full-darkened room. The blood vessels can be seen as thin red lines after about
72-84 hours of incubation. All infertile eggs will appear clear and these are to be rejected from
the incubator, as also eggs with cracked shells. We perform candling on regular basis (at least 2
times per week) to keep track of the change air-cell and ultimately on the egg weight loss.
However, candling is more an art than a science and much can be learnt from
experience.Candlers are commercially available but plans for home-made models can also be
found in some books written
For the lay poultry breeder. If a home-made candler is constructed, it is best to use a light bulb
no larger than 40 watts to prevent the egg from being exposed to excessive heat.

Proper Record Keeping:-


Proper record keeping of the eggs laid, eggs made available for incubation, eggs hatched can be
done by the use of incubation cards. The eggs, laid in a time span of one week, are being
collected in the pheasantry. Before putting these in the incubators, they are all marked so we can
keep track of their further development while in the
incubators. It is fundamental to keep proper records for all the eggs being laid during the
breeding season for good incubation management. Eggs, regardless whether they are used for
artificial or natural incubation, these should be clearly marked with an alcohol pen with the date

HITEC University Taxila 10


Project Report Incubator

of hatch expected, the species, the number of aviary or of the pair, which laid the egg, It is
important to know the family relationships of the eggs and consequently of the chicks, being
born, to guarantee healthy genetic pairings in the pheasantry.

Incubating Conditions:-
Poor results are most commonly produced with improper control of temperature and/or humidity.
Improper control means that the temperature or humidity is too high or too low for a sufficient
length of time that it interferes with the normal growth and development of the embryo. Poor
results also occur from improper ventilation, egg turning and sanitation of the machines or eggs.
Obtain the best hatch by keeping the temperature at 100 degrees F. throughout the entire
incubation period when using a forced-air incubator. Minor fluctuations (less than degree)
above or below 100 degrees are tolerated, but do not let the temperatures vary more than a total
of 1 degree. Prolonged periods of high or low temperatures will alter hatching success. High
temperatures are especially serious. A forced-air incubator that is too warm tends to produce
early hatches. One that runs consistently cooler tends to produce late hatches. In both cases the
total chicks hatched will be reduced.
Maintain a still-air incubator at 102 degrees F. to compensate for the temperature layering within
the incubator. Obtain the proper temperature reading by elevating the bulb of the thermometer to
the same height as the top of the eggs when the eggs are laying horizontal. If the eggs are
positioned in a vertical position, elevate the thermometer bulb to a point about - to -inch
below the top of the egg. The temperature is measured at the level where the embryos develop (at
the top of the egg). Do not allow the thermometer's bulb to touch the eggs or incubator. Incorrect
readings will result. Humidity is carefully controlled to prevent unnecessary loss of egg
moisture. The relative humidity in the incubator between setting and three days prior to hatching
should remain at 58-60% or 84-86 degree F., wet-bulb. Necessary humidity adjustments can be
made as a result of the candling inspection. The egg's weight must decrease by 12% during
incubation if good hatches are expected. Conversion of the two humidity measurements can be
made using the following table:

Rarely is the humidity too high in properly ventilated still-air incubators. The water pan area
should be equivalent to one-half the floor surface area or more. Increased ventilation during the

HITEC University Taxila 11


Project Report Incubator

last few days of incubation and hatching may necessitate the addition of another pan of water or
a wet sponge. Humidity is maintained by increasing the exposed water surface area. Ventilation
is very important during the incubation process. While the embryo is developing, oxygen enters
the egg through the shell and carbon dioxide escapes in the same manner. As the chicks hatch,
they require an increased supply of fresh oxygen. As embryos grow, the air vent openings are
gradually opened to satisfy increased embryonic oxygen demand. Care must be taken to maintain
humidity during the hatching period.
The two most important considerations in this situation are to keep the eggs from overheating
and be sure they have an adequate oxygen supply. The longer the eggs incubate and the greater
the number of eggs in the incubator, the greater the chance that you will experience overheating
and suffocation of the embryos. If the room in which the incubator is located is hot and stuffy,
you will have to react more quickly to power outages than if the room is kept at 75 degrees and is
well ventilated. The most effective guard against overheating and suffocation is to open the door
of the incubator or Hatcher. Do not turn eggs during the last three days before hatching. The
embryos are moving into hatching position and need no turning. Keep the incubator closed
during hatching to maintain proper temperature and humidity. The air vents should be almost
fully open during the latter stages of hatching. The eggs are initially set in the incubator with the
large end up or horizontally with the large end slightly elevated. This enables the embryo to
remain oriented in a proper position for hatching. Never set eggs with the small end upward. In a
still-air incubator, where the eggs are turned by hand, it may be helpful to place an "X" on one
side of each egg and an "O" on the other side, using a pencil. Take extra precautions when
turning eggs during the first week of incubation. The developing embryos have delicate blood
vessels that rupture easily when severely jarred or shaken, thus killing the embryo.
The following table lists incubation requirements for various species of fowl.

Species Incubi. Temp Humidity Do not Humidi Open vent


Period (F.) (F.) turn ty more
(days) after Last
3 days
Chicken 21 100 85-87 18th day 90 18th day

Turkey 28 99 84-86 25th day 90 25th day

Duck 28 100 85-86 25th day 90 25th day

Goose 28-34 99 86-88 25th day 90 25th day

Pigeon 17 100 85-87 15th day 90 14th day

Electrical Section

HITEC University Taxila 12


Project Report Incubator

The Electrical comprises of:

I. Temperature Sensor
II. Microcontroller
III. Circuit schematics

Each of these has been described in detail ahead.

LM 35 Temperature sensor:-
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

Features of LM35:-

Calibrated directly in Celsius (Centigrade)


Linear + 10.0 mV/C scale factor
0.5C accuracy guaranteeable (at +25C)
Rated for full 55 to +150C range
Suitable for remote applications
Low cost due to wafer-level trimming

HITEC University Taxila 13


Project Report Incubator

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

The Microcontroller:-
The PIC18 has a RISC architecture that comes with some standard features such as on-chip
program(code) ROM, data EEPROM, timers,ADC and USATR and I/O ports.The size of
Program ROM,data RAM,data EEPROM, and I/O ports varies among the family members.They
all have peripherals.

PIC18F4520 have code ROM of 32K, data RAM of 1536byte, data EEPROM of 256byte, I/O
pins of 36, ADC of 10-bits, Timers of 4, and is of 40pin DIP package.

HITEC University Taxila 14


Project Report Incubator

HITEC University Taxila 15


Project Report Incubator

The Temperature Sensor Circuit:-

The are many cool sensors available now a days, ranging from IR distance sensor modules,
accelerometers, humidity sensors, temperature sensors and many many more(gas sensors,
alcohol sensor, motion sensors, touch screens). Many of these are analog in nature. That means
they give a voltage output that varies directly (and linearly) with the sensed quantity. Fore in
LM35 temperature sensor, the output voltage is 10mV per degree centigrade. That means if
output is 300mV then the temperature is 30 degrees. In this tutorial we will learn how to
interface LM35 temperature sensor with PIC18F4520 microcontroller and display its output on
the LCD module.

Calculations of Temperature:-
PIC MCU's ADC gives us the value between 0-1023 for input voltage of 0 to 5v provided it is
configured exactly as in the above tutorial. So if the reading is 0 then input is 0v, if reading is
1023 then input is 5v. So in general form if the ADC read out is Val then voltage is.
Unsigned int Val;

HITEC University Taxila 16


Project Report Incubator

Val=ADCRead (0); //Read Channel 0

Voltage= ((Val)/1023.0)*5;

The above formula gives voltage in Volts, to get Voltage in mili Volts (mV) we must multiply it
with 1000, so
Voltage= ((Val)/1023.0)*5*1000); //Voltage is in mV

Since 10mV = 1 degree, to get temperature we must divide it by 10, so


t= ((Val)/1023.0)*5*100); //t is in degree centigrade

Simplifying further we get


t= ((val/1023.0)*500);

t= (Val*0.48876);

We round off this value, so


t=round (Val*0.48876);

Circuit Schematic of Incubator:-

HITEC University Taxila 17


Project Report Incubator

HITEC University Taxila 18


Project Report Incubator

Block DIAGRAM of Humidity Control:-

CONCLUSION
HITEC University Taxila 19
Project Report Incubator

We were exposed to high levels of difficulty while we were exposed to various technical skills. It was a
very good learning experience and at times we had to work with circuits and concepts which were very
new to us.

We would like to recommend the usage of incubator in diverse fields and should be setup at the university
premises so that we are facilitated more easily.

HITEC University Taxila 20


Project Report Incubator

References
The PIC18 Microcontroller and Embedded Systems 2nd Edition by Muhammad Ali Mazidi

PIC Microcontroller by Aalyia

Websites
http://www.google.com

http://www.wikipedia.com

http://www.esnip.com

http://www.alldatasheets.com

http://www.rapidshare.com

http://www.cemex.com

User Manual of HITECH-Compiler Software.

HITEC University Taxila 21


Project Report Incubator

Appendix
Programming Code of Temperature sensor:-
LCD.h:- Void LCDGotoXY (uint8_t LCD.c:-
x, uint8_t y); #include <htc.h>
#include <htc.h> //Low level #include "lcd.h"
#define _XTAL_FREQ Void LCDByte (uint8_t, #define LCD_DATA_LAT
20000000UL uint8_t); LAT (LCD_DATA)
#include "myutils.h" #define LCDCmd(c) #define LCD_E_LAT
#ifndef _LCD_H (LCDByte(c, 0)) LAT (LCD_E)
#define _LCD_H #define LCDData(d) #define LCD_RS_LAT
Typedef unsigned char (LCDByte(d,1)) LAT (LCD_RS)
uint8_t; Void LCDBusyLoop(); #define LCD_RW_LAT
/*********************** /***********************
LCD FUNCTIONS END LAT(LCD_RW)
CONNECTIONS /*********************** #define LCD_DATA_TRIS
***********************/ MACROS TRIS(LCD_DATA)
#define LCD_DATA D//Port ***********************/ #define LCD_E_TRIS
PD0-PD3 are connected to #define LCDClear() TRIS(LCD_E)
D4-D7 LCDCmd(0b00000001) #define LCD_RS_TRIS
#define LCD_E D #define LCDHome() TRIS(LCD_RS)
//Enable/strobe signal LCDCmd(0b00000010) #define LCD_RW_TRIS
#define LCD_E_POS4 #define TRIS(LCD_RW)
//Position of enable in above LCDWriteStringXY(x,y,msg) #define LCD_DATA_PORT
port {\ PORT(LCD_DATA)
#define LCD_RS B LCDGotoXY(x,y);\ #define SET_E()
#define LCD_RS_POS 1 LCDWriteString(msg);\ (LCD_E_LAT|=(1<<LCD_E
#define LCD_RW B } _POS))
#define LCD_RW_POS 2 #define #define SET_RS()
/// ************* For LCDWriteIntXY(x,y,val,fl) (LCD_RS_LAT|=(1<<LCD_
Switches of Different Birds {\ RS_POS))
***********// LCDGotoXY(x,y);\ #define SET_RW()
//#define PORTCbits.RC6=1; LCDWriteInt(val,fl);\ (LCD_RW_LAT|=(1<<LCD
//********************** } _RW_POS))
*****#define LS_BLINK #endif #define CLEAR_E()
0B00000001 Myutlis.h:- (LCD_E_LAT&=(~(1<<LC
#define LS_ULINE #ifndef MYUTILS_H D_E_POS)))
0B00000010 #define MYUTILS_H #define CLEAR_RS()
/*********************** #define _CONCAT(a,b) (LCD_RS_LAT&=(~(1<<LC
FUNCTIONS a##b D_RS_POS)))
***********************/ #define PORT(x) #define CLEAR_RW()
Void LCDInit (uint8_t style); _CONCAT(PORT,x) (LCD_RW_LAT&=(~(1<<L
void LCDWriteString(const #define LAT(x) CD_RW_POS)))
char *msg); _CONCAT(LAT,x) Void LCDByte(uint8_t
Void LCDWriteInt (int Val, #define TRIS(x) c,uint8_t isdata)
unsigned int field_length); _CONCAT(TRIS,x) {
#endif

HITEC University Taxila 22


Project Report Incubator

//Sends a byte to the LCD in LCD_DATA_TRIS|=0x0F; LS_BLINK :The cursor is


4bit mode //change LCD mode blinking type
//cmd=0 for data SET_RW(); LS_ULINE :Cursor is
//cmd=1 for command //Read mode "underline" type else "block"
//NOTE: THIS FUNCTION CLEAR_RS(); type
RETURS ONLY WHEN //Read status ***********************/
LCD HAS PROCESSED //Let the RW/RS //After power on Wait for
THE COMMAND lines stabilize LCD to Initialize
Uint8_t hn,ln; __delay_us(0.5); __delay_ms(30);
//Nibbles //tAS //Set IO Ports
uint8_t temp; do LCD_DATA_TRIS&=(0xF0
hn=c>>4; { );
ln=(c & 0x0F); SET_E(); LCD_E_TRIS&=(~(1<<LCD
if(isdata==0) //Wait tDA for data to _E_POS));
CLEAR_RS(); become available LCD_RS_TRIS&=(~(1<<LC
else __delay_us(0.5); D_RS_POS));
SET_RS(); status=LCD_DATA_PORT; LCD_RW_TRIS&=(~(1<<L
__delay_us(0.500); status=status<<4; CD_RW_POS));
//tAS __delay_us(0.5); LCD_DATA_LAT&=0XF0;
SET_E(); //Pull E low CLEAR_E();
//Send high nibble CLEAR_E(); CLEAR_RW();
temp=(LCD_DATA_LAT & CLEAR_RS();
0XF0)|(hn); __delay_us(1); //tEL //Set 4-bit mode
LCD_DATA_LAT=temp; SET_E(); __delay_us(0.3);
__delay_us(1);
//tEH __delay_us(0.5); SET_E();
//Now data lines are stable temp=LCD_DATA_PORT; LCD_DATA_LAT|=
pull E low for transmission temp&=0x0F; (0b00000010); //[B] To
CLEAR_E(); status=status|temp; transfer 0b00100000 i was
__delay_us(1); busy=status & 0b10000000; using
//Send the lower nibble __delay_us(0.5); LCD_DATA_PORT|=0b001
SET_E(); CLEAR_E(); 00000
temp=(LCD_DATA_LAT & __delay_us(1); //tEL __delay_us(1);
0XF0)|(ln); }while(busy); CLEAR_E();
LCD_DATA_LAT=temp; __delay_us(1);
__delay_us(1); CLEAR_RW(); //Wait for LCD to
//tEH //write mode execute the Functionset
//SEND //Change Port to output Command
CLEAR_E(); LCD_DATA_TRIS&=0xF0; LCDBusyLoop();
__delay_us(1); } //[B] Forgot this delay
//tEL void LCDInit(uint8_t style) //Now the LCD is in
LCDBusyLoop(); { 4-bit mode
} This function Initializes the LCDCmd(0b000011
void LCDBusyLoop() lcd module must be called 00|style); //Display On
{ before calling lcd related LCDCmd(0b001010
//This function waits till lcd functions 00);
is BUSY Arguments: //function set 4-bit,2
uint8_t style = line 5x7 dot format
busy,status=0x00,temp; LS_BLINK,LS_ULINE(can }
//Change Port to input type be "OR"ed for combination) void LCDWriteString(const
because we are reading data char *msg)

HITEC University Taxila 23


Project Report Incubator

{ for(i=j;i<5;i++) *Acquisition Time = 2TAD


/*********************** { *Conversion Clock = 32
This function Writes LCDData(48+str[i]); Tosc
a given string to lcd at the } */ADCON2=0b10001010;
current cursor } }
location. void LCDGotoXY(uint8_t //Function to Read given
Arguments: x,uint8_t y) ADC channel (0-13)
msg: a null { unsigned int
terminated string to print if(x<40) ADCRead(unsigned char ch)
***********************/ { {
while(*msg!='\0') if(y) x|=0b01000000; if(ch>13) return 0;
{ x|=0b10000000; //Invalid Channel
LCDData(*msg); LCDCmd(x); ADCON0=0x00;
msg++; } ADCON0=(ch<<2);
} } //Select ADC
} LM35.c:- Channel
void LCDWriteInt(int #include <htc.h> ADON=1;
val,unsigned int field_length) #include <math.h> //switch on the adc
{ #include "lcd.h" module
/**************** //Chip Settings GODONE=1;//Start
This function writes __CONFIG(1,0x0200); conversion
a integer type value to LCD __CONFIG(2,0X1E1F); while(GODONE);
module __CONFIG(3,0X8100); //wait for the
Arguments: __CONFIG(4,0X00C1); conversion to finish
1)int val : __CONFIG(5,0XC00F); ADON=0;
Value to print __CONFIG(6,0X0082); //switch off adc
2)unsigned int __CONFIG(7,0X0094); return ADRES;
field_length :total length of //Simple Delay Routine }
field in which the value is void Wait(unsigned int delay) void main()
printed { {
must be between 1-5 for(;delay;delay--) //TRISC=1;
if it is -1 the field length is no //Let the LCD
of digits in the val __delay_us(100); Module start up
***********************/ } Wait(100);
char str[5]="00000"; //Function to Initialize the //Initialize the LCD
int i=4,j=0; ADC Module Module
while(val) void ADCInit() LCDInit(LS_BLINK
{ { );
str[i]=val%10; //We use default //Initialize the ADC
val=val/10; value for +/- Vref Module
i--; //VCFG0=0,VCFG1 ADCInit();
} =0 //Clear the Module
if(field_length==-1) //That means +Vref = LCDClear();
Vdd (5v) and -Vref=GEN //Write a string at
while(str[j]==0) j++; //Port Configuration current cursor pos
else //We also use default LCDWriteString("HI
j=5- value here too TEC Incubator ");
field_length; //All ANx channels LCDWriteStringXY(
are Analog 4,1,"Degree Celcius");
if(val<0) LCDData('- /*ADCON2 while(1)
'); *ADC Result Right Justified. {

HITEC University Taxila 24


Project Report Incubator

unsigned int LCDWriteString("Du


val; //ADC Value LCDWriteIntXY(0,1,t,3);//Pr ck ");
unsigned int int IT! LCDWriteStringXY(
t; } 4,1,"Degree Celcius");
//Temperature else if(t==38)
{ LCDWriteIntXY(0,1,t,3);//Pr
val=ADCRead(0); LCDClear(); int IT!
//Read Channel 0 //Write a string at current }
cursor pos else if(t==40)
t=round(val*0.48876 LCDWriteString("Tu {
);//Convert to Degree Celcius rkey "); LCDClear();
LCDWriteStringXY( //Write a string at current
LCDWriteIntXY(0,1, 4,1,"Degree Celcius"); cursor pos
t,3);//Print IT! LCDWriteString("Qu
else if(t==36) LCDWriteIntXY(0,1,t,3);//Pr ail ");
{ int IT! LCDWriteStringXY(
LCDClear(); } 4,1,"Degree Celcius");
//Write a string at current else if(t==39)
cursor pos { LCDWriteIntXY(0,1,t,3);//Pr
LCDWriteString("Pi LCDClear(); int IT!
geon "); //Write a string at current }
LCDWriteStringXY( cursor pos Wait(1000);}
4,1,"Degree Celcius");

HITEC University Taxila 25

Das könnte Ihnen auch gefallen