SlideShare a Scribd company logo
1 of 68
Download to read offline
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 the
Application 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
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 the
Application 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
Chapter 1
                                           Preface

1.1 Name of project: ConThai Rice Cooker

1.2 The origin of project
          From nowadays Thai people eat rice less every year. Next Thai people consume rice
have tendency keep lower. And consumption rice in Asia have 200 kilograms per year but
number of Thai consume have 100 – 110 kilograms per year.
          My world into full consumption war, have fast, convenient, save. That is necessary for
consume rice. Rice has to adapt to a wide variety of markets. Amid the hustle of urban life which
always a race against time. That’s need to use something for convenient to reduce time. So eat
rice in morning meal look like busy because it’s not support with life style that has changed. And
we got culture from west that has effect with people in town consumption. So we can see quantity
consume 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 more
convenient.

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.
1-2



1.4 Procedure
          Procedure is starting from search information about rice cooking at using and used then
design system of rice cooking for overview structure in this device. Detail working procedure as
follow.
            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 5
1. Research rice cocker
2. Hardware
3. Microcontroller
4. Design circuit
5. Buy hardware device
6. Compound circuit
7. Test circuit
8. Adjust
9. Made report
1-3



1.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.
Chapter 2
                                            Theory

2.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 lose
power at less. Transformer can work with alternative only and that is the reason, why current in
home 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 in
home that have height voltage (220 V) and dangerous to lower for safety.
          Input inductor is called primary and output inductor is called secondary between both
doesn’t connect in current but use connection by alternative magnetic field is in transformer
magnetic 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 ratio
transformer step-down. The number of round much is primary coil, connect to 220 volt is input
and output is secondary coil has number of round few, give low voltage.
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. This
is 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 have
induce 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 is
same pond, it give current to output, when smoothing is AC voltage drop. In figure is show not
filter direct current and filter direct current. Capacitor is fast evolve at peak of direct current and
Capacitor evolve to output.
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 alternative
current 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 peak
1.4 × 4.6 = 6.4 V (DC).
          Filtration is not perfect because have little voltage of capacitor when evolve. It is cause
small ripple. For general circuit, supply have ripple 10 % is able. Value of capacitor on
smoothing. It can find to equation below. If capacitor is big size will have little ripple. For half
wave 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 value
number 7805 +5 V 1 A. Show in right hand. Front have install.
2-4




                                  Figure 2-5 IC control voltage


2.2 TRIAC
           TRIAC is semiconductor transistor group. It has inside structure same with DIAC, but
has one more leg. TRIAC is create for modify error SCR. When not induce current in negative
alternative current. Most application of TRIAC will use control circuit is switch connect to
alternative current. TRIAC is create high current also will must careful in drain heat. Structure of
TRIAC 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 positive
voltage trig to G.
             2.2.1.2 Give positive voltage to MT2. Give negative voltage to MT1 and give
negative voltage trig to G.
             2.2.1.3 Give negative voltage to MT2. Give positive voltage to MT1 and give
negative voltage trig to G.
2-5


             2.2.1.4 Give negative voltage to MT2. Give positive voltage to MT1 and give positive
voltage 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 will
continue 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 to
TRIAC lower holding current of TRIAC.

2.3 Sensor
         2.3.1 Thermostat
         Thermostat in digital rice cooking is difference general rice cooking. General rice
cooking consists of Lever Contact Switch and magnetic set. Diode run by magnetic deteriorate
when have high heat. But thermostat in digital rice cooking is measure temperature and send to
microcontroller 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 power
supply. Resistance is portion out voltage in circuit. General voltage divider circuit is develop from
Ohm’s law. Calculate is cross voltage on resistance use voltage divider will fast and be
convenient than Ohm’s law.




                             Figure 2-8 Show voltage divider circuit
2-6


2.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. The
noise surrounding the rice cooker will serve as the command to start the circuit. The LED lamps
installed around. The bottom of the cooker took place light and not light. There is sound order of
the LED, on-off for 15 seconds. And it will run again when there's sound around.


          2.4.3 Timing diagram



     Sound




Comparator




 Time Delay
                                     15 sec.



                      Figure 2-10 Timing diagram check the power circuit
2-7


            2.4.4 The works circuit
            2.4.4.1 Sound detection has received sound from microphone. And voltage sent to
Comparator 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-stable
circuit from IC 555 and using output base bias transistor by BC337. Which is switch control
voltage 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 the
device 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
2-8


2.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
Chapter 3
                                    Circuit and Design

           This chapter discusses the various parts of the circuit. And explain the function of the
circuit 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 1A
in U1 has diode for project to flow one way. In U2 use lm7805 for convent from 9VDC current
1A to 5VDC current 1A for get to use with microcontroller and U3 use lm7805 convent to 5VDC
current 1A for get to use with sensor.
3-2


3.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Ω
3-3


3.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
3-4


Calculate V3min, when RT = 111 kΩ, R3 = 10 kΩ
                 V3min = VT (R T )
                             R3

                                 10 kΩ
                       = 5V(111 kΩ )
                 V3min = 0.4504 V

Calculate IT, when E = 5V, RT = 11 kΩ
                           V
                     IT = (R T )
                             T
                             5V
                       = (11 kΩ )
                     IT = 0.45 mA

Calculate 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 V

Calculate 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 V

Calculate 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 V

Calculate 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
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
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= 14k


3.5 Touch switch circuit




                        Figure 3-6 IC Show using WB2080A Circuit
3-7


3.6 Microcontroller




                      Figure 3-7 Show using ATMEGA12



.
Chapter 4
                    Structure of Programming Controller

4.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.
4-2


                                START     s




   Cooker                       Boiled                             Stream




Set time cook               If temp >100 c                     If temp > 100 c




    Cook
                                                False                            False
                                  SW                                 SW



  Cook =
                                       True                               True
 on2heater

                             OFF heater all                     OFF heater all

If temp >130 c




                  False
     SW



           True

    Warm



                          Figure 4-1 Flow chart main program
4-3

                                  START




    Fried                          Warm                         Set time




If temp >190 c                 If time >2min                    Set hour



                                               False
                   False
     SW                              SW                         Hour +1 -1

                                                                    -1

            True                          True


OFF 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
Chapter 5
                             Experiments and conclusion

5.1 Preface
          After pass programming step each part and design circuit the most important by the
way 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 component
part 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 approximately
3 seconds).
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 and
Automatic 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 proper
standard
            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 as
the main function.
            5.5.2.2 Microcontroller sends data and information to display monitor then our group
