Con thai

858 views

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
858
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Con thai

  1. 1. ConThai Rice Cooker Mr. Jaturapat Pakkanawanit Mr. Nattapon Kumpaing Mr. Prissada Chuachai Mr. Sapon Pitak Mr. Sutipong Kankua Mr. Narubas Younuch Mr. Kittipat Jaturapornpison Mr. Charintorn Jareonsri Mr. Tipakorn Sumeteenarumit Mr. Panuwat Sangketkit Mr. Wtsanu Thamneammai This project Submitted in Partial Fulfillment of theApplication of industrial Electronic for Muti-Disciplinary Workshop Department of Control System and Instrumentation Engineering Faculty of Engineering King Mongkut’s University of Technology Thonburi Academic Year 2011
  2. 2. ConThai Rice Cooker Mr. Jaturapat Pakkanawanit 53211804 Mr. Nattapon Kumpaing 53211811 Mr. Prissada Chuachai 53211819 Mr. Sapon Pitak 53211830 Mr. Sutipong Kankua 53211831 Mr. Narubas Younuch 53219012 Mr. Kittipat Jaturapornpison 54261503 Mr. Charintorn Jareonsri 54261504 Mr. Tipakorn Sumeteenarumit54261512 Mr. Panuwat Sangketkit 54261520 Mr. Wtsanu Thamneammai 54261522 This project Submitted in Partial Fulfillment of theApplication of industrial Electronic for Muti-Disciplinary Workshop Department of Control System and Instrumentation Engineering Faculty of Engineering King Mongkut’s University of Technology Thonburi Academic Year 2011
  3. 3. Chapter 1 Preface1.1 Name of project: ConThai Rice Cooker1.2 The origin of project From nowadays Thai people eat rice less every year. Next Thai people consume ricehave tendency keep lower. And consumption rice in Asia have 200 kilograms per year butnumber of Thai consume have 100 – 110 kilograms per year. My world into full consumption war, have fast, convenient, save. That is necessary forconsume rice. Rice has to adapt to a wide variety of markets. Amid the hustle of urban life whichalways a race against time. That’s need to use something for convenient to reduce time. So eatrice in morning meal look like busy because it’s not support with life style that has changed. Andwe got culture from west that has effect with people in town consumption. So we can see quantityconsume rice of people in town less than people in country side because limit in time. So, this project was made for respond human behavior that was change for got moreconvenient.1.3 Objective For develop Rice Cooker can work Variable by has basic function as follows 1.3.1 Cooking function. 1.3.2 Warm function, can set timer. 1.3.3 Boiled function, can set timer. 1.3.4 Fired function, can set timer.
  4. 4. 1-21.4 Procedure Procedure is starting from search information about rice cooking at using and used thendesign system of rice cooking for overview structure in this device. Detail working procedure asfollow. 1.4.1 Research Theory about rice cooking. 1.4.2 Research function and operation’s controller. 1.4.3 Design structure and circuit of rice cooking. 1.4.4 Find device of product. 1.4.5 Study writes Program by used AVR. 1.4.6 Write program go together with install circuit. 1.4.7 Develop program and Test. 1.4.8 Adjust, solve circuit and made program better. 1.4.9 Collect, conclude problem in working. 1.4.10 The results of the experiment. 1.4.11 Made report.1.5 Period Plan January February March April May 1 2 3 4 1 2 3 4 1 2 3 4 5 1 2 3 4 1 2 3 4 51. Research rice cocker2. Hardware3. Microcontroller4. Design circuit5. Buy hardware device6. Compound circuit7. Test circuit8. Adjust9. Made report
  5. 5. 1-31.6 Benefit 1.6.1 Can made rice cockier that proper with new life style for real use. 1.6.2 Get knowledge from work cooperation and get knowledge that have to useful.
  6. 6. Chapter 2 Theory2.1 Power supply 2.1.1 Block Diagram 220 V Transformer Rectifier Smoothing Regulator 5 V DC AC Mains Figure 2-1 Block Diagram Power supply 2.1.2 Transformer Transformer has convert alternative current from voltage to another voltage by losepower at less. Transformer can work with alternative only and that is the reason, why current inhome be alternative current. Transformer convert step-up increase voltage and transformer convert step-down decrease voltage. Almost power supply use transformer step-down for decrease voltage inhome that have height voltage (220 V) and dangerous to lower for safety. Input inductor is called primary and output inductor is called secondary between bothdoesn’t connect in current but use connection by alternative magnetic field is in transformermagnetic coil. Draw a two line between the coil in symbol is the magnetic core. The ratio of the number coil round is called turns ratio. It determines voltage ratiotransformer step-down. The number of round much is primary coil, connect to 220 volt is inputand output is secondary coil has number of round few, give low voltage.
  7. 7. 2-2 𝑉𝑃 𝑁𝑃 Ratio round = = 𝑉𝑆 𝑁𝑆 Vp = Primary Voltage (Input). Vs = Secondary (Output). Np = Radians of primary inductor. Ns = Radians of secondary inductor. 2.1.3 Bridge rectifier Current on Bridge can use four diode is connector or use brides diode readymade. Thisis full wave current because used all AC current (It has positive current and negative current).Bridge rectifiers have voltage 1.4 V. Because each diode should have voltage 0.7 V when haveinduce current. More over two bridge diode have induced current simultaneously. Figure 2-2 Bridge rectifier circuit Figure 2-3 Full wave bridge diode 2.1.4 Smoothing Filter is grow by high value electrolytic capacitor connect to direct current. Role issame pond, it give current to output, when smoothing is AC voltage drop. In figure is show notfilter direct current and filter direct current. Capacitor is fast evolve at peak of direct current andCapacitor evolve to output.
  8. 8. 2-3 Figure 2-4 Show is charge and discharge of capacitor Make direct voltage is increase to peak (1.4 × RMS). It’s example such alternativecurrent 6 V RMS when have full wave rectifier. It has direct current approximate 4.6 V RMS(Loss of bridge diode rectifier is 1.4 V), When DC is pass in smoothing will increase to peak1.4 × 4.6 = 6.4 V (DC). Filtration is not perfect because have little voltage of capacitor when evolve. It is causesmall ripple. For general circuit, supply have ripple 10 % is able. Value of capacitor onsmoothing. It can find to equation below. If capacitor is big size will have little ripple. For halfwave direct current. Filter use over two time value of capacitor. (5)( I o ) Capacitor for sweep 10 %, C = (V s )(f) Io = Output current to power supply. Vs = Supply voltage (Vpeak of direct current isn’t filter). f = Supply frequency AC (50 Hz). 2.1.5 Regulator IC control voltages have constant voltage (Such 5, 12 and 15 V) or vary output voltage.It’s call follow pass peak of current. Negative IC control voltage used for twin power supply.General IC control that have auto overload protection and thermal protection. Constant IC control have 3 leg and same power transistor such as IC control valuenumber 7805 +5 V 1 A. Show in right hand. Front have install.
  9. 9. 2-4 Figure 2-5 IC control voltage2.2 TRIAC TRIAC is semiconductor transistor group. It has inside structure same with DIAC, buthas one more leg. TRIAC is create for modify error SCR. When not induce current in negativealternative current. Most application of TRIAC will use control circuit is switch connect toalternative current. TRIAC is create high current also will must careful in drain heat. Structure ofTRIAC have 3 semiconductors is P-N-P that have 3 leg. Three leg have MT1, MT2 and G. Figure 2-6 Structure of TRIAC Figure 2-7 Symbol of TRIAC 2.2.1 TRIC working conditions 2.2.1.1 Give positive voltage to MT2. Give negative voltage to MT1 and give positivevoltage trig to G. 2.2.1.2 Give positive voltage to MT2. Give negative voltage to MT1 and givenegative voltage trig to G. 2.2.1.3 Give negative voltage to MT2. Give positive voltage to MT1 and givenegative voltage trig to G.
  10. 10. 2-5 2.2.1.4 Give negative voltage to MT2. Give positive voltage to MT1 and give positivevoltage trig to G. 2.2.2 TRIC stops working conditions When TRIAC induce current isn’t have to keep voltage trig to G. Because TRIAC willcontinue induce current is same SCR. Stop TRIAC have 2 means. 2.2.2.1 Cutoff power supply gives to MT2 and MT1. 2.2.2.2 Decreases bias voltage is give to MT2 and MT1. It make current pass toTRIAC lower holding current of TRIAC.2.3 Sensor 2.3.1 Thermostat Thermostat in digital rice cooking is difference general rice cooking. General ricecooking consists of Lever Contact Switch and magnetic set. Diode run by magnetic deterioratewhen have high heat. But thermostat in digital rice cooking is measure temperature and send tomicrocontroller for process value that control heat inductor. 2.3.2 Voltage divider circuit Voltage divider circuit is circuits have to 2 resistance series connect between powersupply. Resistance is portion out voltage in circuit. General voltage divider circuit is develop fromOhm’s law. Calculate is cross voltage on resistance use voltage divider will fast and beconvenient than Ohm’s law. Figure 2-8 Show voltage divider circuit
  11. 11. 2-62.4 Check the power circuit 2.4.1 Block diagram Sound detection Time delay Flash LED driver Figure 2-9 Block Diagram check the power circuit 2.4.2 The working principle. When, the rice cooker plug in also. The voltage sent to circuit, it’s ready for work. Thenoise surrounding the rice cooker will serve as the command to start the circuit. The LED lampsinstalled around. The bottom of the cooker took place light and not light. There is sound order ofthe LED, on-off for 15 seconds. And it will run again when theres sound around. 2.4.3 Timing diagram SoundComparator Time Delay 15 sec. Figure 2-10 Timing diagram check the power circuit
  12. 12. 2-7 2.4.4 The works circuit 2.4.4.1 Sound detection has received sound from microphone. And voltage sent toComparator circuit because output pulse signals can base bias of transistor BC184. 2.4.4.2 Time delay has delay of the circuit. Assign 15 seconds use Mono-stablecircuit from IC 555 and using output base bias transistor by BC337. Which is switch controlvoltage sent to flash LED driver. 2.4.5 Flash LED driver Flash LED driver has control on-off for LED that is LM3916. When area around thedevice has sound, LED will light around 15 seconds.2.5 Microcontroller 2.5.1 Graphic screen ET-NOKIA LCD 5110 2.7.1.1 Resolution screen 48 x 84 Dot. 2.7.1.2 High speed Serial Bus Interface communication 4.0 Mbits/s. 2.5.1.3 It has controller number PCD8544 for control. 2.5.1.4 LED Back-Light. 2.5.1.5 Run at 2.7 - 5.0 volt. 2.5.1.6 Use low power that suitable with function for battery. 2.5.1.7 Rage of temperature is -25 to +70 degree Celsius. Figure 2-11 Display graphic ET-NOKIA LCD 5110
  13. 13. 2-82.5.2 AT mega 128 2.5.2.1 High effective and have low power. 2.5.2.2 High safety. 2.5.2.3 Can read flash program. 2.5.2.4 Keep data to 20 years at 85 degree Celsius. 2.5.2.5 Interface for witting SPI Program. Figure 2.12 AT mega 128
  14. 14. Chapter 3 Circuit and Design This chapter discusses the various parts of the circuit. And explain the function of thecircuit used in this project.3.1 Power supply circuit Figure 3-1 Power supply circuit In this part we use Lm7809 to convent from transformer 12 VAC to 9 VDC current 1Ain U1 has diode for project to flow one way. In U2 use lm7805 for convent from 9VDC current1A to 5VDC current 1A for get to use with microcontroller and U3 use lm7805 convent to 5VDCcurrent 1A for get to use with sensor.
  15. 15. 3-23.2 TRIAC circuit Figure 3-2 TRIAC circuit Calculate R1, when VT = 5 V, I1 = 60 mA From VT = I1R1 5 V = (60 mA) R1 R1 = 83.33 Ω Calculate R2, when E = 220 V, I2 = 5 mA From E = I2R2 220 V = (5 mA) R2 R2 = 44 kΩ
  16. 16. 3-33.3 Sensor circuit 3.3.1 Calculation voltage divider circuit +5 V R1 V1 1 kΩ RT R2 V2 100 kΩ R3 V3 Output 10 kΩ Figure 3-3 Voltage divider circuit Calculate IT, V70°C, V100°C, V120°C, V190°C . When R1 = 1 kΩ, R2 = 100 kΩ, R3 = 10 kΩCalculate RTmax, when R2 = 100 kΩ RTmax = R1 + R2 + R3 = 1 kΩ + 100 kΩ +10 kΩ RTmax = 111 kΩCalculate RTmin, when R2 = 0 kΩ RTmin= R1 + R2 + R3 = 1 kΩ + 0 kΩ +10 kΩ RTmin = 11 kΩCalculate V3max, when RT = 11 kΩ, R3 = 10 kΩ V3max = VT (R T ) R3 10 kΩ = 5V(11 kΩ ) V3max = 4.5454 V
  17. 17. 3-4Calculate V3min, when RT = 111 kΩ, R3 = 10 kΩ V3min = VT (R T ) R3 10 kΩ = 5V(111 kΩ ) V3min = 0.4504 VCalculate IT, when E = 5V, RT = 11 kΩ V IT = (R T ) T 5V = (11 kΩ ) IT = 0.45 mACalculate V70°C, when R1 = 1 kΩ, R2 = 15.31 kΩ, R3 = 10 kΩ, RT = 26.31 kΩ R V70°C = VT (R 3 ) T 10 kΩ = 5V(26.31 kΩ) V70°C = 1.9004 VCalculate V100°C, when R1 = 1 kΩ, R2 = 5.24 kΩ, R3 = 10 kΩ, RT = 16.24 kΩ R V100°C = VT (R 3 ) T 10 kΩ = 5V(16.24 kΩ ) V100°C = 3.0788 VCalculate V120°C, when R1 = 1 kΩ, R2 = 3.19 kΩ, R3 = 10 kΩ, RT = 14.19 kΩ R V120°C = VT (R 3 ) T 10 kΩ = 5V(14.19 kΩ ) V120°C = 3.5236 VCalculate V190°C, when R1 = 1 kΩ, R2 = 500 Ω, R3 = 10 kΩ, RT = 11.5 kΩ R V190°C = VT (R 3 ) T 10 kΩ = 5V(11.5 kΩ ) V190°C = 4.3478 V
  18. 18. 3-5 3.3.2Graph of sensor by compare resistance with temperature Figure 3-4 The relationship between resistance and temperature.3.4 Check sound status circuit Figure 3-5 Show using IC 555 circuit
  19. 19. 3-6 Calculator Mono-stable circuit from The formula Time period, T=1.1RC Assign T=15 Sec., C=1uF 15 So R = 1.1∗1uF = 13.6364kΩ Selection R= 14k3.5 Touch switch circuit Figure 3-6 IC Show using WB2080A Circuit
  20. 20. 3-73.6 Microcontroller Figure 3-7 Show using ATMEGA12.
  21. 21. Chapter 4 Structure of Programming Controller4.1 Operation of program Overview of program in “Rice cooker” start from set value for user as follow. 4.1.1 Time setting. 4.1.2 Set value and Display LCD Interface. 4.1.3 Fix variable for select function in start Rice cooker. 4.1.4 Operation of program can write Flow Chart thus.
  22. 22. 4-2 START s Cooker Boiled StreamSet time cook If temp >100 c If temp > 100 c Cook False False SW SW Cook = True True on2heater OFF heater all OFF heater allIf temp >130 c False SW True Warm Figure 4-1 Flow chart main program
  23. 23. 4-3 START Fried Warm Set timeIf temp >190 c If time >2min Set hour False False SW SW Hour +1 -1 -1 True TrueOFF heater all OFF heater all Set min 6 sec. Min +1 -1 -1 Set sec Sec +1 -1 -1 Figure 4-2 Flow chart main program
  24. 24. Chapter 5 Experiments and conclusion5.1 Preface After pass programming step each part and design circuit the most important by theway is test the circuit to find the error after that repair error.5.2 Guidelines for tested circuit 5.2.1 Tested touch switch circuit. 5.2.2 Tested drive coil circuit. 5.2.3 Tested check sound circuit. 5.2.4 Tested sensor circuit. 5.2.5 Tested all circuit and measure temperature.5.3 Equipment for test Therefore, this experiment emphasis on rice cooker function and installed componentpart which are; 5.3.1 Power supply: LM7805, LM7809, Capacitor. 5.3.2 Coil. 5.3.3 Triac, Isolate. 5.3.4 Sensor. 5.3.5 Touch switch. 5.3.6 Microcontroller AVR-ATMEGA128. 5.3.7 IC 3916.5.4 Sequence Steps of Testing 5.4.1 Plug in and Microcontroller starts working. 5.4.2 Wait for rice cooker to operate (“Conthai” shows on the monitorn approximately3 seconds).
  25. 25. 5-2 5.4.3 Press each bottom for testing both usage and function. 5.4.4 Coil testing.5.5 Rice Cooker Function Testing Conthai - Rice cooker could be controlled both in term of Manual system andAutomatic system. Moreover, user can verify operated order via display. 5.5.1 Testing Objective 5.5.1.1 Test the accuracy of Microcontroller that can operate as good as properstandard 5.5.1.2 Test the accuracy of digital clock that can operate as good as proper standard 5.5.1.3 Test the accuracy of display that can operate as good as proper standard 5.5.1.4 Test the accuracy of touch switch that can operate as good as proper standard 5.5.2 Testing Task 5.5.2.1 After turn the power, rice cooker will start working by has Microcontroller asthe main function. 5.5.2.2 Microcontroller sends data and information to display monitor then our groupname, Conthai, shows on the display. 5.5.2.3 Setting time by press on time setting function bottom to adjust hour, minuteand second. After the adjustment, press time setting function bottom one more time to approve.Sound will loud out when the confirmation complete) 5.5.2.4 Press on each function; cook, steam, fry and boil, to test touch switch. Theselected function will be displayed on display monitor and hidden light will glow out.5.6 Conclusion According to the testing, every components could be operated as expected and achievetesting objective. Please turn to next unit for more information about obstacles and solutionduring working process.
  26. 26. Chapter 6 Problems and suggestions6.1 Preface In this project has many problems, because this project use electronic device to maxefficiency for work and to divide the problem into 2 types of problems that are Software andHardware.6.2 Problem and SolvingIn this project has problem about Software and Hardware, so we divide the problem and solve asfollows. 6.2.1 First step I see problem that is to used hardware devices are difficult, because wemust the rice cooker have all function. And device can inside to rice cooker. 6.2.2 Second, We test to LED status circuit. When connect power supply we will findyank voltage. It made some circuit to error. So we solve by turn on power supply before connectthe circuit after that to measure each circuit. 6.2.3 Third, when we made PCB after check line PCB. When we test circuit are findbash about line in PCB, after we find bash about line in PCB we solve by weld line PCB. 6.2.4 The surface mouse, when we weld in PCB we don’t know it can use and check bymulti-meter. 6.2.5 Touch switch in circuits are find shield cable have ground around cable, when westripping the wire and weld to copper plate. Found that circuit. 6.3.6 In part microcontroller problems is FUSES attached from factory, its not sameour experiments. It is not possible to perform experiments. It can’t possible to performexperiments. Solution is use boards by program to list variable into experiments to fix variable 2FUSES are same, for programming of rice cooker work. 6.5.7 The TRIAC circuit hacking problems found is calculated according to the theory.It has excess resistance value is not able to trigger GATE output on for the TRIAC, solution is by
  27. 27. 6-2changing the resistance less valuable so the stream flows sufficient to trigger on for the TRIACand selection resistor for range 1 watt.
  28. 28. ContentsChapter 1 Preface 1-1 1.1 Name of project 1-1 1.2 The origin of project 1-1 1.3 Objective 1-1 1.4 Procedure 1-2 1.5 Period 1-2 1.6 Benefit 1-3Chapter 2 Theory 2-1 2.1 Power supply 2-1 2.2 TRIAC 2-4 2.3 Sensor 2-5 2.4 Check the power circuit 2-6 2.5 Microcontroller 2-7Chapter 3 Circuit and Design 3-1 3.1 Power supply circuit 3-1 3.2 TRIAC circuit 3-2 3.3 Sensor circuit 3-3 3.4 Check sound status circuit 3-5 3.5 Touch switch circuit 3-6 3.6 Microcontroller 3-7Chapter 4 Structure of Programming Controller 4-1 4.1 Operation of program 4-1Chapter 5 Experiments and conclusion 5-1 5.1 Preface 5-1 5.2 Guidelines for tested circuit 5-1 5.3 Equipment for test 5-1 5.4 Sequence Steps of Testing 5-1 5.5 Rice Cooker Function Testing 5-2
  29. 29. Contents (contd.) 5.6 Conclusion 5-2Chapter 6 Problems and suggestions 6-1 6.1 Preface 6-1 6.2 Problem and Solving 6-1Appendix A ManualAppendix B ProgrammingAppendix C Datasheet
  30. 30. FiguresFigure 2-1 Block Diagram Power supply 2-1Figure 2-2 Bridge rectifier circuit 2-2Figure 2-3 Full wave bridge diode 2-2Figure 2-4 Show is charge and discharge of capacitor 2-3Figure 2-5 IC control voltage 2-4Figure 2-6 Structure of TRIAC 2-4Figure 2-7 Symbol of TRIAC 2-4Figure 2-8 Show voltage divider circuit 2-5Figure 2-9 Block Diagram check the power circuit 2-6Figure 2-10 Timing diagram check the power circuit 2-6Figure 2-11 Display graphic ET-NOKIA LCD 5110 2-7Figure 2.12 AT mega 128 2-8Figure 3-1 Power supply circuit 3-1Figure 3-2 TRIAC circuit 3-2Figure 3-3 Voltage divider circuit 3-3Figure 3-4 The relationship between resistance and temperature. 3-5Figure 3-5 Show using IC 555 circuit 3-5Figure 3-6 IC Show using WB2080A Circuit 3-6Figure 3-7 Show using ATMEGA12 3-7Figure 4-1 Flow chart main program 4-2Figure 4-2 Flow chart main program 4-3
  31. 31. Appendix BProgramming
  32. 32. Main#include <avr/io.h>#include <avr/interrupt.h>#include <compat/deprecated.h>#define F_CPU 16000000UL#include <util/delay.h>#define PORT_SPI PORTB#define DDR_SPI DDRB#include <avr/io.h> // AVR device-specific IO definitions#include <avr/interrupt.h> // Interrupt Service routine#include <util/twi.h> // AVR TWI interface.#define RX_BUFSIZE 10 // Buffer RX#define DD_ENB DDB0#define DD_MOSI DDB2#define DD_SCK DDB1#define DD_SS DDB6#define DD_DC DDB4#define DD_RESET DDB5#define GLCD_SIZE ((GLCD_X_RES*GLCD_Y_RES)/8)#define GLCD_X_RES 84#define GLCD_Y_RES 48#include "font5x7.h"#define TWI_SLA 0xD0 // Address DS1307 (11010000)#define Vadc 1024/************************************************************** Data Types */typedef unsigned char byte;typedef unsigned int word;typedef struct { byte sec; byte min; byte hour; byte day; byte date; byte month; byte year;} RTC_TYPE;RTC_TYPE RTC;void delay_ms(uint16_t i){ for(;i>0;i--)
  33. 33. _delay_ms(1);}void GLCD_Reset(void){ delay_ms(500); sbi(PORT_SPI,DD_RESET); delay_ms(10); cbi(PORT_SPI,DD_RESET); delay_ms(10); sbi(PORT_SPI,DD_RESET); delay_ms(10);}void GLCD_Clear(void){ int i; sbi(PORT_SPI,DD_DC); for (i=0;i<GLCD_SIZE;i++){ SPI_MasterTransmit(0x00); }}void GLCD_Init(void){ cbi(PORT_SPI,DD_ENB); GLCD_Reset(); cbi(PORT_SPI,DD_DC); SPI_MasterTransmit(0x21); SPI_MasterTransmit(0xc0); SPI_MasterTransmit(0x06); SPI_MasterTransmit(0x13); SPI_MasterTransmit(0x20); SPI_MasterTransmit(0x0c); GLCD_Clear();}void GLCD_GotoXY(uint8_t x,uint8_t y){ cbi(PORT_SPI,DD_DC); SPI_MasterTransmit((0x80)|x); SPI_MasterTransmit((0x40)|y);}sound (){ {
  34. 34. _delay_ms(1); PORTE=0xFF; _delay_ms(1); PORTE=0x00; }}static void GLCD_PutChar(uint8_t ch,uint8_t sp){ int16_t p; if((ch<0x20)||(ch>0x7f)) return; p = (ch-32)*5; for(ch=0;ch<5;ch++){ SPI_M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F, 0xFF, 0xFF,
  36. 36. }; int ch; for(ch=0;ch<504;ch++) { SPI_MasterTransmit(p[ch]); } //if (sp)SPI_MasterTransmit(0x00);}void Put0(int a){ sbi(PORT_SPI,DD_DC); int ch,p[]= { 0xFF,0xFF,0x03,0x03,0x03,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0xFF,0xFF,0xC0,0xC0,0xC0,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void Put1(int a){sbi(PORT_SPI,DD_DC); int ch,p[]= { 0x00,0x18,0x0C,0xFE,0xFF,0xFF,0x00 }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0x00,0xC0,0xC0,0xFF,0xFF,0xFF,0xC0 };
  37. 37. for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void Put2(int a){sbi(PORT_SPI,DD_DC); int ch,p[]= { 0x83,0x83,0x83,0x83,0x83,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0xFF,0xFF,0xC1,0xC1,0xC1,0xC1,0xC1 }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void Put3(int a){ sbi(PORT_SPI,DD_DC); int ch,p[]= { 0X87,0X87,0X87,0X87,0X87,0XFF,0XFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0XE1,0XE1,0XE1,0XE1,0XE1,0XFF,0XFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]);
  38. 38. }}void Put4(int a){ sbi(PORT_SPI,DD_DC); int ch,p[]= { 0xFF,0xFF,0x80,0x80,0x80,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0x01,0x01,0x01,0x01,0x01,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void Put5(int a){sbi(PORT_SPI,DD_DC); int ch,p[]= { 0xFF,0xFF,0x83,0x83,0x83,0x83,0x83 }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0xC1,0xC1,0xC1,0xC1,0xC1,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}
  39. 39. void Put6(int a){sbi(PORT_SPI,DD_DC); int ch,p[]= { 0xFF,0xFF,0x83,0x83,0x83,0x83,0x83 }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0xFF,0xFF,0xC1,0xC1,0xC1,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void Put7(int a){sbi(PORT_SPI,DD_DC); int ch,p[]= { 0x03,0x03,0x03,0x03,0x03,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0x00,0x00,0x00,0x00,0x00,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void Put8(int a){
  40. 40. sbi(PORT_SPI,DD_DC); int ch,p[]= { 0xFF,0xFF,0x83,0x83,0x83,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0xFF,0xFF,0xC1,0xC1,0xC1,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void Put9(int a){sbi(PORT_SPI,DD_DC); int p[]= { 0xFF,0xFF,0x83,0x83,0x83,0xFF,0xFF }; int ch; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0xC1,0xC1,0xC1,0xC1,0xC1,0xFF,0xFF }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}/*void Put0(int a){sbi(PORT_SPI,DD_DC); int p[]=
  41. 41. { 0x00,0x18,0x0C,0xFE,0xFF,0xFF,0x00,0x00 }; int ch; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); int q[]= { 0x00,0xC0,0xC0,0xFF,0xFF,0xFF,0xC0,0xC0, }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}*/void col(int a){sbi(PORT_SPI,DD_DC); int p[]= { 0x00,0x00,0x30,0x30,0x00,0x00,0x00 }; int ch; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(p[ch]); } GLCD_GotoXY(a,2); sbi(PORT_SPI,DD_DC); int q[]= { 0x00,0x00,0x0C,0x0C,0x00,0x00,0x00 }; for(ch=0;ch<7;ch++) { SPI_MasterTransmit(q[ch]); }}void SPI_MasterInit(void){ DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK)|(1<<DD_ENB); DDR_SPI |= (1<<DD_DC)|(1<<DD_RESET); SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1)|(0<<SPR0);}
  42. 42. void SPI_MasterTransmit (uint8_t cData){ SPDR = cData; while (!(SPSR&(1<<SPIF))) ;}void TWI_Stop(){ // Send STOP condition TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWSTO);}uint8_t TWI_Read(uint8_t ack_bit){ if (ack_bit) { // Start transmission, ACK Received TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA); } else { // Start transmission, NACK Received TWCR = (1<<TWINT)|(1<<TWEN); } // Wait for transmission while (!(TWCR & (1<<TWINT))) ; switch (TW_STATUS) { // Data received, ACK returned case TW_MR_DATA_ACK: // Data received, NACK returned case TW_MR_DATA_NACK: break; // Arbitration lost in SLA+R or NACK case TW_MR_ARB_LOST: default: return 0; } return(TWDR); // Read TWDR}/***************************************************************** TWI Write*/uint8_t TWI_Write(uint8_t uc_data,uint8_t ack_bit){ TWDR = uc_data; // Load SLA_W to TWDR
  43. 43. if (ack_bit) { // Start transmission, ACK Received TWCR = (1<<TWINT)|(1<<TWEN)|(1<<TWEA); } else { // Start transmission, NACK Received TWCR = (1<<TWINT)|(1<<TWEN); } // Wait for transmission while (!(TWCR & (1<<TWINT))) ; switch (TW_STATUS) { // SLA+W transmitted, ACK received case TW_MT_SLA_ACK: // SLA+W transmitted, NACK received case TW_MT_SLA_NACK: return 1; // SLA+R transmitted, ACK received case TW_MR_SLA_ACK: // SLA+R transmitted, NACK received case TW_MR_SLA_NACK: return 2; // Data transmitted, ACK received case TW_MT_DATA_ACK: // Data transmitted, NACK received case TW_MT_DATA_NACK: return 3; // Arbitration lost in SLA+W or data case TW_MT_ARB_LOST: default: return 0; }}/*************************************************************** DS1307_Read*/uint8_t DS1307_Read(unsigned char ctl){ unsigned char dat; TWI_Start(); // Start condition TWI_Write(TWI_SLA+TW_WRITE,1); // TWI Write mode TWI_Write(ctl,0); // Control byte TWI_Start(); // Start condition
  44. 44. TWI_Write(TWI_SLA+TW_READ,1); // TWI Read mode dat = TWI_Read(0); // Read NACK Received TWI_Stop(); // Stop condition return (dat);}/************************************************************** DS1307_Write*/void DS1307_Write(unsigned char ctl,unsigned char dat){ TWI_Start(); // Start condition TWI_Write(TWI_SLA+TW_WRITE,1); // TWI Write mode TWI_Write(ctl,1); // Control byte TWI_Write(dat,1); // Data byte TWI_Stop(); // Stop condition}/*********************************************************** Real-Time Clock */// Get Date/Time from RTC(DS1307)void Read_RTC(void){ RTC.sec = DS1307_Read(0x00); RTC.min = DS1307_Read(0x01); RTC.hour = DS1307_Read(0x02); RTC.date = DS1307_Read(0x04); RTC.month = DS1307_Read(0x05); RTC.year = DS1307_Read(0x06);}void TTT(){ unsigned int sec0,sec1,min0,min1,hour0,hour1,digit1,digit2,digit3,digit4; Read_RTC(); sec0=RTC.sec&0x0F; sec1=((RTC.sec&0xF0)); sec1=sec1>>4; min0=RTC.min&0x0F; min1=((RTC.min&0xF0)); min1=min1>>4; hour0= RTC.hour&0x0F; hour1= RTC.hour&0xF0; hour1=hour1>>4;
  45. 45. GLCD_GotoXY(8,1); sbi(PORT_SPI,DD_DC); if (hour1==0)Put0(8); if (hour1==1)Put1(8); if (hour1==2)Put2(8); if (hour1==3)Put3(8); if (hour1==4)Put4(8); if (hour1==5)Put5(8); if (hour1==6)Put6(8); if (hour1==7)Put7(8); if (hour1==8)Put8(8); if (hour1==9)Put9(8); cbi(PORT_SPI,DD_DC); GLCD_GotoXY(16,1); sbi(PORT_SPI,DD_DC); if (hour0==0)Put0(16); if (hour0==1)Put1(16); if (hour0==2)Put2(16); if (hour0==3)Put3(16); if (hour0==4)Put4(16); if (hour0==5)Put5(16); if (hour0==6)Put6(16); if (hour0==7)Put7(16); if (hour0==8)Put8(16); if (hour0==9)Put9(16); GLCD_GotoXY(24,1); col(24); cbi(PORT_SPI,DD_DC); GLCD_GotoXY(32,1); sbi(PORT_SPI,DD_DC); if (min1==0)Put0(32); if (min1==1)Put1(32); if (min1==2)Put2(32); if (min1==3)Put3(32); if (min1==4)Put4(32);; if (min1==5)Put5(32); if (min1==6)Put6(32); if (min1==7)Put7(32); if (min1==8)Put8(32); if (min1==9)Put9(32); GLCD_GotoXY(40,1);if (min0==0)Put0(40); else if (min0==1)Put1(40); else if (min0==2)Put2(40); else if (min0==3)Put3(40); else if (min0==4)Put4(40); else if (min0==5)Put5(40); else if (min0==6)Put6(40); else if (min0==7)Put7(40);
  46. 46. else if (min0==8)Put8(40); if (min0==9)Put9(40); GLCD_GotoXY(48,1); col(48); cbi(PORT_SPI,DD_DC); GLCD_GotoXY(56,1); sbi(PORT_SPI,DD_DC); if (sec1==0)Put0(56); else if (sec1==1)Put1(56); else if (sec1==2)Put2(56); else if (sec1==3)Put3(56); else if (sec1==4)Put4(56); else if (sec1==5)Put5(56); else if (sec1==6)Put6(56); else if (sec1==7)Put7(56); else if (sec1==8)Put8(56); if (sec1==9)Put9(56); GLCD_GotoXY(64,1); if (sec0==0)Put0(64); else if (sec0==1)Put1(64); else if (sec0==2)Put2(64); else if (sec0==3)Put3(64); else if (sec0==4)Put4(64); else if (sec0==5)Put5(64); else if (sec0==6)Put6(64); else if (sec0==7)Put7(64); else if (sec0==8)Put8(64); if (sec0==9)Put9(64); cbi(PORT_SPI,DD_DC);}void TTTT(unsigned int datah,unsigned int datam,unsigned int datas){ unsigned int sec0,sec1,min0,min1,hour0,hour1,digit1,digit2,digit3,digit4; sec0=datas&0x0F; sec1=((datas&0xF0)); sec1=sec1>>4; min0=datam&0x0F; min1=((datam&0xF0)); min1=min1>>4; hour0= datah&0x0F; hour1= datah&0xF0; hour1=hour1>>4; GLCD_GotoXY(8,1); sbi(PORT_SPI,DD_DC); if (hour1==0)Put0(8);
  47. 47. if (hour1==1)Put1(8); if (hour1==2)Put2(8); if (hour1==3)Put3(8); if (hour1==4)Put4(8); if (hour1==5)Put5(8); if (hour1==6)Put6(8); if (hour1==7)Put7(8); if (hour1==8)Put8(8); if (hour1==9)Put9(8); cbi(PORT_SPI,DD_DC); GLCD_GotoXY(16,1); sbi(PORT_SPI,DD_DC); if (hour0==0)Put0(16); if (hour0==1)Put1(16); if (hour0==2)Put2(16); if (hour0==3)Put3(16); if (hour0==4)Put4(16); if (hour0==5)Put5(16); if (hour0==6)Put6(16); if (hour0==7)Put7(16); if (hour0==8)Put8(16); if (hour0==9)Put9(16); GLCD_GotoXY(24,1); col(24); cbi(PORT_SPI,DD_DC); GLCD_GotoXY(32,1); sbi(PORT_SPI,DD_DC); if (min1==0)Put0(32); if (min1==1)Put1(32); if (min1==2)Put2(32); if (min1==3)Put3(32); if (min1==4)Put4(32);; if (min1==5)Put5(32); if (min1==6)Put6(32); if (min1==7)Put7(32); if (min1==8)Put8(32); if (min1==9)Put9(32); GLCD_GotoXY(40,1);if (min0==0)Put0(40); else if (min0==1)Put1(40); else if (min0==2)Put2(40); else if (min0==3)Put3(40); else if (min0==4)Put4(40); else if (min0==5)Put5(40); else if (min0==6)Put6(40); else if (min0==7)Put7(40); else if (min0==8)Put8(40); if (min0==9)Put9(40); GLCD_GotoXY(48,1);
  48. 48. col(48); cbi(PORT_SPI,DD_DC); GLCD_GotoXY(56,1); sbi(PORT_SPI,DD_DC); if (sec1==0)Put0(56); else if (sec1==1)Put1(56); else if (sec1==2)Put2(56); else if (sec1==3)Put3(56); else if (sec1==4)Put4(56); else if (sec1==5)Put5(56); else if (sec1==6)Put6(56); else if (sec1==7)Put7(56); else if (sec1==8)Put8(56); if (sec1==9)Put9(56); GLCD_GotoXY(64,1); if (sec0==0)Put0(64); else if (sec0==1)Put1(64); else if (sec0==2)Put2(64); else if (sec0==3)Put3(64); else if (sec0==4)Put4(64); else if (sec0==5)Put5(64); else if (sec0==6)Put6(64); else if (sec0==7)Put7(64); else if (sec0==8)Put8(64); if (sec0==9)Put9(64); cbi(PORT_SPI,DD_DC);}void setup(){ TCCR1B = (0<<CS12)|(1<<CS11)|(0<<CS10); char buf[RX_BUFSIZE]; TWBR = 8; USART_Init(1, 96); DDRC=0x00; PORTC=0x00; SPI_MasterInit(); sbi(DDR_SPI,DD_SS); sbi(PORT_SPI,DD_SS); GLCD_Init(); GLCD_GotoXY(0,0); Put(); delay_ms(3000); GLCD_Clear(); GLCD_Clear(); GLCD_GotoXY(0,0);
  49. 49. //GLCD_PutStr("TIME",1);}void settime(){ intdata1,data2,data3,data4,data5,data6,sec0,sec1,min0,min1,hour0,hour1,b,tran1,tran2,tran3; int a=1,i; b=1; Read_RTC(); while (PINC==0x7F) { sound (); } sec0=RTC.sec&0x0F; sec1=((RTC.sec&0xF0)); sec1=sec1>>4; min0=RTC.min&0x0F; min1=((RTC.min&0xF0)); min1=min1>>4; hour0= RTC.hour&0x0F; hour1= RTC.hour&0xF0; hour1=hour1>>4; data1=(hour1*10); data2=hour0; data1=(data1+data2); data3=(min1*10); data4=min0; data3=(data3+data4); data5=(sec1*10); data6=sec0; data5=(data5+data6); data2=(data1/10); data2=data2<<4; tran1=data1; tran1=tran1%10; tran1=tran1|data2; data4=(data3/10); data4=data4<<4; tran2=data3; tran2=tran2%10; tran2=tran2|data4; data6=(data5/10); data6=data6<<4; tran3=data5; tran3=tran3%10; tran3=tran3|data6;
  50. 50. TTTT(tran1,tran2,tran3);while(b<=3 & PINC!=0x7F){ delay_ms(150); if (PINC==0x7F)b++; while (PINC==0x7F) { TTTT(tran1,tran2,tran3); for (i=0;i<100;i++) { sound (); } } if (b==1) { GLCD_GotoXY(0,3); sbi(PORT_SPI,DD_DC); GLCD_Clear(); GLCD_PutStr("sethour",1); if (PINC==0xBF) { data1--; sound (); } if (PINC==0xDF) { data1++; sound (); } while (PINC==0xBF|PINC==0xDF) { TTTT(tran1,tran2,tran3); for (i=0;i<100;i++) { sound (); } } if (data1>23)data1=0; if (data1<0)data1=23; data2=(data1/10); data2=data2<<4; tran1=data1; tran1=tran1%10; tran1=tran1|data2; } if (b==2) {
  51. 51. GLCD_GotoXY(0,3); sbi(PORT_SPI,DD_DC); GLCD_Clear(); GLCD_PutStr("setmin",1); if (PINC==0xBF) { data3--; sound (); } if (PINC==0xDF) { data3++; sound (); } while (PINC==0xBF|PINC==0xDF) { TTTT(tran1,tran2,tran3); for (i=0;i<100;i++) { sound (); } } if (data3>59) { data3=0; sound (); } if (data3<0)data3=59; data4=(data3/10); data4=data4<<4; tran2=data3; tran2=tran2%10; tran2=tran2|data4;}if (b==3){ GLCD_GotoXY(0,3); sbi(PORT_SPI,DD_DC); GLCD_Clear(); GLCD_PutStr("setsec",1); if (PINC==0xBF) { data5--; sound (); } if (PINC==0xDF) { data5++;
  52. 52. sound (); } while (PINC==0xBF|PINC==0xDF) { TTTT(tran1,tran2,tran3); for (i=0;i<100;i++) { sound (); } } if (data5>59)data5=0; if (data5<0)data5=59; data6=(data5/10); data6=data6<<4; tran3=data5; tran3=tran3%10; tran3=tran3|data6; } TTTT(tran1,tran2,tran3);// } } DS1307_Write(0x00,tran3); DS1307_Write(0x01,tran2); DS1307_Write(0x02,tran1); while (PINC==0x7F) { } GLCD_Clear();}void init_timer(){ TCCR0 = 0x05;}int main (void){ init_timer(); DDRA = 0xFF; DDRC = 0x00; DDRE = 0xFF; PORTA = 0x00; PORTC = 0xFF; setup(); PORTA = 0x70;
  53. 53. unsigned int adc,count=0,sec=0,min=0,hour=0;char num=0,shour=0,smin=0,dh1=0,dm1=0,tran1=0,tran2=0,tran3=0,st=0,t=0;ADMUX =(0<<REFS1)|(1<<REFS0);ADCSRA = (1<<ADEN)|(0<<ADFR);ADCSRA |=(0<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);USART_Init(1, 96); // USART0 9800 bps, 8:N:1 using a 16MHz crystalwhile(1){ PORTA=PORTA&0xF8; //sound (); TTT(); ADCSRA |= (1<<ADSC); while (!(ADCSRA&(1<<ADIF))); adc = ADCW; printf("nADC = %d ",adc); _delay_ms(100); if(PINC == 0x7F) { settime(); sound (); } if((~PINC & 0x01) == 0x01) //*switch cooker on { //sound (); //debounce switch //on Heating coil is 3 then go to loop cooker //if temperature coil over 130c to complete //if cooker complete go to loop warm st = 1; tran1 = 0; tran2 = 0; smin = 0; shour = 0; while((~PINC & 0x01) == 0x01) { sound (); } GLCD_GotoXY(0,3); GLCD_PutStr("cooker",1); while(st = 1) { if((~PINC & 0x80) == 0x80) { //sound ();
  54. 54. st = 2; t = 1; while((~PINC & 0x80) == 0x80) {sound ();} //GLCD_PutStr("test time",1); while(st == 2) { if((~PINC & 0x01) == 0x01) { while((~PINC & 0x01) == 0x01) { sound (); } st = 0; } if((~PINC & 0x01) == 0x01) { while(((~PINC & 0x01) ==0x01)||((~PINC & 0x80) == 0x80)) { sound (); } st = 0; } if((~PINC & 0x20) == 0x20) { smin++; } if((~PINC & 0x40) == 0x40) { smin--; } while(((~PINC & 0x20) == 0x20) || ((~PINC &0x40) == 0x40)) { sound (); } if(smin > 59) smin = 0; if(smin < 0) smin = 59; dm1=(smin/10); dm1=dm1<<4; tran2=smin%10; tran2=tran2|dm1; printf("n%x",tran2); TTTT(tran1,tran2,tran3); if((~PINC & 0x80) == 0x80) {
  55. 55. st = 3; while((~PINC & 0x80) == 0x80) { sound (); } while(st == 3) { if((~PINC & 0x01) == 0x01) { while((~PINC &0x01) == 0x01) { sound (); } st = 1; } if((~PINC & 0x80) == 0x80) { while((~PINC &0x80) == 0x80) { sound (); } st = 1; } if((~PINC & 0x20) == 0x20) shour++; if((~PINC & 0x40) == 0x40)shour--; while(((~PINC & 0x20) ==0x20) || ((~PINC & 0x40) == 0x40)) { sound (); } if(shour > 59) shour = 0; if(shour < 0) shour = 59; dh1=(shour/10); dh1=dh1<<4; tran1=shour%10; tran1=tran1|dm1; printf("n%x",tran1); TTTT(tran1,tran2,tran3); } } } }
  56. 56. if(((~PINC & 0x01) == 0x01) && (t == 0)) { while((~PINC & 0x01) == 0x01) { sound (); } st = 0; } if(t >= 1) { while(t >= 1) { TTT(); if((TIFR & (1<<TOV0)) == 1) { TIFR = (1<<TOV0); count++; if(count > 59) { count = 0; sec++; if(sec > (59*6)) { sec = 0; min++; if(min > 59) { min = 0; hour++; if(hour >23) { hour = 0; } } } } if((hour == tran1) && (min ==tran2)) { t = 0; } } } st = 0; } while(st == 0)
  57. 57. { PORTA = 0x47; TTT(); ADCSRA |= (1<<ADSC); while (!(ADCSRA&(1<<ADIF))); adc = ADCW; printf("nADC = %d ",adc); _delay_ms(100); if(adc > 768) { PORTA = 0x00; while(1) { GLCD_GotoXY(0,3); GLCD_PutStr("Warm",1); TTT(); if((TIFR & (1<<TOV0)) == 1) { TIFR = (1<<TOV0); count++; if(count > 59) { count = 0; sec++; if(sec > (59*6)) { sec = 0; min++; if(min > 6) { min= 0; } } } if(min < 2) { PORTA = 0x46; } if((min > 2) && (min < 6)) { PORTA = 0x00; } } } } }
  58. 58. }}if((~PINC & 0x02) == 0x02)//*switch boiled on{ //debounce switch //on Heating coil is 3 //if temperature coil lower 100c to on Heating coil //check temperature if over 100c to off Heating coil while((~PINC & 0x02) == 0x02) { sound (); } GLCD_GotoXY(0,3); GLCD_PutStr("Boiled",1); while(1) { TTT(); ADCSRA |= (1<<ADSC); while (!(ADCSRA&(1<<ADIF))); adc = ADCW; printf("nADC = %d ",adc); _delay_ms(100); if(adc < 614) { PORTA = 0x17; } if(adc > 614) { PORTA = 0x00; } }}if((~PINC & 0x04) == 0x04)//*switch fried on{ //debounce switch //on Heating coil is 2 (at below and side) //if temperature coil lower 190c to on Heating coil //check temperature if over 190c to off Heating coil while((~PINC & 0x04) == 0x04) { sound (); } GLCD_GotoXY(0,3); GLCD_PutStr("Fried",1); while(1) { TTT();
  59. 59. ADCSRA |= (1<<ADSC); while (!(ADCSRA&(1<<ADIF))); adc = ADCW; printf("nADC = %d ",adc); _delay_ms(100); if(adc < 890) { PORTA = 0x17; } if(adc > 890) { PORTA = 0x00; } }}if((~PINC & 0x08) == 0x08)//*switch steamed on{ //debounce switch //on Heating coil is 3 //if temperature coil lower 100c to on Heating coil //check temperature if over 100c to off Heating coil while((~PINC & 0x08) == 0x08) { sound (); } GLCD_GotoXY(0,3); GLCD_PutStr("Steamed",1); while(1) { TTT(); ADCSRA |= (1<<ADSC); while (!(ADCSRA&(1<<ADIF))); adc = ADCW; printf("nADC = %d ",adc); _delay_ms(100); if(adc < 614) { PORTA = 0x27; } if(adc > 614) { PORTA = 0x00; } }}if((~PINC & 0x10) == 0x10)//*switch warm on{
  60. 60. //debounce switch //on Heating coil is 2(at top and side) //on Heating 5 min. off 5 min. no check temperature. while((~PINC & 0x10) == 0x10) { sound (); } GLCD_GotoXY(0,3); GLCD_PutStr("Warm",1); while(1) { TTT(); if((TIFR & (1<<TOV0)) == 1) { TIFR = (1<<TOV0); count++; if(count > 59) { count = 0; sec++; if(sec > (59*6)) { sec = 0; min++; if(min > 3) { min = 0; } } } if(min < 2) { PORTA = 0x27; } if((min > 2) && (min < 4)) { PORTA = 0x00; } } } } } return 0;}
  61. 61. Font/*! file font5x7.h brief Graphic LCD Font (Ascii Characters). *///*****************************************************************************//// File Name : font5x7.h// Title : Graphic LCD Font (Ascii Charaters)// Author : Pascal Stang// Date : 10/19/2001// Revised : 10/19/2001// Version : 0.1// Target MCU : Atmel AVR// Editor Tabs : 4////*****************************************************************************#ifndef FONT5X7_H#define FONT5X7_H// standard ascii 5x7 font// defines ascii characters 0x20-0x7F (32-127)static unsigned char __attribute__ ((progmem)) Font5x7[] = { 0x00, 0x00, 0x00, 0x00, 0x00,// (space) 0x00, 0x00, 0x5F, 0x00, 0x00,// ! 0x00, 0x07, 0x00, 0x07, 0x00,// " 0x14, 0x7F, 0x14, 0x7F, 0x14,// # 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ 0x23, 0x13, 0x08, 0x64, 0x62,// % 0x36, 0x49, 0x55, 0x22, 0x50,// & 0x00, 0x05, 0x03, 0x00, 0x00,// 0x00, 0x1C, 0x22, 0x41, 0x00,// ( 0x00, 0x41, 0x22, 0x1C, 0x00,// ) 0x08, 0x2A, 0x1C, 0x2A, 0x08,// * 0x08, 0x08, 0x3E, 0x08, 0x08,// + 0x00, 0x50, 0x30, 0x00, 0x00,// , 0x08, 0x08, 0x08, 0x08, 0x08,// - 0x00, 0x60, 0x60, 0x00, 0x00,// . 0x20, 0x10, 0x08, 0x04, 0x02,// / 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 0x42, 0x61, 0x51, 0x49, 0x46,// 2 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
  62. 62. 0x27, 0x45, 0x45, 0x45, 0x39,// 50x3C, 0x4A, 0x49, 0x49, 0x30,// 60x01, 0x71, 0x09, 0x05, 0x03,// 70x36, 0x49, 0x49, 0x49, 0x36,// 80x06, 0x49, 0x49, 0x29, 0x1E,// 90x00, 0x36, 0x36, 0x00, 0x00,// :0x00, 0x56, 0x36, 0x00, 0x00,// ;0x00, 0x08, 0x14, 0x22, 0x41,// <0x14, 0x14, 0x14, 0x14, 0x14,// =0x41, 0x22, 0x14, 0x08, 0x00,// >0x02, 0x01, 0x51, 0x09, 0x06,// ?0x32, 0x49, 0x79, 0x41, 0x3E,// @0x7E, 0x11, 0x11, 0x11, 0x7E,// A0x7F, 0x49, 0x49, 0x49, 0x36,// B0x3E, 0x41, 0x41, 0x41, 0x22,// C0x7F, 0x41, 0x41, 0x22, 0x1C,// D0x7F, 0x49, 0x49, 0x49, 0x41,// E0x7F, 0x09, 0x09, 0x01, 0x01,// F0x3E, 0x41, 0x41, 0x51, 0x32,// G0x7F, 0x08, 0x08, 0x08, 0x7F,// H0x00, 0x41, 0x7F, 0x41, 0x00,// I0x20, 0x40, 0x41, 0x3F, 0x01,// J0x7F, 0x08, 0x14, 0x22, 0x41,// K0x7F, 0x40, 0x40, 0x40, 0x40,// L0x7F, 0x02, 0x04, 0x02, 0x7F,// M0x7F, 0x04, 0x08, 0x10, 0x7F,// N0x3E, 0x41, 0x41, 0x41, 0x3E,// O0x7F, 0x09, 0x09, 0x09, 0x06,// P0x3E, 0x41, 0x51, 0x21, 0x5E,// Q0x7F, 0x09, 0x19, 0x29, 0x46,// R0x46, 0x49, 0x49, 0x49, 0x31,// S0x01, 0x01, 0x7F, 0x01, 0x01,// T0x3F, 0x40, 0x40, 0x40, 0x3F,// U0x1F, 0x20, 0x40, 0x20, 0x1F,// V0x7F, 0x20, 0x18, 0x20, 0x7F,// W0x63, 0x14, 0x08, 0x14, 0x63,// X0x03, 0x04, 0x78, 0x04, 0x03,// Y0x61, 0x51, 0x49, 0x45, 0x43,// Z0x00, 0x00, 0x7F, 0x41, 0x41,// [0x02, 0x04, 0x08, 0x10, 0x20,// ""0x41, 0x41, 0x7F, 0x00, 0x00,// ]0x04, 0x02, 0x01, 0x02, 0x04,// ^0x40, 0x40, 0x40, 0x40, 0x40,// _0x00, 0x01, 0x02, 0x04, 0x00,// `0x20, 0x54, 0x54, 0x54, 0x78,// a0x7F, 0x48, 0x44, 0x44, 0x38,// b0x38, 0x44, 0x44, 0x44, 0x20,// c0x38, 0x44, 0x44, 0x48, 0x7F,// d0x38, 0x54, 0x54, 0x54, 0x18,// e
  63. 63. 0x08, 0x7E, 0x09, 0x01, 0x02,// f 0x08, 0x14, 0x54, 0x54, 0x3C,// g 0x7F, 0x08, 0x04, 0x04, 0x78,// h 0x00, 0x44, 0x7D, 0x40, 0x00,// i 0x20, 0x40, 0x44, 0x3D, 0x00,// j 0x00, 0x7F, 0x10, 0x28, 0x44,// k 0x00, 0x41, 0x7F, 0x40, 0x00,// l 0x7C, 0x04, 0x18, 0x04, 0x78,// m 0x7C, 0x08, 0x04, 0x04, 0x78,// n 0x38, 0x44, 0x44, 0x44, 0x38,// o 0x7C, 0x14, 0x14, 0x14, 0x08,// p 0x08, 0x14, 0x14, 0x18, 0x7C,// q 0x7C, 0x08, 0x04, 0x04, 0x08,// r 0x48, 0x54, 0x54, 0x54, 0x20,// s 0x04, 0x3F, 0x44, 0x40, 0x20,// t 0x3C, 0x40, 0x40, 0x20, 0x7C,// u 0x1C, 0x20, 0x40, 0x20, 0x1C,// v 0x3C, 0x40, 0x30, 0x40, 0x3C,// w 0x44, 0x28, 0x10, 0x28, 0x44,// x 0x0C, 0x50, 0x50, 0x50, 0x3C,// y 0x44, 0x64, 0x54, 0x4C, 0x44,// z 0x00, 0x08, 0x36, 0x41, 0x00,// { 0x00, 0x00, 0x7F, 0x00, 0x00,// | 0x00, 0x41, 0x36, 0x08, 0x00,// } 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> 0x08, 0x1C, 0x2A, 0x08, 0x08 // <-};#endif
  64. 64. Appendix A Manual
  65. 65. Appendix C Datasheet
  66. 66. Measuring the resistance compared with temperatureDegree MIN MEDIAN MAX Degree MIN MEDIAN MAX26.00 92.70 93.70 94.50 65.00 18.80 19.20 19.2027.00 90.90 91.30 91.90 66.00 18.10 18.10 18.4028.00 87.20 87.50 88.30 67.00 17.20 17.40 17.6029.00 82.40 83.40 83.80 68.00 16.56 16.70 16.8030.00 79.30 79.70 80.80 69.00 15.70 15.96 16.2231.00 77.50 78.80 79.00 70.00 15.30 15.31 15.6032.00 74.10 75.20 76.90 71.00 14.84 14.90 15.1433.00 71.30 71.90 73.20 72.00 14.15 14.30 14.5534.00 68.70 69.20 70.10 73.00 13.61 13.70 14.0135.00 64.90 65.50 66.50 74.00 13.21 13.30 13.4836.00 62.20 62.80 63.50 75.00 12.30 12.82 13.0837.00 58.90 59.20 61.00 76.00 12.46 12.55 12.7938.00 56.90 57.00 57.90 77.00 11.93 12.00 12.3239.00 54.00 55.00 55.40 78.00 11.73 11.80 12.0740.00 52.30 52.90 53.10 79.00 11.08 11.50 11.6141.00 50.10 50.20 50.30 80.00 10.78 10.91 11.2042.00 47.10 47.90 48.40 81.00 10.56 10.76 10.8043.00 44.90 45.60 46.30 82.00 10.10 10.21 10.2344.00 43.00 44.20 44.80 83.00 9.80 10.03 10.0345.00 41.90 42.00 42.60 84.00 9.40 9.54 9.7346.00 40.10 40.80 41.20 85.00 9.18 9.20 9.6347.00 38.70 38.90 39.30 86.00 8.64 8.80 8.9048.00 36.90 37.30 37.80 87.00 8.10 8.20 8.3849.00 35.80 35.90 36.70 88.00 7.63 7.90 7.9550.00 33.50 33.70 34.60 89.00 7.48 7.51 7.7551.00 31.90 32.20 33.20 90.00 7.22 7.25 7.3352.00 29.80 30.60 31.00 91.00 7.07 7.09 7.1753.00 28.90 29.40 30.10 92.00 6.92 6.97 7.0254.00 28.30 28.60 29.30 93.00 6.77 6.83 6.9155.00 26.50 27.10 28.10 94.00 6.41 6.65 6.7456.00 26.30 26.60 27.20 95.00 6.23 6.31 6.4257.00 25.00 25.60 26.70 96.00 5.94 6.18 6.2258.00 24.10 24.30 25.60 97.00 5.73 5.81 5.9959.00 23.00 23.50 23.80 98.00 5.55 5.61 5.7460.00 21.80 22.20 22.80 99.00 5.32 5.43 5.4361.00 21.10 21.80 22.10 100.00 5.22 5.24 5.2862.00 20.30 20.80 21.40 101.00 5.10 5.13 5.2063.00 19.80 20.00 20.20 102.00 4.92 5.08 5.1264.00 19.20 19.60 19.80 103.00 4.78 4.80 4.86
  67. 67. Degree MIN MEDIAN MAX Degree MIN MEDIAN MAX104.00 4.59 4.69 4.72 146.00 0.32 1.32 1.34105.00 4.55 4.61 4.70 147.00 0.30 1.31 1.32106.00 4.47 4.55 4.62 148.00 1.29 1.29 1.31107.00 4.30 4.39 4.52 149.00 0.25 1.27 1.28108.00 4.18 4.27 4.27 150.00 1.23 1.24 1.24109.00 4.09 4.15 4.19 151.00 1.19 1.19 1.21110.00 3.88 4.09 4.15 152.00 1.17 1.17 1.19111.00 3.84 4.01 4.11 153.00 1.14 1.15 1.16112.00 3.80 4.04 4.91 154.00 1.11 1.12 1.15113.00 3.32 3.77 3.96 155.00 1.08 1.09 1.12114.00 3.15 3.69 3.75 156.00 1.05 1.06 1.08115.00 3.02 3.58 3.71 157.00 1.01 1.03 1.03116.00 3.00 3.50 3.65 158.00 1.00 1.00 1.01117.00 2.96 3.46 3.51 159.00 0.99 0.99 1.00118.00 2.88 3.39 3.47 160.00 0.982 0.986 0.993119.00 2.82 3.30 3.33 161.00 0.972 0.976 0.984120.00 2.67 3.19 3.29 162.00 0.954 0.957 0.966121.00 2.61 3.11 3.15 163.00 0.935 0.940 0.948104.00 4.59 4.69 4.72 164.00 0.920 0.928 0.931122.00 2.57 2.91 3.05 165.00 0.910 0.910 0.911123.00 2.54 2.86 2.88 166.00 0.892 0.894 0.899124.00 2.50 2.75 2.80 167.00 0.870 0.873 0.874125.00 2.49 2.59 2.74 168.00 0.839 0.849 0.855126.00 2.47 2.56 2.65 169.00 0.810 0.821 0.832127.00 2.46 2.50 2.59 170.00 0.791 0.798 0.816128.00 2.44 2.47 2.51 171.00 0.776 0.780 0.788129.00 2.39 2.44 2.45 172.00 0.760 0.764 0.765130.00 2.36 2.36 2.38 173.00 0.746 0.748 0.750131.00 2.27 2.32 2.34 174.00 0.737 0.739 0.741132.00 2.18 2.24 2.27 175.00 0.728 0.732 0.733133.00 2.09 2.11 2.15 176.00 0.717 0.720 0.724134.00 1.98 2.03 2.09 177.00 0.709 0.712 0.712135.00 1.91 1.93 2.00 178.00 0.698 0.699 0.700136.00 1.85 1.89 1.91 179.00 0.683 0.683 0.692137.00 1.78 1.79 1.81 180.00 0.659 0.660 0.670138.00 1.62 1.69 1.74 181.00 0.635 0.642 0.657139.00 1.58 1.65 1.65 182.00 0.611 0.617 0.621140.00 1.52 1.55 1.62 183.00 0.599 0.601 0.603141.00 1.49 1.51 1.52 184.00 0.577 0.583 0.589142.00 1.44 1.46 1.48 185.00 0.565 0.567 0.568143.00 1.40 1.41 1.43 186.00 0.550 0.551 0.559144.00 1.36 1.37 1.38 187.00 0.538 0.541 0.545145.00 1.34 1.35 1.35 188.00 0.530 0.534 0.535
  68. 68. Degree MIN MEDIAN MAX189.00 0.512 0.515 0.523190.00 0.490 0.501 0.505191.00 0.472 0.474 0.487192.00 0.462 0.465 0.467193.00 0.453 0.454 0.460194.00 0.444 0.449 0.451195.00 0.439 0.444 0.448196.00 0.427 0.436 0.436197.00 0.421 0.424 0.425198.00 0.412 0.413 0.418199.00 0.402 0.406 0.406200.00 0.391 0.396 0.400201.00 0.389 0.390 0.393202.00 0.378 0.381 0.388

×