32
Project Report Incubator Team Leader: Anum Zaheer Khan Team Members: Hammad Shahnawaz M.Ayub Khan Submitted To: Miss Munnazza Date of Submission: 29 august, 2010

Incubator Report

Embed Size (px)

Citation preview

Page 1: Incubator Report

Project Report Incubator

Team Leader:

Anum Zaheer Khan

Team Members:Hammad Shahnawaz M.Ayub Khan

Submitted To:

Miss Munnazza

Date of Submission:29 august, 2010

Page 2: Incubator Report

Project Report Incubator

Dedication:-HITEC University Taxila 2

Page 3: Incubator Report

Project Report Incubator

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

Page 4: Incubator Report

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

Page 5: Incubator Report

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

Page 6: Incubator Report

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

Page 7: Incubator Report

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 someDisadvantages 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

Page 8: Incubator Report

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 whenNew 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 andTherefore 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

Page 9: Incubator Report

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

Page 10: Incubator Report

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 writtenFor 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 theincubators. 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

Page 11: Incubator Report

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

Page 12: Incubator Report

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. Period(days)

Temp(F.)¹

Humidity(F.)²

Do not turnafter

HumidityLast3 days²

Open ventmore

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

Page 13: Incubator Report

Project Report Incubator

The Electrical comprises of:

I. Temperature SensorII. 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 ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C temperature range. Low cost is assured by trimming and calibration at the wafer level. The LM35’s 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.1°C in still air. The LM35 is rated to operate over a −55° to +150°C temperature range, while the LM35C is rated for a −40° to +110°C range

Features of LM35:-

Calibrated directly in ° Celsius (Centigrade) Linear + 10.0 mV/°C scale factor 0.5°C accuracy guaranteeable (at +25°C) Rated for full −55° to +150°C range Suitable for remote applications Low cost due to wafer-level trimming Operates from 4 to 30 volts

HITEC University Taxila 13

Page 14: Incubator Report

Project Report Incubator

Less than 60 μA current drain Low self-heating, 0.08°C in still air Nonlinearity only ±1⁄4°C 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

Page 15: Incubator Report

Project Report Incubator

HITEC University Taxila 15

Page 16: Incubator Report

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

Page 17: Incubator Report

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

Page 18: Incubator Report

Project Report Incubator

HITEC University Taxila 18

Page 19: Incubator Report

Project Report Incubator

Block DIAGRAM of Humidity Control:-

HITEC University Taxila 19

Page 20: Incubator Report

Project Report Incubator

CONCLUSIONWe 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

Page 21: Incubator Report

Project Report Incubator

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

PIC Microcontroller by Aalyia

Websiteshttp://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

Page 22: Incubator Report

Project Report Incubator

Appendix

Programming Code of Temperature sensor:-LCD.h:-

#include <htc.h>#define _XTAL_FREQ 20000000UL#include "myutils.h"#ifndef _LCD_H#define _LCD_HTypedef unsigned char uint8_t;/***********************

LCD CONNECTIONS***********************/#define LCD_DATA D//Port PD0-PD3 are connected to D4-D7#define LCD_E D //Enable/strobe signal#define LCD_E_POS4//Position of enable in above port#define LCD_RS B#define LCD_RS_POS 1#define LCD_RW B#define LCD_RW_POS 2/// ************* For Switches of Different Birds ***********////#define PORTCbits.RC6=1;//***************************#define LS_BLINK 0B00000001#define LS_ULINE 0B00000010/***********************F U N C T I O N S***********************/Void LCDInit (uint8_t style);void LCDWriteString(const char *msg);Void LCDWriteInt (int Val, unsigned int field_length);

Void LCDGotoXY (uint8_t x, uint8_t y);//Low levelVoid LCDByte (uint8_t, uint8_t);#define LCDCmd(c) (LCDByte(c, 0))#define LCDData(d) (LCDByte(d,1))Void LCDBusyLoop();/*********************** F U N C T I O N S E N D/***********************

M A C R O S***********************/#define LCDClear() LCDCmd(0b00000001)#define LCDHome() LCDCmd(0b00000010)#define LCDWriteStringXY(x,y,msg) {\ LCDGotoXY(x,y);\ LCDWriteString(msg);\}#define LCDWriteIntXY(x,y,val,fl) {\ LCDGotoXY(x,y);\ LCDWriteInt(val,fl);\}#endifMyutlis.h:-#ifndef MYUTILS_H #define MYUTILS_H #define _CONCAT(a,b) a##b #define PORT(x) _CONCAT(PORT,x) #define LAT(x) _CONCAT(LAT,x) #define TRIS(x) _CONCAT(TRIS,x)#endif