name, Conthai, shows on the display.
            5.5.2.3 Setting time by press on time setting function bottom to adjust hour, minute
and 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. The
selected 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 achieve
testing objective. Please turn to next unit for more information about obstacles and solution
during working process.
Chapter 6
                                Problems and suggestions


6.1 Preface
          In this project has many problems, because this project use electronic device to max
efficiency for work and to divide the problem into 2 types of problems that are Software and
Hardware.

6.2 Problem and Solving
In this project has problem about Software and Hardware, so we divide the problem and solve as
follows.
           6.2.1 First step I see problem that is to used hardware devices are difficult, because we
must 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 find
yank voltage. It made some circuit to error. So we solve by turn on power supply before connect
the circuit after that to measure each circuit.
           6.2.3 Third, when we made PCB after check line PCB. When we test circuit are find
bash 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 by
multi-meter.
           6.2.5 Touch switch in circuits are find shield cable have ground around cable, when we
stripping the wire and weld to copper plate. Found that circuit.
           6.3.6 In part microcontroller problems is FUSES attached from factory, it's not same
our experiments. It is not possible to perform experiments. It can’t possible to perform
experiments. Solution is use boards by program to list variable into experiments to fix variable 2
FUSES 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
6-2


changing the resistance less valuable so the stream flows sufficient to trigger on for the TRIAC
and selection resistor for range 1 watt.
Contents

Chapter 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-3
Chapter 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-7
Chapter 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-7
Chapter 4 Structure of Programming Controller      4-1
          4.1 Operation of program                 4-1
Chapter 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
Contents (contd.)

          5.6 Conclusion                                 5-2
Chapter 6 Problems and suggestions                       6-1
          6.1 Preface                                    6-1
          6.2 Problem and Solving                        6-1
Appendix A Manual
Appendix B Programming
Appendix C Datasheet
Figures

Figure 2-1 Block Diagram Power supply                             2-1
Figure 2-2 Bridge rectifier circuit                               2-2
Figure 2-3 Full wave bridge diode                                 2-2
Figure 2-4 Show is charge and discharge of capacitor              2-3
Figure 2-5 IC control voltage                                     2-4
Figure 2-6 Structure of TRIAC                                     2-4
Figure 2-7 Symbol of TRIAC                                        2-4
Figure 2-8 Show voltage divider circuit                           2-5
Figure 2-9 Block Diagram check the power circuit                  2-6
Figure 2-10 Timing diagram check the power circuit                2-6
Figure 2-11 Display graphic ET-NOKIA LCD 5110                     2-7
Figure 2.12 AT mega 128                                           2-8
Figure 3-1 Power supply circuit                                   3-1
Figure 3-2 TRIAC circuit                                          3-2
Figure 3-3 Voltage divider circuit                                3-3
Figure 3-4 The relationship between resistance and temperature.   3-5
Figure 3-5 Show using IC 555 circuit                              3-5
Figure 3-6 IC Show using WB2080A Circuit                          3-6
Figure 3-7 Show using ATMEGA12                                    3-7
Figure 4-1 Flow chart main program                                4-2
Figure 4-2 Flow chart main program                                4-3
Appendix B
Programming
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--)
_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 ()
{
        {
_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_MasterTransmit(pgm_read_byte(&Font5x7[p++]));
         }
         if (sp)SPI_MasterTransmit(0x00);
}

void GLCD_PutStr(uint8_t *str,uint8_t sp)
{
       sbi(PORT_SPI,DD_DC);
       while(*str){
               GLCD_PutChar(*str++,sp);
       }
}

void Put(void)
{
        sbi(PORT_SPI,DD_DC);
        int p[]=
        {
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F,
0x1F, 0xFF, 0xFF,
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                 0xFF, 0xFF, 0xFF, 0xFF,
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0xC0, 0xF8,
0x00, 0x01, 0x1F,
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xF1,
0xF1, 0xF1, 0xF1, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                0xFF, 0xFF, 0xFF, 0xFF,
                0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x01, 0x80, 0xF8, 0xFF, 0xFF,
0xFF, 0xF0, 0x00,
                0x03, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x07, 0xC3, 0xE1, 0xF1,
0xF1, 0xE1, 0xC3,
                0x07, 0x0F, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x03,
                0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x1F, 0x87, 0xC3,
0xE3, 0xE3, 0xE3,
                0xC3, 0x07, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x87, 0xC3, 0xE3, 0xE3,
0xC3, 0xC7, 0x07,
                0x1F, 0x7F, 0xFF, 0xFF,
                0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x8F, 0x8F, 0xCF, 0xCF,
0xFF, 0xFF, 0xFE,
                0xC0, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x3C, 0x3F, 0x1F, 0x1F, 0x0F,
0xFF, 0xFF, 0xFF,
                0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0x00,
                0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xF8, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x0F,
0x1F, 0xFF, 0xFF,
                0xF0, 0xF0, 0xFF, 0xFF,
                0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0xE0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                0xFF, 0xFC, 0x80, 0x00, 0x0F, 0xFF, 0xFF, 0x00, 0x00, 0x7E, 0xFF, 0xFF, 0xFF,
0xFF, 0x7F, 0x1F,
                0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xC0, 0x00, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F,
0x1F, 0x01, 0x00,
                0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x80, 0x07, 0x3F, 0x7F, 0xFF, 0xFF,
0xFF, 0x7F, 0x1F,
                0x03, 0xC1, 0xFF, 0xFF,
                0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xF9, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xF0, 0xF0,
0xF8, 0xF8, 0xFE,
                0xFE, 0xF8, 0xF8, 0xF8, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8,
0xFE, 0xFF, 0xF8,
                0xF8, 0xFF, 0xFF, 0xF8, 0xF8, 0xF8, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF,
                0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0,
0xF0, 0xF8, 0xFC,
                0xFE, 0xFF, 0xFF, 0xFF,
};
       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
        };
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]);
}
}

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]);
        }
}
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)
{
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[]=
{
               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);
}
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
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
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;
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);
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);
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);
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);
//GLCD_PutStr("TIME",1);
}

