Automatic Gas Cooking Control System based on Microcontroller

DOI : 10.17577/IJERTV5IS020221

Download Full-Text PDF Cite this Publication

Text Only Version

Automatic Gas Cooking Control System based on Microcontroller

Mohammed Khalafalla Prof. Zhang Jun

Department of Electronic Engineering Department of Electronic Engineering Tianjin University of Technology and Education Tianjin University of Technology and Education

Tianjin, China Tianjin, China

Abstract: The main problem objects user of cooking gas in all cooking purposes in the world is the safety and controlling of using this gas. As known that this gas is flammable and very dangerous when is used in incorrectly ways. So all manufacturer companies in the world resort to find secured methods which have low cost and more reliability to solve this problem .Most of these methods are using technologies techniques which make user (cooker person) uses his cooker system safely. This paper studies and shows one of simple way for make an automatic gas cooking control system by using available technology techniques. This way was done with microcontroller (atmega32) and other electronic components like servo motor, gas sensor (MQ-2), seven segment display, etc and additional gas valve ( mechanical component).The atmega32 microcontroller controls all communication signals between these electronic instruments in this system. In this system the word automatic means that the system has some (not all) automatic jobs like discovering leakage gas and stop working in the case of finish cooking time or in case of precarious cases. So the users (cookers) start the working (ignition) by inserting some inputs data to the system like time of cooking and amount of gas. When the time of cooking finished or when gas leakage happen the system will stop ignition automatically. This way show the system is more reliable. Also by this way we can offer the gas in cooking purposes.



    Gas cooking is called Liquefied petroleum gas (LPG) or liquid petroleum gas (LP gas), also referred to as simply propane or butane, are flammable mixtures of hydrocarbon gases used as fuel in heating appliances, cooking equipment, and vehicles. LPG is used for cooking in many countries for economic reasons, for convenience or because it is the preferred fuel source.

    Gas cooking systems use this type of gas for cooking purposes in houses and other residential buildings. The old type systems are very simple. They are known as cooking stoves. The problem of these types is there is no reliability and safety on them. So the companies trended to make new types of cooking systems (cooking stoves) which are using some technologies techniques. These modern types start to be used widely all over the world according to their suitable properties. Because the degree of danger of the gas is high, all these systems are working manually by the person who wants to use them for cooking.

    The automatic gas cooking control system in this paper is designed based on microcontroller atmega32. The system is constructed from two parts. Mechanical parts which is denoted by gas valve. The electrical parts are denoted by electrical circuit and electronic components. For study this system some software programs were used.

    The professional proteus7.1 (ISIS7) program software was selected for implementing the system circuit. The circuit was implemented in this simulation software and simulated. Other software is BASCOM-AVR high level programming language program software was used to write suitable code for the atmega32 microcontroller to do all its functions.


    Proteus Virtual System Modeling (VSM) software offers the ability to co-simulate both high and low-level microcontroller code in the context of a mixed mode SPICE circuit simulation. It combines mixed mode SPICE circuit simulation, animated components and microprocessor models to facilitate co-simulation of complete microcontroller based designs. With VSM, it is possible to develop and test such designs before a physical prototype is constructed. The designer can interact with the design using on screen indicators such as LED and LCD displays and actuators such as switches and buttons. The simulation takes place in real time, e.g. a 1GMHz Pentium III can simulate a basic 8051 system clocking at over 12MHz. Proteus VSM also provides extensive debugging facilities including breakpoints, single stepping and variable display for both assembly code and high level language source.

    We used Proteus Virtual System Modeling (VSM) to draw and simulate the circuit of the system. But unfortunately we did not find gas sensor (MQ-2) in this software. So in order to complete our system circuit we make it by our self using new device property of the soft ware. But this device cannot work in real simulation. For this reason we symbolized gas sensor (MQ-2) by pushbutton (GAS LEAKAGE_SENSOR) for real simulation. When pushbutton is pressed means that there is gas leakage and the sensor gives signal on its output and vice versa.


The most important feature of Proteus VSM is its ability to simulate the interaction between software running on a microcontroller and any analog or digital electronics connected to it. The microcontroller model sits on the

