Comfort room with temperature control based on microcontroller
CHAPTER ONE
INTRODUCTION This project is consisting of all information regarding the comfort room with temperature control based on microcontroller. In this chapter; we are providing an overview of the project including the project background, project statement and objectives of project.
1.1. Project Background Room is all about comfort. From now on, our room can be made even more comfortable with automation on temperature controller to move the speed of fan depend on the temperature day and night. Also become more secure with the alarm system that working on the changes of temperature when the temperature reaches the level of bad situation (fire). Everything will become easier every day. More new technologies were created every single day. So this project is mainly purpose to make life become easier and live with technologies system every day and we will be more alert and secure with any accidentally cases that happened such as the room or house is on fire.
This project also provides the designation of an ambient temperature measurement circuit. The motivation for doing this project is the fact that temperature measurement has become an integral part of any control system operating in a temperature sensitive environment and the various learning outcomes associated during the implementation of the project.
As we all know temperature is a physical property of matter that quantitatively expresses the common notions of hot and cold. Objects of low temperature are cold, while various degrees of higher temperatures are referred to as warm or hot.In this project the ambient temperature will be displayed on a LCD. The 16F877A PIC Microcontroller will be used for handling all the required computations and control
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 1
Comfort room with temperature control based on microcontroller
1.2 Problem statement As engineering students we aimed to provide an excellent part of knowledge that shows the use of technology in our lives. In order to help our government to produce the skillful and excellent of workers, later. Also this project can give the information and knowledge about the current temperature in our lives and the most important is self-awareness that reminds us of to save our green world.
So, we providing new kind of technology which is using microcontroller based on temperature controller to control the fan speed automatically depend on the temperature in the room and give the emergencies signal if any bad cases like overheat happened. The goal of this comfort room is to save our energy, times and much more important is to help old people and disable person.
Current technology doesn’t use the automatic switch. Nowadays, many rooms or houses use a manual switch to on or off the fan. So our lives will become easier and comfortable if all the things happened automatically.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 2
Comfort room with temperature control based on microcontroller
1.3. Objective of the project
The objective this project is: 1, To create the comfort room for better lives to make our our life simple and acknowledge . 2, To be familiar with PIC and c program and to be accurate. 3, Reduce our energy and time usages because microcontroller microcontroller makes automation for this project application.
1.4. Scope of the project
1. Create for an old man to make their lives simple and easy. Also we aimed this project to disable person that hard to manually switch on the function of electronic and electric part at the room or house. 2. Reduce our energy and time usages because microcontroller makes automation for this project application. 3. Lastly, this project provided the security signal when the emergency cases happened like the room or house is on fire. This project can be placed to many part of area (room or house). For example:
1) Hospital 2) Office 3) House 4) Lab
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 3
Comfort room with temperature control based on microcontroller
CHAPTER TWO LITERATURE REVIEW
2.1. A Brief History of Temperature Temperature is by far the most measured parameter. It impacts the physical, chemical and biological world in numerous ways. Yet, a full appreciation of the complexities of temperature and its measurement has been relatively slow to develop.
Intuitively, people have known about temperature for a long time: fire is hot and snow is cold. Greater knowledge was gained as man attempted to work with metals through the bronze and iron ages. Some of the technological processes required a degree of control over temperature, but to control temperature you need to be able to measure what you are controlling.
We were using the manual speed controlling of fan. f an. Unlike air conditioners, fans only move air. They do not directly change its speed refer to current state of temperature. We know the used of potentiometer here as the main component to put the speed by level but we need to change the speed manually by push the switch button.
2.2 Brief history of temperature measurement Ancient people were physically aware of hot and cold and probably related temperature by thesize of the fire needed, and how close to sit, to keep warm.
An Australian tribe, still primitive, uses dog instead of blankets to keep warm, thus, they can relate temperature by the dog . A moderately cool night may require two dogs to keep warm, thus it is a two-dog night . An icy night would be a six-dog night .
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 4
Comfort room with temperature control based on microcontroller
Early people were, at first, fire tenders, maintaining fires originally started by natural causes. Later, they learned how to make fire and became fi re makers.
Eventually, they became fire managers as they learned to work with fire to gain the heat needed to boil water, cook meat, fire pottery potter y (500°F or 257°C ), work with copper, tin, bronze (an alloy of copper and tin) and iron, and to make glass. Although they had no quantitative measuring devices to determine how hot a fire was, they developed recipes for building different types of fires and probably used a physical indicator, such as some mineral or metal melting, to indicate the correct temperature for a particular process.
The ancient Greeks knew that air expanded when heated and applied the principle mechanically, but they developed no means of measuring temperature or amount of heat needed and devised no measuring instruments.Snow and again, when heated with a candle. The space on the column, between these two points was then divided into 110 equal parts.
The Italian scientist Galileo (1564-1642) is one of the first recorded to attempt to measure temperature in 1592. His measuring device consisted of a bulb of air, which, when heated, forced liquid (water or spirits of wine [alcohol]) down a column immersed in an open container of the liquid (see Figure 2.1). In about 1611, the thermometer was calibrated by Sanctorius Sanctorius, a colleague of Galileo, who noted the liquid level when the bulb was cooled with melting.
Figure 2.1. Galileo’s air Thermometer air Thermometer
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 5
Comfort room with temperature control based on microcontroller
Jean Rey (1582-1645), a French physician, invented the first liquid thermometer in 1632. His thermometer consisted of a flask with a long slender neck partially filled with water (see Figure 2). As the temperature changed, the liquid level would rise or fall in response.
Unfortunately, it was later realized that these early thermometers were affected by changes in atmospheric pressure. Sealed, liquid in glass thermometers were first made in about 1644. Of the various liquids used, such as water, alcohol, and mercury, alcohol was preferred since is showed the greatest expansion in response to increases i n temperature
Figure 2.2. Rey’s liquid thermometer thermometer
By the early 18th century, as many as 35 different temperature scales had been devised. In 1714, Daniel Gabriel Fahrenheit invented both the mercury and the alcohol thermometer. Fahrenheit's mercury thermometer consists of a capillary tube which after being filled with mercury is heated to expand the mercury and expel the air from the tube. The tube is then sealed, leaving the mercury free to expand and contract with temperature changes. Although the mercury thermometer is not as sensitive as the air thermometer, by being sealed it is not affected by the atmospheric pressure. Mercury freezes at -39° Celsius, so it cannot be used to measure temperature below this point.
Alcohol, on the other hand, freezes at -113° Celsius, allowing much lower temperatures to be measured. MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 6
Comfort room with temperature control based on microcontroller
Later in the 18th century, Anders Celsius realized that it would be advantageous to use more common calibration references and to divide the scale into 100 increments instead of 96. He chose to use one hundred degrees as the freezing point and zero degrees as the boiling point of water. Sensibly the scale was later reversed and the Centigrade scale was born. See Olof Beckman's short History of the Celsius Temperature Scal e.
The late 19th century saw the introduction of bimetallic temperature sensor. These thermometers contain no liquid but operate on the principle of unequal expansion between two metals. Since different metals expand at different rates, one metal that is bonded to another, will bend in one direction when heated and will bend in the opposite direction when cooled (hence the term Bimetallic Thermometer or BiMets). This bending motion is transmitted, by a suitable mechanical linkage, to a pointer that moves across a calibrated scale. Although not as accurate as liquid in glass thermometers, BiMets are more hardly, easy to read and have a wider span, making them ideal for man y industrial applications.
The 20th century also saw the refinement of the temperature scale. Temperatures can now be measured to within about 0.001°C over a wide range, although it is not a simple task. The most recent change occurred with the updating of the International Temperature Scale in 1990 to the International Temperature Scale of 1990 (ITS-90). This document also covers the recent history of temperature standards.
LM 35 sensor can work as thermometer. It is the precision temperature sensor with output linearly proportional to the Celsius (Centigrade) temperature. It also operates in single supply and draws only 60 microampere current. Its self-heating is as low as 0.1 degree at still air. LM 35 is rated to operate between -55 to +150 Degree Celsius. LM 35C operates between 40 to +110 Degree Celsius. Supply voltage required for LM 35 ranges between 4 to 30 Volts DC. Nowadays, we are using the manual speed controlling of fan. Unlike air ai r conditioners, fans only move air. They do not directly change its speed refer to current state of temperature. We know the used of potentiometer here as the main component to put the speed by level but we need to change the speed manually by push the switch button.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 7
Comfort room with temperature control based on microcontroller
What is potentiometer? A potentiometer is a three-terminal resistor with a sliding contact that forms an adjustable voltage divider. If only two terminals are used (one side and the wiper), it acts as a variable resistor or resistor or rheostat rheostat . Potentiometers are commonly used to control electrical devices.
Other than that, we know that our computers using the fan as the cooling system to protect the Central Processing Unit from getting overheat. Fan will control automatically and adjusts the fan speed depending on the temperature of the CPU. If it isn't properly cooled, the CPU will overheat and become permanently damaged. Standard fan control settings simply set the fan to run at a constant speed all the times that the computer is on. This normally involves setting a minimum and maximum fan speed, as well as a high and low CPU temperature. At the low temperature, the fan will start running at the minimum fan speed. The fan speed will vary in line with the CPU temperature until it reaches the high CPU temperature.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 8
Comfort room with temperature control based on microcontroller
CHAPTER THREE CONFORT ROOM WITH TEMPRETURE CONTROL BASED ON MICROCONROLLER
This part is about the methodology which means to elaborate of how the project can be implemented on a few requirements. There are flow charts and project block diagram with complete explanations, hardware and software development and project planning. To complete this task we need to make the research of every method used and understand those things to prevent the mistake and make the project run smoothly. There are important parts of hardware and software used to move the project to be functioned.We are using Microcontroller as the main brain of the project. This Microcontroller has many functions to work the application automatically, just put the simple program then all can run smoothly. All of these important components were explained in this chapter.
Figure 3.1 : Block Diagram of room temperature control based on pic
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 9
Comfort room with temperature control based on microcontroller
Figure 3.2 : Process of room temperature control based on PIC
The block diagram from the figure 3.1 and 3.2 show the complete part of hardware used to project. The circuit starts st arts working when the AC supply is turned on. Then the supply change from AC to DC by using the adapter. DC supply 12 volt was connected to the IC regulator circuit to produce 5 volt stable voltage. Then the sensor LM 35 start to function as the component to measure the changes of temperature surrounds the area. All the application were controlled by the PIC 16F877A to produce the output. We can put the PIC as a brain of the circuit. It is because that all functions in this block diagram are depending on this component. LCD, fan and buzzer are the output that should be set with the program of PIC. LCD used to measure and show the changes of temperature value. The fans start to function when the switch is turned on and the speed is up depending on current temperature. High value of temperature will caused high speed of fan. Then the buzzer only shows the emergency situation if the temperature reached unusual situation temperature.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 10
Comfort room with temperature control based on microcontroller
Figure 3.3: Flow chart of room temperature control based on PIC
The flow chart starts to function when the switch is turn on. The supply voltage flow to the circuit and make all the circuit including PIC to work on all application there. Level 1 (normal mode) of fan starts to function after that. If the temperature reached more than 30ºcelcius the fan automatically change the speed to level 2. The speed of fan’s become more faster. The speed will change back to normal mode if the temperatures reduce. So, we add the application to show more secure and show an emergency case to give the signal if any bad cases happened.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 11
Comfort room with temperature control based on microcontroller
The buzzer will function if the temperature more than 40ºC (to make an easier for our demonstration, we put the emergency temperature only 40 ºC). All of applications here are working automatically with the use of microcontroller.
3.1 Hardware Development
Figure 3.4 : PIC16F877A Microcontroller
The 16F877A is one of the most popular PIC microcontrollers. It comes in a 40 pin DIP pin out and it has many internal peripherals. The 40 pins make it easier to use the peripherals as the functions are spread out over the pins. This makes it easier to decide what external devices to attach without worrying too much if there enough pins to do the job.
One of the main advantages is that each pin is only shared between two or three functions so it’s easier to decide what the pin function (other ( other devices have up to 5 functions for a pin).
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 12
Comfort room with temperature control based on microcontroller
A disadvantage of the device is that it has no internal oscillator so you will need an external crystal of other clock source. The microcontroller PIC16F877A is connected to the peripheral and internal components. As shown in the figure 3.5.
Figure 3.5 connection of PIC16F877A with peripherals and internal
PIC PIC microcontroller feature description Feature
microcontroller
Flash memory
Re-programmable program storage.
RAM
Memory storage for variables.
EEPROM
Long term stable memory: Electrically
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 13
Comfort room with temperature control based on microcontroller
Erasable Programmable Only Memory.
Read
High current Input Output ports (with pin direction change).
I/O ports
Timers/Counters Typically 3. USART
Built in RS232 protocol (only needs level translator chip).
CCP
Capture/Compare/PWM module.
SSP
I2C and SPI Interfaces.
Comparator
An analogue comparator and internal voltage reference.
ADC
Analogue to digital converter.
PSP
Parallel Slave Port microprocessor systems).
LCD
LCD interface.
(for
8
bit
Special features ICSP,WDT,BOR,POR,PWRT,OST,SLEEP ICSP,WDT,BOR,POR,PWRT,OST,SLEEP ICSP
Simple programming using In Circuit Serial Programming.
Table 3.1 Feature of PIC16F877A microcontroller microcontroller
Programing is one of the most useful features of a PIC microcontroller is that you can re program them t hem as they use flash memory (if you choose a part with an F in the part number e.g. 12F675 not 12C509). Input/output PIC Microcontroller can control outputs and react to inputs.
Figure 3.6 : LM 35 Sensors of the room temperature control MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 14
Comfort room with temperature control based on microcontroller
It is the precision temperature sensor with output linearly proportional to the Celsius (Centigrade) temperature. It operates in single supply and draws only 60 uA current. Its selfheating is as low as 0.1 degree at still air. LM 35 is rated to operate between -55 to +150 Degree Celsius. LM 35C operates between -40 to +110 Degree Celsius. Supply voltage required for LM 35 ranges between 4 to 30 Voltages.
Figure 3.7: LCD temperature Display
LCD is an electronically-modulated optical device shaped into a thin, flat panel made up of any number of color or monochrome pixels filled with liquid crystals and arra yed in front of a light source (backlight) or reflector.This LCD is good to demonstrate and do measurement from the temperature sensor. It can show the changes of value from the sensor clearly. Also this LCD is cheaper than the others. Here the specification of LM 016L LCD MODULE, A/N 16X2 No. of Digits / Alpha:32 Character Count x Line:16 x 2 Supply Voltage:5V Display Area Width:61mm Display Area Height:15.8mm Operating Temperature Range:0°C to +50°C External Depth:15mm External Length / Height:44mm External Width:84mm Operating Temperature Max:50°C Operating Temperature Min:0°C
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 15
Comfort room with temperature control based on microcontroller
Figure 3.8 : LM 7805 of voltage regulator IC
LM7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed
linear voltage regulator ICs. The voltage source in a circuit may have fluctuations and would not give the fixed voltage output.The voltage regulator IC maintains the output voltage at a constant value. The xx in 78xx indicates the fixed output voltage it is designed to provide. 7805 provides +5V regulated power supply. Capacitors of suit able values can be connected at input and output pins depending upon the respective voltage levels.
3.3 Software development 3.3.1 CCS C compiler
We are using C compiler to create the program and run the compilation to get zero error. Produce a range of compilers that cover all 8 bit PICs (PIC10, PIC12, PIC14, PIC16, and PIC18) and a few of the higher spec chips (PIC24 and dsPIC). Although there were a lot of languages that can be used for the programming, but internally the computer only understand two numerical values which are 0 and 1 that were also known as the binary number. The interesting about the C languages is it is easy to understand the programming compared to Assembly languages or other languages.
Figure 3.9: CCS C Compiler MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 16
Comfort room with temperature control based on microcontroller
3.3.2 Multism Multism is an electronic schematic capture and simulation program which is part of a suite of circuit design programs, along with NI Ultiboard. Multisim is one of the few circuit design programs to employ the original Berkeley SPICE based software simulation. Multisim was originally created by a company named Electronics Workbench, which is now a division of National Instruments. Multisim includes microcontroller simulation (formerly known as MultiMCU), as well as integrated import and export features to the Printed Circuit Board layout software in the suite, Ultiboard. Multisim is widely used in academia and industry for circuits education, electronic schematic design and SPICE simulation.
Figure 3.10 : Multism
3.3.3 PIC Kit 2 and USB burner- version 2.55 Pickit2 is the high-speed programmer & Debugger designed especially for development programming of PIC single chip microcomputer. The product is featured with small volume, low power consumption, high reliability as well as easy and convenient operation. Pickit2 is applicable for almost all PIC10/12/16/18/24 and dspic30/33 FLASH series Microcontroller's Programming. Pickit2 is a USB based ICSP (In Circuit Serial Programming) programmer. Since its first release, Microchip has opened all resource of Pickit2 to the public, which includes all software source code and hardware schematics.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 17
Comfort room with temperature control based on microcontroller
Figure 3.11 : PIC Kit 2 & USB burner
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 18
Comfort room with temperature control based on microcontroller
CHAPTER FOUR RESULT AND ANALYSIS
This chapter contains the result of fan speed and buzzer. All the system controlled by microcontroller and temperature sensor to make it work automatically. It consists of the hardware and software development as mentioned in the methodology of chapter 3. Upon the completion of hardware construction and programming process, the project is needed to be tested to confirm of its function success. The tests are divided into certain parts. The parts are voltage regulator supply, microcontroller, sensor temperature, PWM motor circuit and programming.
4.1. Results
Speed Slow Fast Emergency
Level of temperature Level 1 Level 2 Level 3
Table 4.1: Result
Referring to above table, the slow level mean the speed of fan is on normal state. The fan will function when the switch is turned on. If the temperature reached above 30 ⁰C the speed will change automatically to level 2 and will change to lev el 3 if more than 40 ⁰C.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 19
Comfort room with temperature control based on microcontroller
4.1 Analysis Circuit
Figure 4.1: Complete Circuit without PWM Circuit of room temperature control
Figure 4.2: Full View Circuit room temperature control
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 20
Comfort room with temperature control based on microcontroller
Figure 4.3: Regulator Circuit (12v and 5v)
The AC supply is already converted by the adapter to give 12V input in this circuit. The function of this circuit is to produce the 5volts of VCC. Both of the voltages (12volt and 5volt) were used in this project. Both of output voltages wer e connected to all circuit and give the supply to function all of it. From here, it is easier to make the connection.
Figure 4.4: Simulation of Regulator Circuit
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 21
Comfort room with temperature control based on microcontroller
Figure 4.5: Sketch of PWM Motor Circuit
PWM Motor circuit above used to move the fan with microcontroller programming. The speed can be adjusted refer to the duty percentages. The MOSFET component was function as the speed controller to control all the level of duty (speed of fan). The duty programming was set in the PIC.
Figure 4.6: LM 35 sensor and LCD Interfacing
LCD will display and measure the current of temperature in the room. Above picture show the designation of the LCD and LM 35 sensor interfaced with PIC.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 22
Comfort room with temperature control based on microcontroller
Figure 4.7 : Test Circuit and Measurement
The LM 35 will detect the temperature and every part of rising temperature will state on the display. The speed of fan will change refer to the specification we state in PIC programming.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 23
Comfort room with temperature control based on microcontroller
CHAPTER FIVE CONCLUSION 5.1 Project Conclusion
Everybody dream to live with easier life and put some secure awareness among themself. This project make the wish come true to stay the life more comfortable. There are many application of Smart Room. But this project only to show the uses of temperature in our lives and make development of it. So if we understand more about temperature, we know how to manage the situation and also can reduce the t he time and energy we use ever y day like switch on the fan manually and never alert of the accident happened in the rooms or house. All the circuit and application of it were done greatly. The temperature can be measure and read from the display. This project also gives the information about current temperature. So we will be more knowledgeable and self-awareness. We will have more self-motivated to work harder to reduce the current problem temperature in our world, and then will save our green life to live in peaceful and harmony situation .
5.2 Project Limitation
The main important thing of research and development is a cost, especially for electronics components of relates to this project. Hard to create many application because some of the component are not sell in here. Need to order from other country.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 24
Comfort room with temperature control based on microcontroller
5.3 Future Project Recommendation
A series of enhancement, modification and upgrading have been carried out to produce better performance for the future enhancement. Below is some suggestion from our research to upgrading this project:
Make the circuit more compact and smaller. Eas y to keep and place it to our house.
Produce the system for user where the system can send the SMS directly the status of security level in house to them. Controlling the room application using computer. Use Visual Basic software that can control all operation for example just clicking the mouse then can open the light or fan. Add more applications like solar and also make an improvement of the circuit. Make it more compact and easy to keep it.
Produce a backup system like using a generator or battery as a support supply. So if blackout happened the system still can run properly. properly.
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 25
Comfort room with temperature control based on microcontroller
REFERENCES BOOKS
1. Renato Nuns, José Delgado, "An Architecture for a Home Automation System", ICECS '98 – International Conference on Electronics, Circuits and Systems, September 1998, pp.259 262. 2. Muhammad Ali Maizidi,The 8051 microcontroller & Embeded S ystems 3. Thedore F Bogart, Jr. Electric Circuits – Circuits – PIC PIC GUIDE
INTERNET WEBSITE
1. www.alldatasheet.com/datasheet-pdf/pdf/.../PIC16F87X. www.alldatasheet.com/datasheet -pdf/pdf/.../PIC16F87X.html html 2. http://ezinearticles.com/?Home-Security-History&id=212935 http://ezinearticles.com/?Home-Securit y-History&id=2129354 4 3. http://www.facstaff.bucknell.edu/mastascu/eLessonsHTML/Sensors/TempLM35 http://www.facstaff .bucknell.edu/mastascu/eLessonsHTML/Sensors/TempLM35.html .html
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 26
Comfort room with temperature control based on microcontroller
APPENDICES Appendix A: Programming Programming
To control the PIC, we need the programs to control all the circuit. Here the result of it: it : /* this a project c programming for microcontroller based temperature control system */ /* Mekelle university _EIT-M_ Electrical & Computer Engineering*/ #include<16F877A.h> #fuses HS,NOLVP,NOWDT #use delay(clock=20000000) #include
Void main () { float mytemp; setup_port_a (RA0_ANALOG); setup_adc(ADC_CLOCK_INTERNAL); set_adc_channel(0); setup_ccp1(CCP_PWM);
// Configure CCP1 as a PWM
setup_timer_2(T2_DIV_BY_16, setup_timer_2(T2_DIV_BY_1 6, 500, 2);
// 500 Hz
//starting mode// lcd_init(); lcd_putc("\fTemperature"); printf (lcd_putc); delay_ms(3000);
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 27
Comfort room with temperature control based on microcontroller
lcd_init();
while(true) { delay_ms(800); mytemp=(read_adc()*(5.0/254))*100; lcd_gotoxy(1,1); printf(lcd_putc, "Temp Now:%f\n ", mytemp); output_low(pin_B5); output_high(pin_B7); if(mytemp<=35.0) { set_pwm1_duty(1000); } if(mytemp<30.0) { set_pwm1_duty(200);
// 25% duty cycle on pin C2
} if(mytemp>=40.0) { output_high(pin_B5); set_pwm1_duty(1000); } MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 28
Comfort room with temperature control based on microcontroller
} }
APPENDIX B: LM7805 LM7805 Regulator
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 29
Comfort room with temperature control based on microcontroller
PIC16F87X Data Sheet 28/40-Pin 8-Bit CMOS FLASH Microcontrollers Devices Included in this Data Sheet:
PIC16F877 Microcontroller Core Features:
High performance RISC CPU Operating speed: DC - 20 MHz clock input DC - 200 ns instruction cycle Up to 8K x 14 words of FLASH Program Memory, Up to 368 x 8 bytes of Data Memor y (RAM) Up to 256 x 8 bytes of EEPROM Data Memory MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 30
Comfort room with temperature control based on microcontroller
Pinout compatible to the PIC16C73B/74B/76/77 Interrupt capability (up to 14 sources) Eight level deep hardware stack Direct, indirect and relative addressing modes Power-on Reset (POR) Power-up Timer (PWRT) and Oscillator Start-up Timer (OST) Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation Programmable code protection Single 5V In-Circuit Serial Programming capability Wide operating voltage range: 2.0V to 5.5V High Sink/Source Current: 25 Ma Commercial, Industrial and Extended temperature ranges Low-power consumption: - < 0.6 mA typical @ 3V, 4 MHz - 20 μA typical @ 3V, 32 kHz - < 1 μA typical standby current
MEKELLE UNIVERSITY
ELECTRICAL AND COMPUTER ENGINERING
Page 31