void settime()
{
        int
data1,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;
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)
       {
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++;
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;
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 crystal

while(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 ();
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)
                                          {
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);

                                             }
                                         }

                                     }
                               }
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)
{
                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;
                                          }
                                 }
                        }
                }
       }
}
}

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();
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
{
//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;
}
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
0x27, 0x45, 0x45, 0x45, 0x39,// 5
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
0x01, 0x71, 0x09, 0x05, 0x03,// 7
0x36, 0x49, 0x49, 0x49, 0x36,// 8
0x06, 0x49, 0x49, 0x29, 0x1E,// 9
0x00, 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,// A
0x7F, 0x49, 0x49, 0x49, 0x36,// B
0x3E, 0x41, 0x41, 0x41, 0x22,// C
0x7F, 0x41, 0x41, 0x22, 0x1C,// D
0x7F, 0x49, 0x49, 0x49, 0x41,// E
0x7F, 0x09, 0x09, 0x01, 0x01,// F
0x3E, 0x41, 0x41, 0x51, 0x32,// G
0x7F, 0x08, 0x08, 0x08, 0x7F,// H
0x00, 0x41, 0x7F, 0x41, 0x00,// I
0x20, 0x40, 0x41, 0x3F, 0x01,// J
0x7F, 0x08, 0x14, 0x22, 0x41,// K
0x7F, 0x40, 0x40, 0x40, 0x40,// L
0x7F, 0x02, 0x04, 0x02, 0x7F,// M
0x7F, 0x04, 0x08, 0x10, 0x7F,// N
0x3E, 0x41, 0x41, 0x41, 0x3E,// O
0x7F, 0x09, 0x09, 0x09, 0x06,// P
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
0x7F, 0x09, 0x19, 0x29, 0x46,// R
0x46, 0x49, 0x49, 0x49, 0x31,// S
0x01, 0x01, 0x7F, 0x01, 0x01,// T
0x3F, 0x40, 0x40, 0x40, 0x3F,// U
0x1F, 0x20, 0x40, 0x20, 0x1F,// V
0x7F, 0x20, 0x18, 0x20, 0x7F,// W
0x63, 0x14, 0x08, 0x14, 0x63,// X
0x03, 0x04, 0x78, 0x04, 0x03,// Y
0x61, 0x51, 0x49, 0x45, 0x43,// Z
0x00, 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,// a
0x7F, 0x48, 0x44, 0x44, 0x38,// b
0x38, 0x44, 0x44, 0x44, 0x20,// c
0x38, 0x44, 0x44, 0x48, 0x7F,// d
0x38, 0x54, 0x54, 0x54, 0x18,// e
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
Appendix A
 Manual
Appendix C
 Datasheet
Measuring the resistance compared with temperature

Degree   MIN     MEDIAN   MAX       Degree   MIN     MEDIAN   MAX
26.00    92.70    93.70   94.50    65.00     18.80    19.20   19.20
27.00    90.90    91.30   91.90    66.00     18.10    18.10   18.40
28.00    87.20    87.50   88.30    67.00     17.20    17.40   17.60
29.00    82.40    83.40   83.80    68.00     16.56    16.70   16.80
30.00    79.30    79.70   80.80    69.00     15.70    15.96   16.22
31.00    77.50    78.80   79.00    70.00     15.30    15.31   15.60
32.00    74.10    75.20   76.90    71.00     14.84    14.90   15.14
33.00    71.30    71.90   73.20    72.00     14.15    14.30   14.55
34.00    68.70    69.20   70.10    73.00     13.61    13.70   14.01
35.00    64.90    65.50   66.50    74.00     13.21    13.30   13.48
36.00    62.20    62.80   63.50    75.00     12.30    12.82   13.08
37.00    58.90    59.20   61.00    76.00     12.46    12.55   12.79
38.00    56.90    57.00   57.90    77.00     11.93    12.00   12.32
39.00    54.00    55.00   55.40    78.00     11.73    11.80   12.07
40.00    52.30    52.90   53.10    79.00     11.08    11.50   11.61
41.00    50.10    50.20   50.30    80.00     10.78    10.91   11.20
42.00    47.10    47.90   48.40    81.00     10.56    10.76   10.80
43.00    44.90    45.60   46.30    82.00     10.10    10.21   10.23
44.00    43.00    44.20   44.80    83.00     9.80     10.03   10.03
45.00    41.90    42.00   42.60    84.00     9.40     9.54    9.73
46.00    40.10    40.80   41.20    85.00     9.18     9.20    9.63
47.00    38.70    38.90   39.30    86.00     8.64     8.80    8.90
48.00    36.90    37.30   37.80    87.00     8.10     8.20    8.38
49.00    35.80    35.90   36.70    88.00     7.63     7.90    7.95
50.00    33.50    33.70   34.60    89.00     7.48     7.51    7.75
51.00    31.90    32.20   33.20    90.00     7.22     7.25    7.33
52.00    29.80    30.60   31.00    91.00     7.07     7.09    7.17
53.00    28.90    29.40   30.10    92.00     6.92     6.97    7.02
54.00    28.30    28.60   29.30    93.00     6.77     6.83    6.91
55.00    26.50    27.10   28.10    94.00     6.41     6.65    6.74
56.00    26.30    26.60   27.20    95.00     6.23     6.31    6.42
57.00    25.00    25.60   26.70    96.00     5.94     6.18    6.22
58.00    24.10    24.30   25.60    97.00     5.73     5.81    5.99
59.00    23.00    23.50   23.80    98.00     5.55     5.61    5.74
60.00    21.80    22.20   22.80    99.00     5.32     5.43    5.43
61.00    21.10    21.80   22.10    100.00    5.22     5.24    5.28
62.00    20.30    20.80   21.40    101.00    5.10     5.13    5.20
63.00    19.80    20.00   20.20    102.00    4.92     5.08    5.12
64.00    19.20    19.60   19.80    103.00    4.78     4.80    4.86
Degree   MIN    MEDIAN   MAX    Degree   MIN     MEDIAN   MAX
104.00   4.59    4.69    4.72   146.00   0.32     1.32    1.34
105.00   4.55    4.61    4.70   147.00   0.30     1.31    1.32
106.00   4.47    4.55    4.62   148.00   1.29     1.29    1.31
107.00   4.30    4.39    4.52   149.00   0.25     1.27    1.28
108.00   4.18    4.27    4.27   150.00   1.23     1.24    1.24
109.00   4.09    4.15    4.19   151.00   1.19     1.19    1.21
110.00   3.88    4.09    4.15   152.00   1.17     1.17    1.19
111.00   3.84    4.01    4.11   153.00   1.14     1.15    1.16
112.00   3.80    4.04    4.91   154.00   1.11     1.12    1.15
113.00   3.32    3.77    3.96   155.00   1.08     1.09    1.12
114.00   3.15    3.69    3.75   156.00   1.05     1.06    1.08
115.00   3.02    3.58    3.71   157.00   1.01     1.03    1.03
116.00   3.00    3.50    3.65   158.00   1.00     1.00    1.01
117.00   2.96    3.46    3.51   159.00   0.99     0.99    1.00
118.00   2.88    3.39    3.47   160.00   0.982    0.986   0.993
119.00   2.82    3.30    3.33   161.00   0.972    0.976   0.984
120.00   2.67    3.19    3.29   162.00   0.954    0.957   0.966
121.00   2.61    3.11    3.15   163.00   0.935    0.940   0.948
104.00   4.59    4.69    4.72   164.00   0.920    0.928   0.931
122.00   2.57    2.91    3.05   165.00   0.910    0.910   0.911
123.00   2.54    2.86    2.88   166.00   0.892    0.894   0.899
124.00   2.50    2.75    2.80   167.00   0.870    0.873   0.874
125.00   2.49    2.59    2.74   168.00   0.839    0.849   0.855
126.00   2.47    2.56    2.65   169.00   0.810    0.821   0.832
127.00   2.46    2.50    2.59   170.00   0.791    0.798   0.816
128.00   2.44    2.47    2.51   171.00   0.776    0.780   0.788
129.00   2.39    2.44    2.45   172.00   0.760    0.764   0.765
130.00   2.36    2.36    2.38   173.00   0.746    0.748   0.750
131.00   2.27    2.32    2.34   174.00   0.737    0.739   0.741
132.00   2.18    2.24    2.27   175.00   0.728    0.732   0.733
133.00   2.09    2.11    2.15   176.00   0.717    0.720   0.724
134.00   1.98    2.03    2.09   177.00   0.709    0.712   0.712
135.00   1.91    1.93    2.00   178.00   0.698    0.699   0.700
136.00   1.85    1.89    1.91   179.00   0.683    0.683   0.692
137.00   1.78    1.79    1.81   180.00   0.659    0.660   0.670
138.00   1.62    1.69    1.74   181.00   0.635    0.642   0.657
139.00   1.58    1.65    1.65   182.00   0.611    0.617   0.621
140.00   1.52    1.55    1.62   183.00   0.599    0.601   0.603
141.00   1.49    1.51    1.52   184.00   0.577    0.583   0.589
142.00   1.44    1.46    1.48   185.00   0.565    0.567   0.568
143.00   1.40    1.41    1.43   186.00   0.550    0.551   0.559
144.00   1.36    1.37    1.38   187.00   0.538    0.541   0.545
145.00   1.34    1.35    1.35   188.00   0.530    0.534   0.535
Degree   MIN     MEDIAN   MAX
189.00   0.512    0.515   0.523
190.00   0.490    0.501   0.505
191.00   0.472    0.474   0.487
192.00   0.462    0.465   0.467
193.00   0.453    0.454   0.460
194.00   0.444    0.449   0.451
195.00   0.439    0.444   0.448
196.00   0.427    0.436   0.436
197.00   0.421    0.424   0.425
198.00   0.412    0.413   0.418
199.00   0.402    0.406   0.406
200.00   0.391    0.396   0.400
201.00   0.389    0.390   0.393
202.00   0.378    0.381   0.388