LCD.c:-#include <htc.h>#include "lcd.h"#define LCD_DATA_LAT

LAT (LCD_DATA)#define LCD_E_LAT

LAT (LCD_E)#define LCD_RS_LAT

LAT (LCD_RS)#define LCD_RW_LAT

LAT(LCD_RW)#define LCD_DATA_TRIS

TRIS(LCD_DATA)#define LCD_E_TRIS

TRIS(LCD_E)#define LCD_RS_TRIS

TRIS(LCD_RS)#define LCD_RW_TRIS

TRIS(LCD_RW)#define LCD_DATA_PORT

PORT(LCD_DATA)#define SET_E() (LCD_E_LAT|=(1<<LCD_E_POS))#define SET_RS() (LCD_RS_LAT|=(1<<LCD_RS_POS))#define SET_RW() (LCD_RW_LAT|=(1<<LCD_RW_POS))#define CLEAR_E() (LCD_E_LAT&=(~(1<<LCD_E_POS)))#define CLEAR_RS() (LCD_RS_LAT&=(~(1<<LCD_RS_POS)))#define CLEAR_RW() (LCD_RW_LAT&=(~(1<<LCD_RW_POS)))Void LCDByte(uint8_t c,uint8_t isdata){

HITEC University Taxila 22

Page 23: Incubator Report

Project Report Incubator

//Sends a byte to the LCD in 4bit mode//cmd=0 for data//cmd=1 for command//NOTE: THIS FUNCTION RETURS ONLY WHEN LCD HAS PROCESSED THE COMMANDUint8_t hn,ln;//Nibblesuint8_t temp;hn=c>>4;ln=(c & 0x0F);if(isdata==0)CLEAR_RS();elseSET_RS();__delay_us(0.500);

//tASSET_E();//Send high nibbletemp=(LCD_DATA_LAT & 0XF0)|(hn);LCD_DATA_LAT=temp;__delay_us(1);

//tEH//Now data lines are stable pull E low for transmissionCLEAR_E();__delay_us(1);//Send the lower nibbleSET_E();temp=(LCD_DATA_LAT & 0XF0)|(ln);LCD_DATA_LAT=temp;__delay_us(1);

//tEH//SENDCLEAR_E();__delay_us(1);

//tELLCDBusyLoop();}void LCDBusyLoop(){//This function waits till lcd is BUSYuint8_t busy,status=0x00,temp;//Change Port to input type because we are reading data

LCD_DATA_TRIS|=0x0F;//change LCD modeSET_RW();

//Read modeCLEAR_RS();//Read status//Let the RW/RS

lines stabilize__delay_us(0.5);

//tASdo{

SET_E();//Wait tDA for data to become available

__delay_us(0.5);status=LCD_DATA_PORT;status=status<<4;__delay_us(0.5);//Pull E low

CLEAR_E();

__delay_us(1); //tELSET_E();

__delay_us(0.5);temp=LCD_DATA_PORT;

temp&=0x0F;status=status|temp;

busy=status & 0b10000000;__delay_us(0.5);

CLEAR_E();__delay_us(1); //tEL}while(busy);

CLEAR_RW();//write mode//Change Port to outputLCD_DATA_TRIS&=0xF0;}void LCDInit(uint8_t style){This function Initializes the lcd module must be called before calling lcd related functionsArguments:style = LS_BLINK,LS_ULINE(can be "OR"ed for combination)

LS_BLINK :The cursor is blinking typeLS_ULINE :Cursor is "underline" type else "block" type***********************///After power on Wait for LCD to Initialize__delay_ms(30);//Set IO PortsLCD_DATA_TRIS&=(0xF0);LCD_E_TRIS&=(~(1<<LCD_E_POS));LCD_RS_TRIS&=(~(1<<LCD_RS_POS));LCD_RW_TRIS&=(~(1<<LCD_RW_POS));LCD_DATA_LAT&=0XF0;

CLEAR_E();CLEAR_RW();CLEAR_RS();//Set 4-bit mode__delay_us(0.3);SET_E();LCD_DATA_LAT|

=(0b00000010); //[B] To transfer 0b00100000 i was using LCD_DATA_PORT|=0b00100000