schematic along with the other elements of product design. It simulates the execution of designer object code (machine code), just like a real chip. If the program code writes to a port, the logic levels in circuit change accordingly, and if the circuit changes the state of the processors pins, this will be seen by the program code, just as in real systems. The VSM CPU models fully simulate I/O ports, interrupts, timers, USARTs and all other peripherals present on each supported processor. The interaction of all these peripherals with the external circuit is fully modeled down to waveform level and the entire system is therefore simulated. The ISIS editor consists of three main areas as shown in Figure (1):

  1. The Editing Window: acts as a window on the drawing where we place and wire up components.

  2. Object Selector: lists objects inserted into the Editing Window and allows us to select new objects to be inserted from the ISIS library.

  3. Overview Window: In normal use, the Overview Window displays an overview of the entire drawing and the blue box shows the edge of the current sheet and the green box the area of the sheet currently displayed in the Editing Window. However, when a new object is selected from the Object Selector the Overview Window is used to preview the selected object.

    Figure 1 ISIS schematic capture window. (1) Editing Window, (2) Object Selector, and (3) Overview Window


    BASCOM-AVR© is the original Windows Basic compiler for the AVR family and Atmel's microprocessors. It is designed to run on XP/VISTA/WIN7 and WIN8. In addition it has full support for arrays and the single floating point data type. Also Bascom-8051 and Bascom-avr are development environments built around a powerful Basic compiler. Both are suited for project handling and program development for the 8051 family and its derivatives as well as for the AVR microcontrollers from Atmel. The 8051 microcontroller family has been well known over many years. The development of new derivatives is not finished yet. From time to time new powerful derivatives are announced. Atmel developed the AVR microcontroller family which is well suited for high level language programming and in system programming. When we run the Bascom-avr software the following window will appear. (I this is our first run, the edit window will be empty).

    Figure 2 Bascom-avr capture window

  5. MICROCONTROLLERS Microcontrollers are the heart and soul of many everyday

    appliances. And most of all, microcontrollers are easy to use and to design with, from the point of view of a designer. They can do many functions without a lot of extra components. This leads to a small and compact system that is more reliable and cost-effective (because of the fewer number of components and the fewer number of interconnections). They constructs from many things like central processing unit (CPU) is the heart of the controller and itself is composed of registers, the arithmetic logic unit (ALU),instruction decoder, and control circuitry. Program Memory where the instructions of the program are stored. RAM is the data memory of the controller and it is used by the controller to store data. Clock Oscillator could be an internal RC-oscillator or an oscillator with an external timing element, such as a quartz crystal, an LC resonant circuit, or even an RC circuit. So the controller executes the program out of the program memory at a certain rate. This rate is determined by the frequency of the clock oscillator. Reset and Brownout Detector Circuit reset circuit in the controller ensures that at startup all the components and control circuits in the controller start at a predefined initial state and all the required registers are initialized properly. Serial Port is used to communicate with external devices on a serial data basis and can operate at any required data transfer speed. Digital I/O Ports are used by microcontroller to exchange digital data with the outside world and the data on the digital I/O port is exchanged as bytes. Analog I/O Ports as analog input is performed using an analog-to-digital converter (ADC) and Analog output is performed using a digital-to-analog converter (DAC). Timer is used by the controller to time events or to count events and in this case the timer is called a counter. Watchdog Timer (WDT) is a special timer with a specific function and is usually used to prevent software crashes. Real Timer Clock (RTC) is a special timer with the task of maintaining time of day, date, etc. It can be used to time-stamp events. These devices come in a variety of sizes and complexity. Like microprocessors (CPU on a chip), microcontrollers are classified as 8-bit, 16-bit, or 32-bit (or 64-bit) components. This refers to the width of the internal registers and the accumulator. An 8-bit system usually also means that the CPU connects to the various chip components through an 8-bit data path.

    Figure 3- An 8-bit microcontroller

  6. ATMEGA32M1

    The ATmega32M1 is a low-power CMOS 8-bit microcontroller based on the AVR enhanced RISC architecture. By executing powerful instructions in a single clock cycle, the 32M1achieves throughputs approaching 1 MIPS per MHz allowing the system designers to optimize power consumption versus processing speed.

    The AVR core combines a rich instruction set with 32 general purpose working registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. The ATmega32M1 provides the following features: 32K bytes of In-System Programmable Flash with Read-While-Write capabilities,1K bytes EEPROM, 2K bytes SRAM, 32 general purpose working registers, one Motor Power Stage Controller, two flexible Timer/Counters with compare modes and PWM, one UART with HW LIN, an 11- channel 10-bit ADC with two differential input stages with programmable gain, a 10-bit DAC, a programmable Watchdog Timer with Internal Individual Oscillator, an SPI serial port, an On-chip Debug system and four software selectable power saving modes.

    The Idle mode stops the CPU while allowing the SRAM, Timer/Counters, SPI ports, CAN, LIN/UART and interrupt system to continue functioning. The Power-down mode saves the register contents but freezes the Oscillator, disabling all other chip functions until the next interrupt or Hardware Reset. The ADC Noise Reduction mode stops the CPU and all I/O modules except ADC, to minimize switching noise during ADC conversions. In Standby mode, the Crystal/Resonator Oscillator is running while the rest of the device is sleeping. This allows very fast start-up combined with low power consumption.

    The device is manufactured using Atmels high-density nonvolatile memory technology. The On chip ISP Flash allows the program memory to be reprogrammed in-system through an SPI serial interface, by a conventional nonvolatile memory programmer, or by an On-chip Boot program running on the AVR core. The boot program can use any interface to download the application program in the application Flash memory. Software in the Boot Flash section will continue to run while the Application Flash section is updated, providing true Read-While-Write operation. By

    combining an 8-bit RISC CPU with In-System Self- Programmable Flash on a monolithic chip, the Atmel ATmega32M1 is a powerful microcontroller that provides a highly flexible and cost effective solution to many embedded control applications.

    Figure 4- Pin out of ATmega32 microcontroller

  7. AUTOMATIC GAS COOKING CONTROL SYSTEM Automatic gas cooking control system circuit