More Related Content

Viewers also liked

Control estratégico (parte quinta)
Control estratégico (parte quinta)Control estratégico (parte quinta)
Control estratégico (parte quinta)
Bryan Quijije
 
Vinculación Estatal
Vinculación EstatalVinculación Estatal
Vinculación Estatal
ucvps
 
Introduction to Social Media Overview (Feb12)
Introduction to Social Media Overview (Feb12)Introduction to Social Media Overview (Feb12)
Introduction to Social Media Overview (Feb12)
rlabsza
 
Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...
Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...
Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...
Biblioteca Virtual
 
Administración definitivo
Administración definitivoAdministración definitivo
Administración definitivo
Karolina Mndza A
 
Intertextualidad en la produccion escrita
Intertextualidad en la produccion escritaIntertextualidad en la produccion escrita
Intertextualidad en la produccion escrita
Jorge Suarez
 
TargetAnnual Report2007
TargetAnnual Report2007TargetAnnual Report2007
TargetAnnual Report2007
finance4
 

Viewers also liked (20)

Wearable Technology Part 1 Blue Paper
Wearable Technology Part 1 Blue Paper Wearable Technology Part 1 Blue Paper
Wearable Technology Part 1 Blue Paper
 
Control estratégico (parte quinta)
Control estratégico (parte quinta)Control estratégico (parte quinta)
Control estratégico (parte quinta)
 
nes Educativas.
nes Educativas.nes Educativas.
nes Educativas.
 
Radiaciones no ionizantes explicacion
Radiaciones no ionizantes explicacionRadiaciones no ionizantes explicacion
Radiaciones no ionizantes explicacion
 
Vinculación Estatal
Vinculación EstatalVinculación Estatal
Vinculación Estatal
 
Eindrapportage Arbeidsmarkt Internet De Grote Uittocht
Eindrapportage Arbeidsmarkt Internet De Grote UittochtEindrapportage Arbeidsmarkt Internet De Grote Uittocht
Eindrapportage Arbeidsmarkt Internet De Grote Uittocht
 
OCP Full Report
OCP Full ReportOCP Full Report
OCP Full Report
 
Mercury in Skin Lightening Products
Mercury in Skin Lightening Products Mercury in Skin Lightening Products
Mercury in Skin Lightening Products
 
Sistemas Operativos
Sistemas OperativosSistemas Operativos
Sistemas Operativos
 
Introduction to Social Media Overview (Feb12)
Introduction to Social Media Overview (Feb12)Introduction to Social Media Overview (Feb12)
Introduction to Social Media Overview (Feb12)
 
Modelo educativo
Modelo educativoModelo educativo
Modelo educativo
 
Nicolas
NicolasNicolas
Nicolas
 
Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...
Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...
Unsafe Sleep Practices And An Analysis Of Bedsharing Among Infants Dying Sudd...
 
Mexico
MexicoMexico
Mexico
 
Administración definitivo
Administración definitivoAdministración definitivo
Administración definitivo
 
Intertextualidad en la produccion escrita
Intertextualidad en la produccion escritaIntertextualidad en la produccion escrita
Intertextualidad en la produccion escrita
 
Sistemas operativos
Sistemas operativos Sistemas operativos
Sistemas operativos
 
TargetAnnual Report2007
TargetAnnual Report2007TargetAnnual Report2007
TargetAnnual Report2007
 
Ch06s
Ch06sCh06s
Ch06s
 
On Bernstein Polynomials
On Bernstein PolynomialsOn Bernstein Polynomials
On Bernstein Polynomials
 

Similar to Con thai