__delay_us(1);CLEAR_E();__delay_us(1);//Wait for LCD to

execute the Functionset Command

LCDBusyLoop(); //[B] Forgot this delay

//Now the LCD is in 4-bit mode

LCDCmd(0b00001100|style);//Display On

LCDCmd(0b00101000);

//function set 4-bit,2 line 5x7 dot format}void LCDWriteString(const char *msg)

HITEC University Taxila 23

Page 24: Incubator Report

Project Report Incubator

{/***********************

This function Writes a given string to lcd at the current cursor

location.Arguments:msg: a null

terminated string to print***********************/ while(*msg!='\0') {

LCDData(*msg);msg++;

}}void LCDWriteInt(int val,unsigned int field_length){

/****************This function writes

a integer type value to LCD module

Arguments:1)int val :

Value to print2)unsigned int

field_length :total length of field in which the value is printed

must be between 1-5 if it is -1 the field length is no of digits in the val***********************/

char str[5]="00000";int i=4,j=0;while(val){str[i]=val%10;val=val/10;i--;}if(field_length==-1)

while(str[j]==0) j++;else

j=5-field_length;

if(val<0) LCDData('-');

for(i=j;i<5;i++){LCDData(48+str[i]);}

}void LCDGotoXY(uint8_t x,uint8_t y){ if(x<40) { if(y) x|=0b01000000; x|=0b10000000; LCDCmd(x); }}LM35.c:-#include <htc.h>#include <math.h>#include "lcd.h"//Chip Settings__CONFIG(1,0x0200);__CONFIG(2,0X1E1F);__CONFIG(3,0X8100);__CONFIG(4,0X00C1);__CONFIG(5,0XC00F);__CONFIG(6,0X0082);__CONFIG(7,0X0094);//Simple Delay Routinevoid Wait(unsigned int delay){

for(;delay;delay--)

__delay_us(100);}//Function to Initialize the ADC Modulevoid ADCInit(){

//We use default value for +/- Vref

//VCFG0=0,VCFG1=0//That means +Vref =

Vdd (5v) and -Vref=GEN//Port Configuration//We also use default

value here too//All ANx channels

are Analog/*ADCON2

*ADC Result Right Justified.

*Acquisition Time = 2TAD*Conversion Clock = 32 Tosc*/ADCON2=0b10001010;}//Function to Read given ADC channel (0-13)unsigned int ADCRead(unsigned char ch){

if(ch>13) return 0;//Invalid ChannelADCON0=0x00;ADCON0=(ch<<2);//Select ADC

ChannelADON=1;//switch on the adc

moduleGODONE=1;//Start

conversionwhile(GODONE);//wait for the

conversion to finishADON=0;//switch off adcreturn ADRES;

}void main(){//TRISC=1;

//Let the LCD Module start up

Wait(100);//Initialize the LCD

Module

LCDInit(LS_BLINK);//Initialize the ADC

ModuleADCInit();//Clear the ModuleLCDClear();//Write a string at

current cursor pos

LCDWriteString("HITEC Incubator ");

LCDWriteStringXY(4,1,"Degree Celcius");

HITEC University Taxila 24

Page 25: Incubator Report

Project Report Incubator

while(1){

unsigned int val; //ADC Value

unsigned int t;

//Temperature

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

t=round(val*0.48876);//Convert to Degree Celcius

LCDWriteIntXY(0,1,t,3);//Print IT!else if(t==36){LCDClear();//Write a string at current cursor pos

LCDWriteString("Pigeon ");

LCDWriteStringXY(4,1,"Degree Celcius"); LCDWriteIntXY(0,1,t,3);//Print IT!}else if(t==38){LCDClear();//Write a string at current cursor pos

LCDWriteString("Turkey ");

LCDWriteStringXY(4,1,"Degree Celcius"); LCDWriteIntXY(0,1,t,3);//Print IT!}

else if(t==39){LCDClear();

//Write a string at current cursor pos

LCDWriteString("Duck ");

LCDWriteStringXY(4,1,"Degree Celcius"); LCDWriteIntXY(0,1,t,3);//Print IT!}else if(t==40){LCDClear();//Write a string at current cursor pos

LCDWriteString("Quail ");

LCDWriteStringXY(4,1,"Degree Celcius"); LCDWriteIntXY(0,1,t,3);//Print IT!}Wait(1000);}

HITEC University Taxila 25

Page 26: Incubator Report