compounds from these components:-

  1. Atmega32 microcontroller was selected to be the main mind of the system circuit to do all operation instructions and communication signals for the circuit.

  2. Seven segment display four digits to show time in minutes and hours. Also it shows the gas level when set by user.

  3. MG995 servo motor which drives the gas valve for open/close the gas that flow in the stove.

  4. Three LEDs, green one to indicate the system in working condition. Red one indicates the system in stopping condition and yellow one to indicate the system in stopping condition according to the fault.

  5. MQ2 gas sensor to discover if there is any gas leakage.

  6. Bc548 NPN transistor to give suitable value for programming microcontroller.

  7. Sound buzzer to give sound alarm when gas leakage happens.

  8. Five pushbuttons for setting or resetting working requirements like time and gas level and start the working.

  9. Some resistances for adjusting components currents.

  10. Power source (direct source or battery)

The automatic gas cooking control system contains four levels (25%, 50%, 75% and 100%) for gas flowing. These levels correspond to the rotation degrees of the gas valve that is driven by servo motor. So it can allow users to choose the mount of gas flowing in the stove from theses four levels according to their kind of cooking by pressing pushbutton. Also the system allows them to set the time for using gas (cooking time) in hours and minutes. All these options will be decided according to user requirements. In additional, it contains protective function by stopping flowing of the gas in to the stove by closing the gas valve when leakage of gas happen then give users sound and light alarm in these cases. This function is done by adding gas sensor in the system circuit to discover if there is any gas leakage.

The automatic gas cooking control system works when the users want to use gas for cooking. First they turn the power switch ON then choose the amount of gas flowing level that will be required according to the kind of cooking.

For this step users will press pushbutton (GAS LEVEL_SWITCH) in the system circuit. When press this pushbutton only one time that means choosing level 25% and the number 1 will appear on the last seven segment display digit in the circuit. By this way pressing pushbutton two times means choosing level 50% and the number 2 will appear on the last seve segment display digit then do the same for level 75% with number 3 and level 100% with number 4. After that, set the time for cooking (cooking interval). For this step users will press pushbutton (SW_MIN) in the system circuit to set minutes of cooking time every pressing time the number of minutes will increase by 1. Then minutes will appear on the first two seven segment display digits (in the right) in the circuit. In order to set hours of cooking time users can press pushbutton (SW_HOUR) in the system circuit. The hours will increase by 1 after pressing their pushbutton two times. Hours will appear on the third seven segment display digit (in the middle) in the circuit. Because of safety (opinion) condition, hours of cooking time can be set to maximum two hours. We assume that no kind of cooking its cooking time exceeds three hours (just in this case). This means the maximum cooking time can be set in this system is three hours. So if three hours is not enough, users can adding another cooking times each time has three hours cooking time. Among these setting steps if any errors happens users can press pushbutton (RST) to reset their setting values and set them again to the correct ones. Finally users start the working of the stove by pressing the starting switch (SW_START).Then the green LED will blink and the time will start in decreasing to show operating mode. After all these steps the microcontroller takes the mount of flowing gas levels (25%, 50%, 75% and 100%) and cooking time as input and processes it .Then it sends a signal to the servo motor which is related to microcontroller. The servo motor will turn to the suitable direction (position) in degrees (45º, 90º, 135º and 180º) to open the gas valve which is related to the servo motor to allow gas to flow in the stove. Users turn the ignition switch on (automatic or manually) the ignition will start. Then the microcontroller starts to decrease the operating time and shows it on the seven segment display. After the time finish it sends another signal to the servo motor will turn to the opposite direction (position 0º) to close the gas valve to stop gas flowing in the stove then stop ignition then the red LED will turn ON and the cooking time (hours and minutes) will show its zero values on seven segment display to indicate stopping mode. At any moment of working or stopping mode of the system if gas leakage happens microcontroller will send signals to the buzzer sound to make sound on it and to the yellow LED to turn it ON