Sushant 131119022958-phpapp02
Sushant 131119022958-phpapp02Sushant 131119022958-phpapp02
Sushant 131119022958-phpapp02
K. Suresh Kumar
 
securedroomaccessproject-150718081732-lva1-app6892
securedroomaccessproject-150718081732-lva1-app6892securedroomaccessproject-150718081732-lva1-app6892
securedroomaccessproject-150718081732-lva1-app6892
shreya sankrityayan
 

Similar to Con thai (20)

Irrigation
IrrigationIrrigation
Irrigation
 
Sushant 131119022958-phpapp02
Sushant 131119022958-phpapp02Sushant 131119022958-phpapp02
Sushant 131119022958-phpapp02
 
a simple mobile battery charger with inverter (ups) &night switch
a simple mobile battery charger with inverter (ups) &night switcha simple mobile battery charger with inverter (ups) &night switch
a simple mobile battery charger with inverter (ups) &night switch
 
Automatic Plant Irrigator -Mini Project ECE(without micro controller)
Automatic Plant Irrigator -Mini Project ECE(without micro controller) Automatic Plant Irrigator -Mini Project ECE(without micro controller)
Automatic Plant Irrigator -Mini Project ECE(without micro controller)
 
Automatic Phase Changer
Automatic Phase ChangerAutomatic Phase Changer
Automatic Phase Changer
 
Narendra parmar
Narendra parmarNarendra parmar
Narendra parmar
 
Solar Driven Automatic Water Level Controller with Dry Run Protection
Solar Driven Automatic Water Level Controller with Dry Run ProtectionSolar Driven Automatic Water Level Controller with Dry Run Protection
Solar Driven Automatic Water Level Controller with Dry Run Protection
 
Report on PCB designing and fabrication by Prince Rohan
Report on PCB designing and fabrication by Prince RohanReport on PCB designing and fabrication by Prince Rohan
Report on PCB designing and fabrication by Prince Rohan
 
Finalist 1 PPT Aman.pptx
Finalist 1 PPT Aman.pptxFinalist 1 PPT Aman.pptx
Finalist 1 PPT Aman.pptx
 
securedroomaccessproject-150718081732-lva1-app6892
securedroomaccessproject-150718081732-lva1-app6892securedroomaccessproject-150718081732-lva1-app6892
securedroomaccessproject-150718081732-lva1-app6892
 
Data
DataData
Data
 
IRJET- An Inductor based DC/DC Converter for Energy Harvesting Applicatio...
IRJET-  	  An Inductor based DC/DC Converter for Energy Harvesting Applicatio...IRJET-  	  An Inductor based DC/DC Converter for Energy Harvesting Applicatio...
IRJET- An Inductor based DC/DC Converter for Energy Harvesting Applicatio...
 
Final esd lab manual (1)
Final esd lab manual (1)Final esd lab manual (1)
Final esd lab manual (1)
 
Moisture controller report total
Moisture controller report totalMoisture controller report total
Moisture controller report total
 
Final Report
Final ReportFinal Report
Final Report
 
Design and implementation of micro hydro turbine for power generation and its...
Design and implementation of micro hydro turbine for power generation and its...Design and implementation of micro hydro turbine for power generation and its...
Design and implementation of micro hydro turbine for power generation and its...
 
Ntpc barh (bstpp)
Ntpc barh (bstpp)Ntpc barh (bstpp)
Ntpc barh (bstpp)
 
DESIGN_AND_CONSTRUCTION_OF_2KW_SOLAR_PAN.pdf
DESIGN_AND_CONSTRUCTION_OF_2KW_SOLAR_PAN.pdfDESIGN_AND_CONSTRUCTION_OF_2KW_SOLAR_PAN.pdf
DESIGN_AND_CONSTRUCTION_OF_2KW_SOLAR_PAN.pdf
 
Pulse Density Modulation Based Series Resonant Inverter Fed Induction Heater ...
Pulse Density Modulation Based Series Resonant Inverter Fed Induction Heater ...Pulse Density Modulation Based Series Resonant Inverter Fed Induction Heater ...
Pulse Density Modulation Based Series Resonant Inverter Fed Induction Heater ...
 
IRJET - Implementation of Low Harmonics Multilevel Inverter using SPWM
IRJET -  	  Implementation of Low Harmonics Multilevel Inverter using SPWMIRJET -  	  Implementation of Low Harmonics Multilevel Inverter using SPWM
IRJET - Implementation of Low Harmonics Multilevel Inverter using SPWM
 

More from Tipakorn Sumeteenarumit (8)

คอนไทย
คอนไทยคอนไทย
คอนไทย
 
Inc281 54261512 4
Inc281 54261512 4Inc281 54261512 4
Inc281 54261512 4
 
Inc281-54261512_3
Inc281-54261512_3Inc281-54261512_3
Inc281-54261512_3
 
Inc281-54261512_2
Inc281-54261512_2Inc281-54261512_2
Inc281-54261512_2
 
Inc281-54261512_1
Inc281-54261512_1Inc281-54261512_1
Inc281-54261512_1
 
Automation dishwasher1
Automation dishwasher1Automation dishwasher1
Automation dishwasher1
 
Automation dishwasher
Automation dishwasherAutomation dishwasher
Automation dishwasher
 
Oscilloscope
OscilloscopeOscilloscope
Oscilloscope
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Con thai

  • 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 the Application 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. 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 the Application 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. Chapter 1 Preface 1.1 Name of project: ConThai Rice Cooker 1.2 The origin of project From nowadays Thai people eat rice less every year. Next Thai people consume rice have tendency keep lower. And consumption rice in Asia have 200 kilograms per year but number of Thai consume have 100 – 110 kilograms per year. My world into full consumption war, have fast, convenient, save. That is necessary for consume rice. Rice has to adapt to a wide variety of markets. Amid the hustle of urban life which always a race against time. That’s need to use something for convenient to reduce time. So eat rice in morning meal look like busy because it’s not support with life style that has changed. And we got culture from west that has effect with people in town consumption. So we can see quantity consume 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 more convenient. 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. 1-2 1.4 Procedure Procedure is starting from search information about rice cooking at using and used then design system of rice cooking for overview structure in this device. Detail working procedure as follow. 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 5 1. Research rice cocker 2. Hardware 3. Microcontroller 4. Design circuit 5. Buy hardware device 6. Compound circuit 7. Test circuit 8. Adjust 9. Made report
  • 5. 1-3 1.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. Chapter 2 Theory 2.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 lose power at less. Transformer can work with alternative only and that is the reason, why current in home 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 in home that have height voltage (220 V) and dangerous to lower for safety. Input inductor is called primary and output inductor is called secondary between both doesn’t connect in current but use connection by alternative magnetic field is in transformer magnetic 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 ratio transformer step-down. The number of round much is primary coil, connect to 220 volt is input and output is secondary coil has number of round few, give low voltage.
  • 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. This is 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 have induce 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 is same pond, it give current to output, when smoothing is AC voltage drop. In figure is show not filter direct current and filter direct current. Capacitor is fast evolve at peak of direct current and Capacitor evolve to output.
  • 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 alternative current 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 peak 1.4 × 4.6 = 6.4 V (DC). Filtration is not perfect because have little voltage of capacitor when evolve. It is cause small ripple. For general circuit, supply have ripple 10 % is able. Value of capacitor on smoothing. It can find to equation below. If capacitor is big size will have little ripple. For half wave 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 value number 7805 +5 V 1 A. Show in right hand. Front have install.
  • 9. 2-4 Figure 2-5 IC control voltage 2.2 TRIAC TRIAC is semiconductor transistor group. It has inside structure same with DIAC, but has one more leg. TRIAC is create for modify error SCR. When not induce current in negative alternative current. Most application of TRIAC will use control circuit is switch connect to alternative current. TRIAC is create high current also will must careful in drain heat. Structure of TRIAC 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 positive voltage trig to G. 2.2.1.2 Give positive voltage to MT2. Give negative voltage to MT1 and give negative voltage trig to G. 2.2.1.3 Give negative voltage to MT2. Give positive voltage to MT1 and give negative voltage trig to G.
  • 10. 2-5 2.2.1.4 Give negative voltage to MT2. Give positive voltage to MT1 and give positive voltage 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 will continue 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 to TRIAC lower holding current of TRIAC. 2.3 Sensor 2.3.1 Thermostat Thermostat in digital rice cooking is difference general rice cooking. General rice cooking consists of Lever Contact Switch and magnetic set. Diode run by magnetic deteriorate when have high heat. But thermostat in digital rice cooking is measure temperature and send to microcontroller 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 power supply. Resistance is portion out voltage in circuit. General voltage divider circuit is develop from Ohm’s law. Calculate is cross voltage on resistance use voltage divider will fast and be convenient than Ohm’s law. Figure 2-8 Show voltage divider circuit
  • 11. 2-6 2.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. The noise surrounding the rice cooker will serve as the command to start the circuit. The LED lamps installed around. The bottom of the cooker took place light and not light. There is sound order of the LED, on-off for 15 seconds. And it will run again when there's sound around. 2.4.3 Timing diagram Sound Comparator Time Delay 15 sec. Figure 2-10 Timing diagram check the power circuit
  • 12. 2-7 2.4.4 The works circuit 2.4.4.1 Sound detection has received sound from microphone. And voltage sent to Comparator 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-stable circuit from IC 555 and using output base bias transistor by BC337. Which is switch control voltage 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 the device 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. 2-8 2.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. Chapter 3 Circuit and Design This chapter discusses the various parts of the circuit. And explain the function of the circuit 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 1A in U1 has diode for project to flow one way. In U2 use lm7805 for convent from 9VDC current 1A to 5VDC current 1A for get to use with microcontroller and U3 use lm7805 convent to 5VDC current 1A for get to use with sensor.
  • 15. 3-2 3.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. 3-3 3.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. 3-4 Calculate V3min, when RT = 111 kΩ, R3 = 10 kΩ V3min = VT (R T ) R3 10 kΩ = 5V(111 kΩ ) V3min = 0.4504 V Calculate IT, when E = 5V, RT = 11 kΩ V IT = (R T ) T 5V = (11 kΩ ) IT = 0.45 mA Calculate 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 V Calculate 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 V Calculate 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 V Calculate 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. 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. 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= 14k 3.5 Touch switch circuit Figure 3-6 IC Show using WB2080A Circuit
  • 20. 3-7 3.6 Microcontroller Figure 3-7 Show using ATMEGA12 .
  • 21. Chapter 4 Structure of Programming Controller 4.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. 4-2 START s Cooker Boiled Stream Set time cook If temp >100 c If temp > 100 c Cook False False SW SW Cook = True True on2heater OFF heater all OFF heater all If temp >130 c False SW True Warm Figure 4-1 Flow chart main program
  • 23. 4-3 START Fried Warm Set time If temp >190 c If time >2min Set hour False False SW SW Hour +1 -1 -1 True True OFF 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. Chapter 5 Experiments and conclusion 5.1 Preface After pass programming step each part and design circuit the most important by the way 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 component part 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 approximately 3 seconds).
  • 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 and Automatic 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 proper standard 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 as the main function. 5.5.2.2 Microcontroller sends data and information to display monitor then our group name, Conthai, shows on the display. 5.5.2.3 Setting time by press on time setting function bottom to adjust hour, minute and 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. The selected 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 achieve testing objective. Please turn to next unit for more information about obstacles and solution during working process.
  • 26. Chapter 6 Problems and suggestions 6.1 Preface In this project has many problems, because this project use electronic device to max efficiency for work and to divide the problem into 2 types of problems that are Software and Hardware. 6.2 Problem and Solving In this project has problem about Software and Hardware, so we divide the problem and solve as follows. 6.2.1 First step I see problem that is to used hardware devices are difficult, because we must 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 find yank voltage. It made some circuit to error. So we solve by turn on power supply before connect the circuit after that to measure each circuit. 6.2.3 Third, when we made PCB after check line PCB. When we test circuit are find bash 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 by multi-meter. 6.2.5 Touch switch in circuits are find shield cable have ground around cable, when we stripping the wire and weld to copper plate. Found that circuit. 6.3.6 In part microcontroller problems is FUSES attached from factory, it's not same our experiments. It is not possible to perform experiments. It can’t possible to perform experiments. Solution is use boards by program to list variable into experiments to fix variable 2 FUSES 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. 6-2 changing the resistance less valuable so the stream flows sufficient to trigger on for the TRIAC and selection resistor for range 1 watt.
  • 28. Contents Chapter 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-3 Chapter 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-7 Chapter 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-7 Chapter 4 Structure of Programming Controller 4-1 4.1 Operation of program 4-1 Chapter 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. Contents (contd.) 5.6 Conclusion 5-2 Chapter 6 Problems and suggestions 6-1 6.1 Preface 6-1 6.2 Problem and Solving 6-1 Appendix A Manual Appendix B Programming Appendix C Datasheet
  • 30. Figures Figure 2-1 Block Diagram Power supply 2-1 Figure 2-2 Bridge rectifier circuit 2-2 Figure 2-3 Full wave bridge diode 2-2 Figure 2-4 Show is charge and discharge of capacitor 2-3 Figure 2-5 IC control voltage 2-4 Figure 2-6 Structure of TRIAC 2-4 Figure 2-7 Symbol of TRIAC 2-4 Figure 2-8 Show voltage divider circuit 2-5 Figure 2-9 Block Diagram check the power circuit 2-6 Figure 2-10 Timing diagram check the power circuit 2-6 Figure 2-11 Display graphic ET-NOKIA LCD 5110 2-7 Figure 2.12 AT mega 128 2-8 Figure 3-1 Power supply circuit 3-1 Figure 3-2 TRIAC circuit 3-2 Figure 3-3 Voltage divider circuit 3-3 Figure 3-4 The relationship between resistance and temperature. 3-5 Figure 3-5 Show using IC 555 circuit 3-5 Figure 3-6 IC Show using WB2080A Circuit 3-6 Figure 3-7 Show using ATMEGA12 3-7 Figure 4-1 Flow chart main program 4-2 Figure 4-2 Flow chart main program 4-3
  • 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. _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. _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_MasterTransmit(pgm_read_byte(&Font5x7[p++])); } if (sp)SPI_MasterTransmit(0x00); } void GLCD_PutStr(uint8_t *str,uint8_t sp) { sbi(PORT_SPI,DD_DC); while(*str){ GLCD_PutChar(*str++,sp); } } void Put(void) { sbi(PORT_SPI,DD_DC); int p[]= { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x01, 0xC0, 0xF8, 0x00, 0x01, 0x1F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF1,
  • 35. 0xF1, 0xF1, 0xF1, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x01, 0x80, 0xF8, 0xFF, 0xFF, 0xFF, 0xF0, 0x00, 0x03, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x07, 0xC3, 0xE1, 0xF1, 0xF1, 0xE1, 0xC3, 0x07, 0x0F, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x03, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x03, 0x03, 0x1F, 0x87, 0xC3, 0xE3, 0xE3, 0xE3, 0xC3, 0x07, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0x3F, 0x0F, 0x87, 0xC3, 0xE3, 0xE3, 0xC3, 0xC7, 0x07, 0x1F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x03, 0x00, 0x00, 0x8F, 0x8F, 0xCF, 0xCF, 0xFF, 0xFF, 0xFE, 0xC0, 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x3C, 0x3F, 0x1F, 0x1F, 0x0F, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0x0C, 0x0F, 0x0F, 0x0F, 0x0F, 0x1F, 0xFF, 0xFF, 0xF0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x07, 0x00, 0xE0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0x80, 0x00, 0x0F, 0xFF, 0xFF, 0x00, 0x00, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x00, 0x00, 0x7F, 0xFF, 0xFF, 0xC0, 0x00, 0x0F, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x01, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x80, 0x07, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x03, 0xC1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xF9, 0xFF, 0xFE, 0xFC, 0xF8, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xFE, 0xFE, 0xF8, 0xF8, 0xF8, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFE, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xF8, 0xF8, 0xF8, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 0xFF, 0xFF,
  • 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. 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. } } 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. 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. 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. { 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. 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. 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. 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. 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. 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. 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. 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. //GLCD_PutStr("TIME",1); } void settime() { int data1,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. 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. 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. 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. 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 crystal while(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. 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. 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. 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. { 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. } } 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. 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. //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. 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. 0x27, 0x45, 0x45, 0x45, 0x39,// 5 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 0x01, 0x71, 0x09, 0x05, 0x03,// 7 0x36, 0x49, 0x49, 0x49, 0x36,// 8 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 0x00, 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,// A 0x7F, 0x49, 0x49, 0x49, 0x36,// B 0x3E, 0x41, 0x41, 0x41, 0x22,// C 0x7F, 0x41, 0x41, 0x22, 0x1C,// D 0x7F, 0x49, 0x49, 0x49, 0x41,// E 0x7F, 0x09, 0x09, 0x01, 0x01,// F 0x3E, 0x41, 0x41, 0x51, 0x32,// G 0x7F, 0x08, 0x08, 0x08, 0x7F,// H 0x00, 0x41, 0x7F, 0x41, 0x00,// I 0x20, 0x40, 0x41, 0x3F, 0x01,// J 0x7F, 0x08, 0x14, 0x22, 0x41,// K 0x7F, 0x40, 0x40, 0x40, 0x40,// L 0x7F, 0x02, 0x04, 0x02, 0x7F,// M 0x7F, 0x04, 0x08, 0x10, 0x7F,// N 0x3E, 0x41, 0x41, 0x41, 0x3E,// O 0x7F, 0x09, 0x09, 0x09, 0x06,// P 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q 0x7F, 0x09, 0x19, 0x29, 0x46,// R 0x46, 0x49, 0x49, 0x49, 0x31,// S 0x01, 0x01, 0x7F, 0x01, 0x01,// T 0x3F, 0x40, 0x40, 0x40, 0x3F,// U 0x1F, 0x20, 0x40, 0x20, 0x1F,// V 0x7F, 0x20, 0x18, 0x20, 0x7F,// W 0x63, 0x14, 0x08, 0x14, 0x63,// X 0x03, 0x04, 0x78, 0x04, 0x03,// Y 0x61, 0x51, 0x49, 0x45, 0x43,// Z 0x00, 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,// a 0x7F, 0x48, 0x44, 0x44, 0x38,// b 0x38, 0x44, 0x44, 0x44, 0x20,// c 0x38, 0x44, 0x44, 0x48, 0x7F,// d 0x38, 0x54, 0x54, 0x54, 0x18,// e
  • 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
  • 66. Measuring the resistance compared with temperature Degree MIN MEDIAN MAX Degree MIN MEDIAN MAX 26.00 92.70 93.70 94.50 65.00 18.80 19.20 19.20 27.00 90.90 91.30 91.90 66.00 18.10 18.10 18.40 28.00 87.20 87.50 88.30 67.00 17.20 17.40 17.60 29.00 82.40 83.40 83.80 68.00 16.56 16.70 16.80 30.00 79.30 79.70 80.80 69.00 15.70 15.96 16.22 31.00 77.50 78.80 79.00 70.00 15.30 15.31 15.60 32.00 74.10 75.20 76.90 71.00 14.84 14.90 15.14 33.00 71.30 71.90 73.20 72.00 14.15 14.30 14.55 34.00 68.70 69.20 70.10 73.00 13.61 13.70 14.01 35.00 64.90 65.50 66.50 74.00 13.21 13.30 13.48 36.00 62.20 62.80 63.50 75.00 12.30 12.82 13.08 37.00 58.90 59.20 61.00 76.00 12.46 12.55 12.79 38.00 56.90 57.00 57.90 77.00 11.93 12.00 12.32 39.00 54.00 55.00 55.40 78.00 11.73 11.80 12.07 40.00 52.30 52.90 53.10 79.00 11.08 11.50 11.61 41.00 50.10 50.20 50.30 80.00 10.78 10.91 11.20 42.00 47.10 47.90 48.40 81.00 10.56 10.76 10.80 43.00 44.90 45.60 46.30 82.00 10.10 10.21 10.23 44.00 43.00 44.20 44.80 83.00 9.80 10.03 10.03 45.00 41.90 42.00 42.60 84.00 9.40 9.54 9.73 46.00 40.10 40.80 41.20 85.00 9.18 9.20 9.63 47.00 38.70 38.90 39.30 86.00 8.64 8.80 8.90 48.00 36.90 37.30 37.80 87.00 8.10 8.20 8.38 49.00 35.80 35.90 36.70 88.00 7.63 7.90 7.95 50.00 33.50 33.70 34.60 89.00 7.48 7.51 7.75 51.00 31.90 32.20 33.20 90.00 7.22 7.25 7.33 52.00 29.80 30.60 31.00 91.00 7.07 7.09 7.17 53.00 28.90 29.40 30.10 92.00 6.92 6.97 7.02 54.00 28.30 28.60 29.30 93.00 6.77 6.83 6.91 55.00 26.50 27.10 28.10 94.00 6.41 6.65 6.74 56.00 26.30 26.60 27.20 95.00 6.23 6.31 6.42 57.00 25.00 25.60 26.70 96.00 5.94 6.18 6.22 58.00 24.10 24.30 25.60 97.00 5.73 5.81 5.99 59.00 23.00 23.50 23.80 98.00 5.55 5.61 5.74 60.00 21.80 22.20 22.80 99.00 5.32 5.43 5.43 61.00 21.10 21.80 22.10 100.00 5.22 5.24 5.28 62.00 20.30 20.80 21.40 101.00 5.10 5.13 5.20 63.00 19.80 20.00 20.20 102.00 4.92 5.08 5.12 64.00 19.20 19.60 19.80 103.00 4.78 4.80 4.86
  • 67. Degree MIN MEDIAN MAX Degree MIN MEDIAN MAX 104.00 4.59 4.69 4.72 146.00 0.32 1.32 1.34 105.00 4.55 4.61 4.70 147.00 0.30 1.31 1.32 106.00 4.47 4.55 4.62 148.00 1.29 1.29 1.31 107.00 4.30 4.39 4.52 149.00 0.25 1.27 1.28 108.00 4.18 4.27 4.27 150.00 1.23 1.24 1.24 109.00 4.09 4.15 4.19 151.00 1.19 1.19 1.21 110.00 3.88 4.09 4.15 152.00 1.17 1.17 1.19 111.00 3.84 4.01 4.11 153.00 1.14 1.15 1.16 112.00 3.80 4.04 4.91 154.00 1.11 1.12 1.15 113.00 3.32 3.77 3.96 155.00 1.08 1.09 1.12 114.00 3.15 3.69 3.75 156.00 1.05 1.06 1.08 115.00 3.02 3.58 3.71 157.00 1.01 1.03 1.03 116.00 3.00 3.50 3.65 158.00 1.00 1.00 1.01 117.00 2.96 3.46 3.51 159.00 0.99 0.99 1.00 118.00 2.88 3.39 3.47 160.00 0.982 0.986 0.993 119.00 2.82 3.30 3.33 161.00 0.972 0.976 0.984 120.00 2.67 3.19 3.29 162.00 0.954 0.957 0.966 121.00 2.61 3.11 3.15 163.00 0.935 0.940 0.948 104.00 4.59 4.69 4.72 164.00 0.920 0.928 0.931 122.00 2.57 2.91 3.05 165.00 0.910 0.910 0.911 123.00 2.54 2.86 2.88 166.00 0.892 0.894 0.899 124.00 2.50 2.75 2.80 167.00 0.870 0.873 0.874 125.00 2.49 2.59 2.74 168.00 0.839 0.849 0.855 126.00 2.47 2.56 2.65 169.00 0.810 0.821 0.832 127.00 2.46 2.50 2.59 170.00 0.791 0.798 0.816 128.00 2.44 2.47 2.51 171.00 0.776 0.780 0.788 129.00 2.39 2.44 2.45 172.00 0.760 0.764 0.765 130.00 2.36 2.36 2.38 173.00 0.746 0.748 0.750 131.00 2.27 2.32 2.34 174.00 0.737 0.739 0.741 132.00 2.18 2.24 2.27 175.00 0.728 0.732 0.733 133.00 2.09 2.11 2.15 176.00 0.717 0.720 0.724 134.00 1.98 2.03 2.09 177.00 0.709 0.712 0.712 135.00 1.91 1.93 2.00 178.00 0.698 0.699 0.700 136.00 1.85 1.89 1.91 179.00 0.683 0.683 0.692 137.00 1.78 1.79 1.81 180.00 0.659 0.660 0.670 138.00 1.62 1.69 1.74 181.00 0.635 0.642 0.657 139.00 1.58 1.65 1.65 182.00 0.611 0.617 0.621 140.00 1.52 1.55 1.62 183.00 0.599 0.601 0.603 141.00 1.49 1.51 1.52 184.00 0.577 0.583 0.589 142.00 1.44 1.46 1.48 185.00 0.565 0.567 0.568 143.00 1.40 1.41 1.43 186.00 0.550 0.551 0.559 144.00 1.36 1.37 1.38 187.00 0.538 0.541 0.545 145.00 1.34 1.35 1.35 188.00 0.530 0.534 0.535
  • 68. Degree MIN MEDIAN MAX 189.00 0.512 0.515 0.523 190.00 0.490 0.501 0.505 191.00 0.472 0.474 0.487 192.00 0.462 0.465 0.467 193.00 0.453 0.454 0.460 194.00 0.444 0.449 0.451 195.00 0.439 0.444 0.448 196.00 0.427 0.436 0.436 197.00 0.421 0.424 0.425 198.00 0.412 0.413 0.418 199.00 0.402 0.406 0.406 200.00 0.391 0.396 0.400 201.00 0.389 0.390 0.393 202.00 0.378 0.381 0.388