.Also sends signal to the servo motor to make it turn to the opposite direction (position 0º) to close the gas valve to stop gas flowing in the stove then stop ignition. This indicates the system stopped according to the error. The system uses direct supply or small battery as electric power source. This figure shows our system circuit in Proteus ISIS simulation soft ware.

Figure 5- Automatic Gas Cooking Control System Circuit

In this figure we show our system circuit inputs for cooking time, gas level which will enter by users and gas leakage sensor that will work in case of error.

Figure 6- Automatic Gas Cooking Control System inputs and main power source

Here in this figure we show our system circuit outputs. Seven segment display for cooking time, gas level which will show on it. Error case and circuit modes will show LEDs and buzzer.

Figure 7- Automatic Gas Cooking Control System outputs

When users press (switch on) main switch to power on the circuit will be ready for receiving inputs (enter by users). This figure shows this case.

Figure 8- System Circuit after Power on and ready for inputs setting

After users entered their inputs (cooking time and gas level) the circuit will be ready for starting ignition and working. This figure shows example case.

Figure 9- System Circuit after Inputs Setting (Cooking Time = 1 hour and 10 minutes, Gas Level = 3 or 75%)

Finally users entered their inputs then press (SW_START) switch to start circuit working and ignition. In below figure we can see the servo motor turned to position (135º) corresponds to the gas level 75%l (3) to open gas valve then the green LED will continue in blinking.

Figure 10- System Circuit in Operating Mode

Stopping mode starts after the cooking time or working mode time finished. In this mode the seven segments display zero values for cooking time and gas level. Also the red LED will turn on and the servo motor turned to position (0º) to close the gas valve. Below figure shows this mode.

Figure 11- System Circuit in Stopping Mode

During working or stopping mode if any gas leakage happens the circuit will become in error mode. It will send sound alarm on the buzzer and turn the yellow LED will turn on. The seven segments display zero values for cooking time and gas level and the servo motor turned to position (0º) to close the gas valve. This figure shows error mode.

Figure 12- System Circuit in Stopping Mode according to error (gas leakage)


Proteus Virtual System Modeling (VSM) is very useful integrating software specifically for engineering applications, which have good ability of simulation functionality. Also BASCOM-AVR© is very good software for writing high level programs (codes). It has suitable compiler for the AVR family and Atmel's microprocessors. Atmel AVR microcontroller family was developed and well suited for high level language programming and in system programming.

In industry the electrical cooking systems (stoves) are very easy in making. Also are easy in using for cooking purposes in houses and other residential buildings. Because of their safety and guarantee control. In compare with gas cooking systems (stoves) are very complicated and dangerous because of gas properties. So we study and designed this system to point out to this types of cooking systems.

We think this paper can be considered as small simple way make the reader use it to understand how gas cooking system is very important in our life. After we wrote this paper we expect that the interested reader can take into account as new way on their future projects, and gain effectiveness on the overall life development process.


  1. MCS Electronics- BASCOM-AVR user manual. © MCS Electronics 1995-2009.

  2. Zbigniew Gibek. Gunderloy BASCOM BASIC AVR Wersja Poland 2002-2003.

  3. Dhananjay V. Gadre. PROGRAMMING AND CUSTOMIZING THE AVR. McGraw-Hill New York San Francisco Washington, D.C. Auckland Bogotá. Copyright 2001The McGraw-Hill Companies,Inc.

  4. Ganiyu R. A., Arulogun O. T., Okediran O. O. Development Of A Microcontroller-Based Traffic Light System For Road Intersection Control, INTERNATIONAL JOURNAL OF SCIENTIFIC & TECHNOLOGY RESEARCH (IJSTR),VOLUME 3, ISSUE 5, May 2014, ISSN 2277-8616

  5. Chairman Capital Cooking Equipment, Inc. gas cocking user guide.

  6. Benton Harbor, MI 49022-2692, Gas range user instructions


  8. LouisE.Frenzel,Jr.PrinciplesofElectronic Communication Systems, ThirdEdition.

  9. Robertshaw®, Paragon®, Ranco®, Uni-Line® and Publication Zone,

    Uni-line Product Knowledge for RSU COOKING

  10. P.N.Paraskevopoulous, Modren Control Engineering, ISBN: 0-8247- 8981-4, Marcel, Dekker, Inc., 270 Madison Avenue, New York, NY 10016, tel: 212-696-9000; fax: 212-685-4540.

Leave a Reply