You are on page 1of 59

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

CHAPTER-1
INTRODUCTION
In India the supply of LPG through pipelines is not possible due to shortage of
LPG.As technology being improved many gas agencies or distributors have implemented
IVRS these days although due to daily busy schedules, customer finds very difficult to
book new cylinder, and also it is very dangerous when a LPG gas leakage occurs in any
domestic usage, chemical industry or in any other applications. This paper provides
automatic booking of LPG cylinder and to overcome the problem of LPG leakage. IVRS
system was borne from general complaints of consumers that landline phones of their
distributors were either busy or no one answered the call promptly. With this system, a
consumer can approach the gas agency by dialing a toll-free number and later will have
to follow the interactive directions. Finally, the system will announce the customer
number and confirms the customer number and also confirms the refill of cylinder.
So our proposal is to completely automate the process of refill booking without
human intervention that accordingly will help consumer against foul play. Our system is
also intended to help consumers to upgrade their safety standards, act in accordance with
statutory requirements on environmental commitments and most importantly the basic
function being prevented by accidents and protect life and property from disasters. The
primary objective of our paper is to measure the gas present in the cylinder when weight
of the cylinder reached below the fixed load, using the pervasive sensors.
The gas retailer gets the order for a new cylinder and the house owner receives the
message about the same and the details about the booking proceedings. And the
secondary objective is to provide any malfunction in gas system in order to prevent
damage or explosion of LPG.

Dept of ECE, SREC, NANDYAL

Page 1

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

BLOCKDIAGRAM:

Fig:1.1 Home side control and monitoring module

fig:1.2 Agency side module

Dept of ECE, SREC, NANDYAL

Page 2

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

CHAPTER-2
LITERATURE REVIEW
Automatic LPG leakage detection and hazard prevention for home security using
an alarm and exhaust fan. Gas leakage is a major concern with residential, commercial
premises and gas powered transportation vehicles. One of the preventive measures to
avoid the danger associated with gas leakage is to install a gas leakage detector at
vulnerable locations.

EXISTING SYSTEM
No automatic LPG cylinder empty detection
The consumers have the task of booking for replacement.
Many a time, the users are unaware of the level of gas in the cylinder so they fail
to book in time, resulting in inconvenience.
No automated leak control

GSM Module
Gas sensor detects the presence of gas, weight sensor gives the gas level in
cylinder, and microcontroller will take corrective or necessary actions. The status of all
these happening has to be conveyed to the owner of system or housemates. The
technology making it very easy to send and receive messages using GSM module works
on simple AT commands which can be implemented by interfacing it to the
microcontroller Rx and Tx pins. The GSM module used is SIMCOM 300 which uses
SIM memory to store the number of system owner or housemates and distributor or to
whoever the messages have to be forwarded. It requires very less memory to send and
receive text messages and operates on simple 12 Volt adapter.

Dept of ECE, SREC, NANDYAL

Page 3

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


CHAPTER-3
INTRODUCTION TO EMBEDDED SYSTEMS
An embedded system can be defined as a computing device that does a specific
focused job. Appliances such as the air-conditioner, VCD player, DVD player, printer, fax
machine, mobile phone etc. are examples of embedded systems. Each of these appliances
will have a processor and special hardware to meet the specific requirement of the
application along with the embedded software that is executed by the processor for
meeting that specific requirement. The embedded software is also called firm ware.
The desktop/laptop computer is a general purpose computer. You can use it for a variety
of applications such as playing games, word processing, accounting, software
development and so on. In contrast, the software in the embedded systems is always fixed
listed below:
Embedded systems do a very specific task; they cannot be programmed to do
different things. . Embedded systems have very limited resources, particularly the
memory. Generally, they do not have secondary storage devices such as the CDROM or
the floppy disk. Embedded systems have to work against some deadlines. A specific job
has to be completed within a specific time. In some embedded systems, called real-time
systems, the deadlines are stringent. Missing a deadline may cause a catastrophe-loss of
life or damage to property. Embedded systems are constrained for power. As many
embedded systems operate through a battery, the power consumption has to be very low.

Application Areas:
Nearly 99 percent of the processors manufactured end up in embedded systems.
The embedded system market is one of the highest growth areas as these systems are
used in very market segment- consumer electronics, office automation, industrial
automation, biomedical engineering, wireless communication, data communication,
telecommunications, transportation, military and so on.

Dept of ECE, SREC, NANDYAL

Page 4

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Consumer appliances: At home we use a number of embedded systems which include
digital camera, digital diary, DVD player, electronic toys, microwave oven, remote
controls for TV and air-conditioner, VCO player, video game consoles, video recorders
etc. Todays high-tech car has about 20 embedded systems for transmission control,
engine spark control, air-conditioning, navigation etc. Even wristwatches are now
becoming embedded systems. The palmtops are powerful embedded systems using which
we can carry out many general-purpose tasks such as playing games and word
processing.

Office automation: The office automation products using embedded systems are copying
machine, fax machine, key telephone, modem, printer, scanner etc.

Industrial automation: Today a lot of industries use embedded systems for process
control. These include pharmaceutical, cement, sugar, oil exploration, nuclear energy,
electricity generation and transmission. The embedded systems for industrial use are
designed to carry out specific tasks such as monitoring the temperature, pressure,
humidity, voltage, current etc., and then take appropriate action based on the monitored
levels to control other devices or to send information to a centralized monitoring station.
In hazardous industrial environment, where human presence has to be avoided, robots are
used, which are programmed to do specific jobs. The robots are now becoming very
powerful and carry out many interesting and complicated tasks such as hardware
assembly.

Medical electronics: Almost every medical equipment in the hospital is an embedded


system. These equipments include diagnostic aids such as ECG, EEG, blood pressure
measuring devices, X-ray scanners; equipment used in blood analysis, radiation,
colonscopy, endoscopy etc. Developments in medical electronics have paved way for
more accurate diagnosis of diseases.

Dept of ECE, SREC, NANDYAL

Page 5

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Overview of Embedded System Architecture:


Every embedded system consists of custom-built hardware built around a Central
Processing Unit (CPU). This hardware also contains memory chips onto which the
software is loaded. The software residing on the memory chip is also called the
firmware.

Fig:3.1 Layered architecture of Embedded systems


The operating system runs above the hardware, and the application software runs
above the operating system. The same architecture is applicable to any computer
including a desktop computer. However, there are significant differences. It is not
compulsory to have an operating system in every embedded system. For small appliances
such as remote control units, air conditioners, toys etc., there is no need for an operating
system and you can write only the software specific to that application. For applications
involving complex processing, it is advisable to have an operating system.
In such a case, you need to integrate the application software with the operating
system and then transfer the entire software on to the memory chip. Once the software is

Dept of ECE, SREC, NANDYAL

Page 6

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


transferred to the memory chip, the software will continue to run for a long time you
dont need to reload new software.
Now, let us see the details of the various building blocks of the hardware of an
embedded system. As shown in Fig. the building blocks are;
Central Processing Unit (CPU)
Memory (Read-only Memory and Random Access Memory)
Input Devices
Output devices
Communication interfaces
Application-specific circuitry
Fig:3.2 Building Blocks of Hardware Embedded Systems

Dept of ECE, SREC, NANDYAL

Page 7

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Central Processing Unit (CPU):


The Central Processing Unit (processor, in short) can be any of the following:
microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is
a low-cost processor. Its main attraction is that on the chip itself, there will be many other
components such as memory, serial communication interface, analog-to digital converter
etc. So, for small applications, a micro-controller is the best choice as the number of
external components required will be very less. On the other hand, microprocessors are
more powerful, but you need to use many external components with them. D5P is used
mainly for applications in which signal processing is involved such as audio and video
processing.

Memory:
The memory is categorized as Random Access Memory (RAM) and Read Only
Memory (ROM). The contents of the RAM will be erased if power is switched off to the
chip, whereas ROM retains the contents even if the power is switched off. So, the
firmware is stored in the ROM.

Input devices:
Unlike the desktops, the input devices to an embedded system have very limited
capability. There will be no keyboard or a mouse, and hence interacting with the
embedded system is no easy task. Many embedded systems will have a small keypad-you
press one key to give a specific command. A keypad may be used to input only the digits.
Many embedded systems used in process control do not have any input device for user
interaction.

Output devices:
Dept of ECE, SREC, NANDYAL

Page 8

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


The output devices of the embedded systems also have very limited capability. A
small Liquid Crystal Display (LCD) may also be used to display some important
parameters.

Communication interfaces:
The embedded systems may need to, interact with other embedded systems at
they may have to transmit data to a desktop. To facilitate this, the embedded systems are
provided with one or a few communication interfaces such as RS232, RS422, RS485,
Universal Serial Bus (USB), IEEE 1394, Ethernet etc.

Application-specific circuitry:
Sensors, transducers, special processing and control circuitry may be required fat
an embedded system, depending on its application. This circuitry interacts with the
processor to carry out the necessary work. The entire hardware has to be given power
supply either through the 230 volts main supply or through a battery. The hardware has to
design in such a way that the power consumption is minimized.
3.2 POWER SUPPLY:
The input to the circuit is applied from the regulated power supply. The a.c. input
i.e., 230V from the mains supply is step down by the transformer to 12V and is fed to a
rectifier. The output obtained from the rectifier is a pulsating d.c voltage. So in order to
get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any
a.c components present even after rectification. Now, this voltage is given to a voltage
regulator to obtain a pure constant dc voltage

Dept of ECE, SREC, NANDYAL

Page 9

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

230V
AC

D.C
Output

50Hz

Step
down
transfor

Bridge
Rectif
er

Filter

voltag
e

fig:3.3 Power supply


Transformer:
Usually, DC voltages are required to operate various electronic equipment and
these voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the
a.c input available at the mains supply i.e., 230V is to be brought down to the required
voltage level. This is done by a transformer. Thus, a step down transformer is employed
to decrease the voltage to a required level.
Rectifier:
The output from the transformer is fed to the rectifier. It converts A.C. into
pulsating D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a
bridge rectifier is used because of its merits like good stability and full wave rectification.

Filter:

Dept of ECE, SREC, NANDYAL

Page 10

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Capacitive filter is used in this project. It removes the ripples from the output of
rectifier and smoothens the D.C. Output

received from this filter is constant until the

mains voltage and load is maintained constant. However, if either of the two is varied,
D.C. voltage received at this point changes. Therefore a regulator is applied at the output
stage.
Voltage regulator:
As the name itself implies, it regulates the input applied to it. A voltage regulator
is an electrical regulator designed to automatically maintain a constant voltage level. In
this project, power supply of 5V and 12V are required. In order to obtain these voltage
levels, 7805 and 7812 voltage regulators are to be used. The first number 78 represents
positive supply and the numbers 05, 12 represent the required output voltage levels.

CHAPTER-4
Dept of ECE, SREC, NANDYAL

Page 11

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


COMMUNICATIONS OR TECHNOLOGIES THAT WE
ARE USING IN THE PROJECT
4.1 GSM(Global system for mobiles):
Definition:
Global System for Mobile (GSM) is a second generation cellular standard
developed to cater voice services and data delivery using digital modulation.

Fig:4.1 GSm

GSM-History
Developed by Group Special Mobile (founded 1982) which was an
CEPT (Conference of European Post and Telecommunication)
Aim : to replace the incompatible analog system

Dept of ECE, SREC, NANDYAL

Page 12

initiative of

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Presently the responsibility of GSM standardization resides with special mobile
group under ETSI ( European telecommunication Standards Institute )

Full set of specifications phase-I became available in 1990

Today many providers all over the world use GSM (more than 135
Countries in Asia, Africa, Europe, Australia, America)
More than 1300 million subscribers in world and 45 million subscribers in India.
GSM IN WORLD

Fig:GSM in World

GSM SERVICES
Dept of ECE, SREC, NANDYAL

Page 13

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Tele-services
Bearer or Data Services
Supplementary services

Tele-services

Telecommunication services that enable voice communication


via mobile phones
Offered services
Mobile telephony
Emergency calling

Bearer or Data Services


Include various data services for information transfer between GSM and other
networks like PSTN, ISDN etc at rates from 300 to 9600 bps
Short Message Service (SMS) up to 160 character alphanumeric data transmission
to/from the mobile terminal
Unified Messaging Services(UMS)
Group 3 fax
Voice mailbox
Electronic mail

Supplementary services
Call related services :

Call Waiting- Notification of an incoming call while on the handset

Call Hold- Put a caller on hold to take another call

Call Barring- All calls, outgoing calls, or incoming calls

Call Forwarding- Calls can be sent to various numbers defined by the user

Multi Party Call Conferencing - Link multiple calls together

CLIP Caller line identification presentation

Dept of ECE, SREC, NANDYAL

Page 14

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

CLIR Caller line identification restriction

GSM System Architecture-I

Mobile Station (MS)


Mobile Equipment (ME)
Subscriber Identity Module (SIM)

Base Station Subsystem (BSS)


Base Transceiver Station (BTS)
Base Station Controller (BSC)

Network Switching Subsystem(NSS)


Mobile Switching Center (MSC)
Home Location Register (HLR)
Visitor Location Register (VLR)
Authentication Center (AUC)
Equipment Identity Register (EIR)

System Architecture Mobile Station (MS)


The Mobile Station is made up of two entities:
1. Mobile Equipment (ME)
2. Subscriber Identity Module (SIM)

Mobile Equipment

Dept of ECE, SREC, NANDYAL

Page 15

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Portable,vehicle mounted, hand held device
Uniquely identified by an IMEI (International Mobile Equipment Identity)
Voice and data transmission
Monitoring power and signal quality of surrounding cells for optimum handover
Power level : 0.8W 20 W
160 character long SMS.

Subscriber Identity Module (SIM)


Smart card contains the International Mobile Subscriber Identity (IMSI)
Allows user to send and receive calls and receive other subscribed services
Encoded network identification details
- Key Ki,Kc and A3,A5 and A8 algorithms
Protected by a password or PIN
Can be moved from phone to phone contains key information to activate the
phone

System Architecture Base Station Subsystem (BSS)


Base Station Subsystem is composed of two parts that communicate across the
standardized Abis interface allowing operation between components made by different
suppliers
1. Base Transceiver Station (BTS)
2. Base Station Controller (BSC)

System Architecture Base Station Subsystem (BSS)


Base Transceiver Station (BTS):
Encodes,encrypts,multiplexes,modulates and feeds the RF signals to the antenna.

Dept of ECE, SREC, NANDYAL

Page 16

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Frequency hopping
Communicates with Mobile station and BSC
Consists of Transceivers (TRX) units
Base Station Controller (BSC)
Manages Radio resources for BTS
Assigns Frequency and time slots for all MSs in its area
Handles call set up
Transcoding and rate adaptation functionality
Handover for each MS
Radio Power control
It communicates with MSC and BTS
System Architecture Network Switching Subsystem(NSS)
Mobile Switching Center (MSC)
Heart of the network
Manages communication between GSM and other networks
Call setup function and basic switching
Call routing
Billing information and collection
Mobility management
- Registration
- Location Updating
- Inter BSS and inter MSC call handoff
MSC does gateway function while its customer roams to other network by using
HLR/VLR.

Dept of ECE, SREC, NANDYAL

Page 17

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

System Architecture Network Switching Subsystem

Home Location Registers (HLR)


Permanent database about mobile subscribers in a large service area (generally one per
GSM network operator) Database contains IMSI, MS ISDN, prepaid/postpaid, roaming
restrictions, and supplementary services.

Visitor Location Registers (VLR)


-

Temporary database which updates whenever new MS enters its


area, by HLR database

Controls those mobiles roaming in its area

Reduces number of queries to HLR

Database contains IMSI, TMSI, MSISDN, MSRN, Location Area,


authentication key

Authentication Center (AUC)


-

Protects against intruders in air interface

Maintains authentication keys and algorithms and provides


security triplets ( RAND, SRES, Kc)

Generally associated with HLR

Equipment Identity Register (EIR)


- Database that is used to track handsets using the IMEI (International
Mobile Equipment Identity)
-

Made up of three sub-classes: The White List, The Black List and
the Gray List

Only one EIR per PLMN

Dept of ECE, SREC, NANDYAL

Page 18

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

OPERATION GSM:

Fig:4.2 Operation Of GSM

Call Routing:
Call Originating from MS
Call termination to MS

Dept of ECE, SREC, NANDYAL

Page 19

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Fig:4.3 Block Diagram For Call routing


Outgoing calls:
1.

MS sends dialed number to BSS

2.

BSS sends dialed number to MSC

3.
4.
5.
6.
7.

MSC checks VLR if MS is allowed the requested service.


If so, MSC asks to allocate resources for calls.
MSC routes the call to GMSC
GMSC routes the call to local exchange of called use.
Answer back (ring back) tone is routed from called user to MS via
GMSC, MSC, BSS

Incoming Calls:
Dept of ECE, SREC, NANDYAL

Page 20

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Fig:4.4 Block diaram for incoming call

Incoming a call
1. Calling a GSM subscribers
2. Forwarding call to GSMC
3. Signal Setup to HLR
4. Request MSRN from VLR
5. Forward responsible MSC to GMSC
6. Forward Call to current MSC.
7.

Get current status of MS

8. Paging of MS
9.

MS answers

Dept of ECE, SREC, NANDYAL

Page 21

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


10. Security checks
11. . Set up connection
Handovers:

Fig:4.5 Block diagram for Handovers


Between 1 and 2 Inter BTS / Intra BSC
Between 1 and 3
Inter BSC/ Intra MSC
Between 1 and 4
Inter MSC
Security in GSM
On air interface, GSM uses encryption and TMSI instead of IMSI.
SIM is provided 4-8 digit PIN to validate the ownership of SIM
3 algorithms are specified :
Dept of ECE, SREC, NANDYAL

Page 22

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


- A3 algorithm for authentication
- A5 algorithm for encryption
- A8 algorithm for key generation

Characteristics of GSM Standard


Fully digital system using 900,1800 MHz frequency band.
TDMA over radio carriers(200 KHz carrier spacing.
8 full rate or 16 half rate TDMA channels per carrier.
User/terminal authentication for fraud control.
Encryption of speech and data transmission over the radio path.
Full international roaming capability.
Low speed data services (upto 9.6 Kb/s).
Compatibility with ISDN.
Support of Short Message Service (SMS).
Advantages of GSM over Analog system:
Capacity increases
Reduced RF transmission power and longer battery life.
International roaming capability.
Better security against fraud (through terminal validation and user authentication).
Encryption capability for information security and privacy.
Compatibility with ISDN,leading to wider range of services

GSM Applications
Mobile telephony
GSM-R
Dept of ECE, SREC, NANDYAL

Page 23

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

4.2 AT89S8252 MICROCNTROLLER:

Fig:4.6 Microcontroller AT89S8252


MICROCONTROLLER
Microprocessors and microcontrollers are widely used in embedded systems
products.Microcontroller is a programmable device. A microcontroller has a CPU in
addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single
Dept of ECE, SREC, NANDYAL

Page 24

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in
microcontrollers makes them ideal for many applications in which cost and space are
critical.
The Intel 8052 is a Harvard architecture, single chip microcontroller (C) which
was developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s
and early 1990s, but today it has largely been superseded by a vast range of enhanced
devices with 8052-compatible processor cores that are manufactured by more than 20
independent manufacturers including Atmel, Infineon Technologies and Maxim
Integrated Products.
The microcontroller used in this project is AT89S8252. Atmel Corporation
introduced this 89S52 microcontroller.
The present project is implemented on Keil Uvision. In order to program the
device, Proload tool has been used to burn the program onto the microcontroller.
The features, pin description of the microcontroller and the software tools used
are discussed in the following sections.
FEATURES OF AT89S8252:
8K Bytes of In-System Reprogrammable Downloadable Flash Memory
2K Bytes EEPROM Endurance: 100,000 Write/Erase Cycles
4V to 6V Operating Range
Fully Static Operation: 0 Hz to 24 MHz
Three-level Program Memory Lock
256 x 8-bit Internal RAM
32 Programmable I/O Lines
Three 16-bit Timer/Counters
Nine Interrupt Sources
SPI Serial Interface

Dept of ECE, SREC, NANDYAL

Page 25

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Programmable UART Serial Channel

Interrupt Recovery from Power-down

Dual Data Pointer

Power-off Flag

DESCRIPTION:
The AT89S8252 is a low-power, high-performance CMOS 8-bit microcontroller
with 8K bytes of downloadable Flash programmable and erasable read-only memory
and 2K bytes of EEPROM. The device is manufactured using Atmels high-density
nonvolatile memory technology and is compatible with the industry-standard 80C51
instruction set and pinout.

The on-chip downloadable Flash allows the program memory to be


reprogrammed through an SPI serial interface or by a conventional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with downloadable Flash
on a monolithic chip, the Atmel AT89S8252 is a powerful microcontroller, which
provides a highly-flexible and cost-effective solution to many embedded control
applications.
The AT89S8252 provides the following standard features: 8K bytes of
downloadable Flash, 2K bytes of EEPROM, 256 bytes of RAM, 32 I/O lines, two
data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture,
a full duplex serial port, on-chip oscillator, and clock circuitry.
In addition, the AT89S8252 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port, and
interrupt system to continue functioning. The Power-down mode saves the RAM

Dept of ECE, SREC, NANDYAL

Page 26

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


contents but freezes the oscillator, disabling all other chip functions until the next
external interrupt or hardware reset.
The downloadable Flash can be changed a single byte at a time and is accessible
through the SPI serial interface. Holding RESET active forces the SPI bus into a
serial programming interface and allows the program memory to be written to or read
from unless lock bits have been activated.

Fig:4.7 pin diagram

Pin Description
VCC

Dept of ECE, SREC, NANDYAL

Page 27

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Pin 40 provides the supply voltage to the chip. The voltage is +5V.
GND
Ground.

XTAL1 and XTAL2


The 8052 has an on-chip oscillator but requires an external clock to run it.
Usually, a quartz crystal oscillator is connected to inputs XTAL1 (pin19) and XTAL2
(pin18). There are various speeds of 8052 family. Speed refers to the maximum oscillator
frequency connected to XTAL. When the 8052 is connected to a crystal oscillator and is
powered up, the frequency can be observed on the XTAL2 pin using the oscilloscope.
XTAL1 is the input to the inverting oscillator amplifier and input to the internal
clock operating circuit and XTAL2 is the output from the inverting oscillator amplifier.

ALE/PROG
Address Latch Enable is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG)
during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6
the oscillator frequency and may be used for external timing or clocking purposes. If
desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit
set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is
weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in
external execution mode.
PSEN (Program Store Enable)

Dept of ECE, SREC, NANDYAL

Page 28

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


It is the read strobe to external program memory. When the AT89S8252 is
executing code from external program memory, PSEN is acti-vated twice each machine
cycle, except that two PSEN activations are skipped during each access to external data
memory.
EA/VPP (External Access Enable)
EA must be strapped to GND in order to enable the device to fetch code from
external program memory locations starting at 0000H up to FFFFH. Note, however, that
if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped
to VCC for internal program executions. This pin also receives the 12-volt programming
enable voltage (VPP) during Flash programming when 12-volt programming is selected.
Ports 0, 1, 2 and 3
The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All
the ports upon RESET are configured as input, since P0-P3 have value FFH on them.
Port 0(P0)
Port 0 is also designated as AD0-AD7, allowing it to be used for both address and
data. ALE indicates if P0 has address or data. When ALE=0, it provides data D0-D7, but
when ALE=1, it has address A0-A7. Therefore, ALE is used for demultiplexing address
and data with the help of an internal latch.
When there is no external memory connection, the pins of P0 must be connected
to a 10K-ohm pull-up resistor. This is due to the fact that P0 is an open drain. With
external pull-up resistors connected to P0, it can be used as a simple I/O, just like P1 and
P2. But the ports P1, P2 and P3 do not need any pull-up resistors since they already have
pull-up resistors internally. Upon reset, ports P1, P2 and P3 are configured as input ports.
Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are
Dept of ECE, SREC, NANDYAL

Page 29

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that
are externally being pulled low will source current because of the internal pull-ups.

PROGRAMMING THE FLASH AND EEPROM


A 50% duty cycle clock can be programmed to come out on P1.0. This pin,
besides being a regular I/0 pin, has two alternate functions. It can be programmed to input
the external clock for Timer/Counter 2 or to output a 50% duty cycle clock ranging from
61 Hz to 4 MHz (for a 16-MHz operating frequency).
Port 2
With no external memory connection, P2 are used as simple I/O. With external
memory connections, port 2 must be used along with P0 to provide the 16-bit address for
the external memory. Port 2 is designated as A8-A15 indicating its dual function. While
P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the
address.
Port 2 also receives the high-order address bits and some control signals during
Flash programming and verification.
Port 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that
are externally being pulled low will source current because of the pull-ups. Port 3
receives some control signals for Flash programming and verification.

Dept of ECE, SREC, NANDYAL

Page 30

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Port 3 also serves the functions of various special features of the AT89S8252, as
shown in the following table.

Table: Port 3 Alternate functions

Data Memory EEPROM and RAM


The AT89S8252 implements 2K bytes of on-chip EEPROM for data storage and
256 bytes of RAM. The upper 128 bytes of RAM occupy a parallel space to the Special
Function Registers i.e., the upper 128 bytes have the same addresses as the SFR space but
are physically separate from SFR space.
When an instruction accesses an internal location above address 7FH, the address
mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of
RAM or the SFR space.
Instructions that use direct addressing access SFR space. For example, the following
direct addressing instruction accesses the SFR at location 0A0H (which is P2).
MOV 0A0H, #data

Dept of ECE, SREC, NANDYAL

Page 31

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Instructions that use indirect addressing 128 bytes of data RAM are available as
stack space.The on-chip EEPROM data memory is selected by setting the EEMEN bit in
the WMCON register at SFR address location 96H..

4.3 SWITCH AND LED INTERFACING WITH THE MICROCONTROLLER:


Switches and LEDs are the most widely used input/output devices of the 8052.
SWITCH INTERFACING:
CPU accesses the switches through ports. Therefore these switches are connected
to a microcontroller. This switch is connected between the supply and ground terminals.
A single microcontroller (consisting of a microprocessor, RAM and EEPROM and
several ports all on a single chip) takes care of hardware and software interfacing of the
switch.
These switches are connected to an input port. When no switch is pressed, reading
the input port will yield 1s since they are all connected to high (Vcc). But if any switch is
pressed, one of the input port pins will have 0 since the switch pressed provides the path
to ground. It is the function of the microcontroller to scan the switches continuously to
detect and identify the switch pressed.
Vcc

R
P2.0

Dept of ECE, SREC, NANDYAL

Page 32

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Gnd
fig:4.8InterfacingswitchwiththeMicrocontroller

Dept of ECE, SREC, NANDYAL

Page 33

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Thus now the two conditions are to be remembered:


1. When the switch is open, the total supply i.e., Vcc appears at the port pin P2.0
P2.0 = 1
2. When the switch is closed i.e., when it is pressed, the total supply path is provided
to ground. Thus the voltage value at the port pin P2.0 will be zero.
P2.0 = 0
By reading the pin status, the microcontroller identifies whether the switch is pressed
or not. When the switch is pressed, the corresponding related to this switch press written in
the program will be executed.
LED INTERFACING:
LED stands for Light Emitting Diode.
Microcontroller port pins cannot drive these LEDs as these require high currents to
switch on. Thus the positive terminal of LED is directly connected to Vcc, power supply and
the negative terminal is connected to port pin through a current limiting resistor.
This current limiting resistor is connected to protect the port pins from sudden flow of
high currents from the power supply.
Thus in order to glow the LED, first there should be a current flow through the LED.
In order to have a current flow, a voltage difference should exist between the LED terminals.
To ensure the voltage difference between the terminals and as the positive terminal of LED is
connected to power supply Vcc, the negative terminal has to be connected to ground. Thus
this ground value is provided by the microcontroller port pin. This can be achieved by writing
an instruction CLR P1.0. With this, the port pin P1.0 is initialized to zero and thus now a
voltage difference is established between the LED terminals and accordingly, current flows
and therefore the LED glows. LED and switches can be connected to any one of the four port
pins.

Dept of ECE,SREC,NANDYAL.

Page 34

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Vcc
P1.0

Fig: 4.9 LED Interfacing with the Microcontroller


Light emitting diode:

Light-emitting diodes are elements for light signalization in electronics. They are
manufactured in different shapes, colors and sizes. For their low price, low consumption and
simple use, they have almost completely pushed aside other light sources- bulbs at first place.
They perform similar to common diodes with the difference that they emit light when current
flows through them.

Fig:4.9 LED

4.4 SERIAL COMMUNICATIONS:


Dept of ECE,SREC,NANDYAL.

Page 35

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


TIMERS:
The 8052 has two timers: Timer 0 and Timer 1. They can be used either as timers to
generate a time delay or as counters to count events happening outside the microcontroller
Both Timer 0 and Timer 1 are 16-bit wide. Since the 8052 has an 8-bit architecture,
each 16-bit timer is accessed as two separate registers of low byte and high byte.
Lower byte register of Timer 0 is TL0 and higher byte is TH0. Similarly lower byte
register of Timer1 is TL1 and higher byte register is TH1.
TMOD (timer mode) register:
Both timers 0 and 1 use the same register TMOD to set the various operation modes.
TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the
upper 4 bits for Timer 1. In each case, the lower 2 bits are used to set the timer mode and the
upper 2 bits to specify the operation.

(MSB)

(LSB)

GATE
M0

C/T

M1

M0

GATE

C/T

M1

GATE
Every timer has a means of starting and stopping. The timers in the 8052 have both.
The start and stop of the timer are controlled by the way of software by the TR (timer start)
bits TR0 and TR1. The hardware way of starting and stopping the timer by an external source
is achieved by making GATE=1 in the TMOD register.
C/T

Dept of ECE,SREC,NANDYAL.

Page 36

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Timer or counter selected. Cleared for timer operation and set for counter operation.
M1 Mode bit 1
M0 Mode bit 0
M1

M0

Mode

Operating Mode

13-bit timer mode


8-bit timer/counter THx with TLx as 5-bit prescaler

16-bit timer mode


16-bit timer/counters THx and TLx are cascaded

8-bit auto reload timer/counter


THx holds a value that is to be reloaded into TLx .

The mode used here to generate a time delay is MODE 2.


This mode 2 is an 8-bit timer and therefore it allows only values of 00H to FFH to be
loaded into the timers register TH. After TH is loaded with the 8-bit value, the 8052 give a
copy of it to TL. When the timer starts, it starts to count up by incrementing the TL register. It
counts up until it reaches its limit of FFH. When it rolls over from FFH to 00H, it sets high
the TF (timer flag). If Timer 0 is used, TF0 goes high and if Timer 1 is used, TF1 goes high.
When the TL register rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically
with the original value kept by the TH register.

Asynchronous and synchronous communication:

Dept of ECE,SREC,NANDYAL.

Page 37

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Computers transfer data in two ways: parallel and serial. In parallel data transfers,
often 8 or more lines are used to transfer data to a device that is only a few feet away.
Although a lot of data can be transferred in a short amount of time by using many wires in
parallel, the distance cannot be great. To transfer to a device located many meters away, the
serial method is best suitable.
In serial communication, the data is sent one bit at a time. The 8052 has serial
communication capability built into it, there by making possible fast data transfer using only
a few wires.
The fact that serial communication uses a single data line instead of the 8-bit data line
instead of the 8-bit data line of parallel communication not only makes it cheaper but also
enables two computers located in two different cities to communicate over the telephone.
Serial data communication uses two methods, asynchronous and synchronous. The
synchronous method transfers a block of data at a time, while the asynchronous method
transfers a single byte at a time. With synchronous communications, the two devices initially
synchronize themselves to each other, and then continually send characters to stay in sync.
Even when data is not really being sent, a constant flow of bits allows each device to know
where the other is at any given time. That is, each character that is sent is either actual data or
an idle character.
The serial ports on IBM-style PCs are asynchronous devices and therefore only
support asynchronous serial communications. Asynchronous means "no synchronization",
and thus does not require sending and receiving idle characters. However, the beginning and
end of each byte of data must be identified by start and stop bits.
There are special IC chips made by many manufacturers for serial data
communications. These chips are commonly referred to as UART(universal asynchronous
receiver-transmitter) and USART(universal synchronous-asynchronous receiver-transmitter).
The 8052 has a built-in UART.
In the asynchronous method, the data such as ASCII characters are packed between a
start and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The
start bit is always a 0 (low) and stop bit (s) is 1 (high). This is called framing.
The rate of data transfer in serial data communication is stated as bps (bits per
second). Another widely used terminology for bps is baud rate. The data transfer rate of a
given computer system depends on communication ports incorporated into that system. And
Dept of ECE,SREC,NANDYAL.

Page 38

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


in asynchronous serial data communication, this baud rate is generally limited to 100,000bps.
The baud rate is fixed to 9600bps in order to interface with the microcontroller using a crystal
of 11.0592 MHz.
RS232 CABLE:
To allow compatibility among data communication equipment, an interfacing standard
called RS232 is used. Since the standard was set long before the advent of the TTL logic
family, its input and output voltage levels are not TTL compatible. For this reason, to connect
any RS232 to a microcontroller system, voltage converters such as MAX232 are used to
convert the TTL logic levels to the RS232 voltage levels and vice versa.
MAX 232:
Max232 IC is a specialized circuit which makes standard voltages as required by
RS232 standards. This IC provides best noise rejection and very reliable against discharges
and short circuits. MAX232 IC chips are commonly referred to as line drivers.
To ensure data transfer between PC and microcontroller, the baud rate and voltage
levels of Microcontroller and PC should be the same. The voltage levels of microcontroller
are logic1 and logic 0 i.e., logic 1 is +5V and logic 0 is 0V. But for PC, RS232 voltage levels
are considered and they are: logic 1 is taken as -3V to -25V and logic 0 as +3V to +25V. So,
in order to equal these voltage levels, MAX232 IC is used. Thus this IC converts RS232
voltage levels to microcontroller voltage levels and vice versa.

Fig: 4.10 Pin diagram of MAX 232 IC

SCON (serial control) register:


Dept of ECE,SREC,NANDYAL.

Page 39

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


The SCON register is an 8-bit register used to program the start bit, stop bit and data bits of
data framing.

SM0

SM1

SM2

REN

TB8

RB8

TI

SM0

SCON.7

Serial port mode specifier

SM1

SCON.6

Serial port mode specifier

SM2

SCON.5

Used for multiprocessor communication

REN

SCON.4

Set/cleared by software to enable/disable reception

TB8

SCON.3

Not widely used

RB8

SCON.2

Not widely used

TI

SCON.1

Transmit interrupt flag. Set by hardware .

RI

SCON.0

Receive interrupt flag.

4.5 LCD ( Liquid Crystal display):


LCD is finding wide spread use replacing LEDs (seven segment LEDs or other multi
segment LEDs) because of the following reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics. This is in contrast to LEDs,
which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the
task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep
displaying the data.
4. Ease of programming for characters and graphics.

Dept of ECE,SREC,NANDYAL.

Page 40

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


These components are specialized for being used with the microcontrollers, which
means that they cannot be activated by standard IC circuits. They are used for writing
different messages on a miniature LCD.
Fig:4.11 LCD display

A model described here is for its low price and great possibilities most frequently used
in practice. It is based on the HD44780 . It displays all the alphabets, Greek letters,
punctuation marks, mathematical symbols etc. In addition, it is possible to display symbols
that user makes up on its own. Automatic shifting message on display (shift left and right),
appearance of the pointer, backlight etc. are considered as useful characteristics.
Pins Functions
There are pins along one side of the small printed board used for connection to the
microcontroller. There are total of 14 pins marked with numbers (16 in case the background
light is built in). Their function is described in the table below:

Function

Pin
Number

Name

Logic
State

Description

Ground

Vss

0V

Power supply

Vdd

+5V

Contrast

Vee

0 - Vdd

Control of
operating

Dept of ECE,SREC,NANDYAL.

RS

R/W

0
1

D0 D7 are interpreted as
commands
D0 D7 are interpreted as data

Write data (from controller to

LCD)

Page 41

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Read data (from LCD to
controller)
0
6

1
From 1 to 0

Data / commands

Access to LCD disabled


Normal operating
Data/commands are transferred to
LCD

D0

0/1

Bit 0 LSB

D1

0/1

Bit 1

D2

0/1

Bit 2

10

D3

0/1

Bit 3

11

D4

0/1

Bit 4

12

D5

0/1

Bit 5

13

D6

0/1

Bit 6

14

D7

0/1

Bit 7 MSB

LCD screen:
LCD screen consists of two lines with 16 characters each. Each character consists of
5x7 dot matrix. Contrast on display depends on the power supply voltage and whether
messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied
on pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions
of displays have built in backlight (blue or green diodes). When used during operating, a
resistor for current limitation should be used (like with any LE diode).

Dept of ECE,SREC,NANDYAL.

Page 42

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Fig:4.12 LCD Screen

LCD Basic Commands


All data transferred to LCD through outputs D0-D7 will be interpreted as commands
or as data, which depends on logic state on pin RS:
RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in processor
addresses built in map of characters and displays corresponding symbols.

List of commands of LCD display:


Command

R RW D7 D6 D5 D4 D3 D2 D1 D0

Dept of ECE,SREC,NANDYAL.

Page 43

Execution

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


S

Time

Clear display

0 0 0

1.64mS

Cursor home

0 0 0

1.64mS

Entry mode set

0 0 0

40uS

Display on/off control

0 0 0

U B

40uS

Cursor/Display Shift

0 0 0

1 D/C R/L x

Function set

0 0 1

Set CGRAM address

0 1

Set DDRAM address

Read BUSY flag (BF)

Write to CGRAM or DDRAM 1


Read from CGRAM or
DDRAM

I/D 1 = Increment (by 1)

B
F

D
L

0 = Display shift off

40uS

40uS

CGRAM address

40uS

DDRAM address

0 D7 D6 D5 D4 D3 D2 D1 D0

40uS

1 D7 D6 D5 D4 D3 D2 D1 D0

40uS

R/L 1 = Shift right


0 = Shift left
DL 1 = 8-bit interface
0 = 4-bit interface

D 1 = Display on

N 1 = Display in two lines

0 = Display off

0 = Display in one line

U 1 = Cursor on
0 = Cursor off

Dept of ECE,SREC,NANDYAL.

40uS

DDRAM address

0 = Decrement (by 1)
S 1 = Display shift on

I/

F 1 = Character format 5x10 dots


0 = Character format 5x7 dots

Page 44

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


LCD Connection
Depending on how many lines are used for connection to the microcontroller, there
are 8-bit and 4-bit LCD modes. The appropriate mode is determined at the beginning of the
process in a phase called initialization. In the first case, the data are transferred through
outputs D0-D7 as it has been already explained. In case of 4-bit LED mode, for the sake of
saving valuable I/O pins of the microcontroller, there are only 4 higher bits (D4-D7) used for
communication, while other may be left unconnected.
Consequently, each data is sent to LCD in two steps: four higher bits are sent first
(that normally would be sent through lines D4-D7), four lower bits are sent afterwards. With
the help of initialization, LCD will correctly connect and interpret each data received.
Besides, with regards to the fact that data are rarely read from LCD (data mainly are
transferred from microcontroller to LCD) one more I/O pin may be saved by simple
connecting R/W pin to the Ground. Such saving has its price. Even though message
displaying will be normally performed, it will not be possible to read from busy flag since it
is not possible to read from display.

LCD Initialization
Once the power supply is turned on, LCD is automatically cleared. This process lasts
for approximately 15mS. After that, display is ready to operate. The mode of operating is set
by default. This means that:
1. Display is cleared
2. Mode
DL = 1 Communication through 8-bit interface
N = 0 Messages are displayed in one line
F = 0 Character font 5 x 8 dots
3. Display/Cursor on/off
D = 0 Display off
U = 0 Cursor off
B = 0 Cursor blink off

Dept of ECE,SREC,NANDYAL.

Page 45

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


4. Character entry
ID = 1 Addresses on display are automatically incremented by 1
S = 0 Display shift off
Automatic reset is mainly performed without any problems. Mainly but not always! If
for any reason power supply voltage does not reach full value in the course of 10mS, display
will start perform completely unpredictably. If voltage supply unit can not meet this condition
or if it is needed to provide completely safe operating, the process of initialization by which a
new reset enabling display to operate normally must be applied.
Algorithm according to the initialization is being performed depends on whether
connection to the microcontroller is through 4- or 8-bit interface. All left over to be done after
that is to give basic commands and of course- to display messages.

4.6 CONTRAST CONTROL:


To have a clear view of the characters on the LCD, contrast should be adjusted. To
adjust the contrast, the voltage should be varied. For this, a preset is used which can behave
like a variable voltage device. As the voltage of this preset is varied, the contrast of the LCD
is adjusted.
Fig:4.13 Variable resistor

4.7 INTERFACING THE KEYPAD TO 8052:

At the lowest level, keyboards are organized in a matrix of rows and columns. The
CPU accesses both rows and columns through ports. Therefore, with two 8-bit ports, an 8*8
matrix of keys can be connected to a microprocessor. When a key is pressed, a row and a
column make a contact, otherwise there is no connection between rows and columns. A single
microcontroller (consisting of a microprocessor, RAM, EPROM and several ports all on a

Dept of ECE,SREC,NANDYAL.

Page 46

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


single chip) takes care of hardware and software interfacing of the keypad. In such systems, it
is the function of programs stored in EPROM of the microcontroller to scan the keys
continuously, identify which one has been activated and present it to the motherboard.

Fig:4.14 4*3 Matrix Keypad Connections to Ports


Scanning and identifying the key:
The rows are connected to an output port and the columns are connected to an input
port. If no key has been pressed, reading the input port will yield 1s for all columns since they
are all connected to high (Vcc). If all the rows are grounded and a key is pressed, one of the
columns will have 0 since the key pressed provides the path to ground. It is the function of
the microcontroller to scan the keypad continuously to detect and identify the key pressed.
Grounding rows and reading the columns:
To detect a pressed key, the microcontroller grounds all rows by providing 0 (zero) to
the output latch, then it reads the columns. If the data read from the columns is D2-D0 =111,
no key has been pressed and the process continues until a key press is detected. However, if

Dept of ECE,SREC,NANDYAL.

Page 47

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


one of the column bits has a zero, this means that a key press has occurred i.e., for example, if
D2-D0=110, this means that a key in the D0 column has been pressed. After a key press is
detected, the microcontroller will go through a process of identifying the key.

EEPROM:
In the design of all microprocessors-based systems, semiconductor memories are used
as primary storage for code and data. Semiconductor memories are connected directly to the
CPU and they are the memory that the CPU first asks for information (code and data). For
this reason, semiconductor memories are sometimes referred to as primary memory.
Important Terminology common to all Semiconductor Memories:
Memory capacity:
The number of bits that a semiconductor memory chip can store is called chip
capacity. It can be in units of Kilobits, Megabits and so on. This must be distinguished from
the storage capacity of computer system. While the memory capacity of a memory IC chip is
always given in bits, the memory capacity of a computer system is given in bytes.
Memory organization:
Memory chips are organized into a number of locations within the IC. Each location
can hold 1 bit, 4 bits, 8 bits or even 16 bits, depending on how it is designed internally. The
number of bits that each location within the memory chip can hold is always equal to the
number of data pins on the chip. i.e., the total number of bits that a memory chip can store is
equal to the number of locations times the number of data bits per location.
Speed:
One of the most important characteristics of a memory chip is the speed at which its
data can be accessed. The speed of the memory chip is commonly referred to as its access
time. The access time of memory chip varies from a few nanoseconds to hundreds of
nanoseconds, depending on the IC technology used in the design and fabrication process.The

Dept of ECE,SREC,NANDYAL.

Page 48

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


different types of memories are RAM, ROM, EPROM and EEPROM.RAM and ROM are
inbuilt in the microprocessor.
This project requires the data such as the total number of available units and the pulse
count to be stored permanently and this data modifies upon the power consumption. Thus this
data has to be stored in such a location where it cannot be erased when power fails and also
the data should be allowed to make changes in it without the system interface i.e., there
should be a provision in such a way that the data should be accessed (or modified) while it is
in system board but not external erasure and programming. The flash memory inbuilt in the
microcontroller can erase the entire contents in less than a second and the erasure method is
electrical. But the major drawback of Flash memory is that when flash memorys contents are
erased, the entire device will be erased but not a desired section or byte.For this purpose, we
prefer EEPROM in our project.
EEPROM (Electrically Erasable Programmable Read only memory)
EEPROM has several advantages over other memory devices, such as the fact that its
method of erasure is electrical and therefore instant. In addition, in EEPROM one can select
which byte to be erased, in contrast to flash , in which the entire contents of ROM are erased.
The main advantage of EEPROM is that one can program and erase its contents while it is in
system board. It does not require physical removal of the memory chip from its socket. In
general, the cost per bit for EEPROM is much higher when compared to other devices.

4.8 Vibration Detector:


Here we use a ceramic piezoelectric buzzer plate for vibration detection.Piezo ceramic
buzzers generate sound through the bending vibrations of a thin metal plate adhered to a
piezo ceramic disc.

Dept of ECE,SREC,NANDYAL.

Page 49

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Fig:4.14 Vibration Detector

These buzzers feature low power consumption, a safe, spark-free and non-contact
structure, and a small size and light weight for an easy mounting to printed circuit boards. As
a result, an increasing number of piezoceramic buzzers are now used to generate an artificial
voice in combination with voice synthesizing ICs. To produce high-quality piezoceramic
buzzers, FDK has capitalized on many years of piezoceramics production and outstanding
ceramic processing technologies and thin film forming techniques. By adding a sophisticated
audio know-how to this manufacturing expertise, FDK offers a large array of electronic tone
generating products, such as piezoceramic diaphragms, sounders and buzzers, to meet loud
sound outputs, wide frequency ranges, and many other requirements.

4.9 Load cell:


a load cell is described as a weight measurement device necessary for
electronic scales that display weights in digits. However, load cell is not restricted to
weight measurement in electronic scales.Load cell is a passive transducer or sensor which
converts applied force into electrical signals.
Dept of ECE,SREC,NANDYAL.

Page 50

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Fig:4.15 Load cell


4.10 LPG SENSOR MQ-5:
This sensor detect the gas and pass the variable voltage to pic18f1320 and If the gas
level is normal lies between 1.2 volt to 4 volt, I activated two leds and a buzzer in slow mode
for early warning then if the gas level goes high then I activated a led and 2 buzzer in fast
mode it is for high level of gas so I done it for that Sensitive material of MQ-5 gas sensor is
SnO2, which with lower conductivity in clean air. When the Target combustible gas exist, the
sensors conductivity is higher along with the gas concentration rising.MQ-5 gas sensor has
high sensitivity to Methane, Propane and Butane, and could be used to detect both Methane
and Propane. The sensor could be used to detect different combustible gas especially
Methane, it is with low cost and suitable for different application.
4.11 ZIGBEE:
ZigBee is a specification for a suite of high-level communication protocols used to
create personal area network built from small, low-power digital radios. ZigBee is based
on an IEEE 802.15.4 standard. Though its low power consumption limits transmission
distances to 10100 meters line-of-sight, depending on power output and environmental
characteristics.
ZigBee devices can transmit data over long distances by passing data through a mesh
network of intermediate devices to reach more distant ones. ZigBee is typically used in low
data rate applications that require long battery life and secure networking .

Dept of ECE,SREC,NANDYAL.

Page 51

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Fig:4.16 Zigbee

4.12Relay:
The main operation of a relay comes in places where only a low-power signal
can be used to control a circuit. It is also used in places where only one signal can be
used to control a lot of circuits. The application of relays started during the invention
of telephones. They played an important role in switching calls in telephone
exchanges.They were also used in long distance telegraphy. They were used to
switch the signal coming from one source to another destination.

Fig:4.17 Relay

CHAPTER-5
HARDWARE DESCRIPTION
Dept of ECE,SREC,NANDYAL.

Page 52

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


The system proposed consists of three major modules namely, leakage detection
module, GSM module with PIC microcontroller, protection circuitry. It uses ATMEGA168,
which is an 8 bit microcontroller. It finds wide application due to its features and low power.
The leakage detection module consists of the MQ-5 gas sensor and the associated
circuitry to detect the amount of combustible gas present in the surrounding .The sensitivity
of the gas sensor can be adjusted using external circuitry. The sensor is insensitive to air. The
output of sensor module is connected to ADC of the microcontroller.The microcontroller
digities the voltage and checks if the concentration is within safe levels. If the concentration
of the combustible gases is beyond safe levels (the safety level is programmable) the
microcontroller immediately activates an alarm and the LEDs and turns off the power
supply, then sends alert SMS about leakage to the stored numbers via GSM and further .

Fig:5.1 Block diagram of leakage system control and prevention

In this prototype, gas leakage detection has been given a highest priority. MQ6 placed
in the vicinity of the gas cylinder. In the advent of leakage, the resistance of the sensor
decreases increasing its conductivity. Corresponding pulse is fed to microcontroller and
simultaneously switches on the buzzer and exhaust fan which we can reset by a manual reset
Dept of ECE,SREC,NANDYAL.

Page 53

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


switch, and automatically turns off the power supply to avoid the fire accidents.Also a logic
high pulse (+5 V) is given as an interrupt to INT0 pin of ATMega16 Microcontroller.
Microcontroller sends a message EMERGENCY ALERT: LPG gas leakage found in your
home to required cell numbers via GSM module and the same will be displayed on LCD.

SOFTWARE DESCRIPTION
Keil development tools, designed for ARM processor-based microcontroller devices,
support every level of developer from the professional application engineer to the student just
learning about embedded software development. The industry-standard Keil C/C++
Compilers, Macro Assemblers, Debuggers, Real-Time Kernels, and Single-board Computers
support ALL ARMcompatible derivatives and help you in getting your projects completed on
schedule. Embedded C is a set of language extensions for the C Programming language by
the C Standards committee to address commonality issues that exist between C extensions for
different embedded systems. Embedded C programming requires nonstandard extensions to
the C language in order to support exotic features such as fixed-point arithmetic, multiple
distinct memory banks, and basic I/O operations. In 2008, the C Standards Committee
extended the C language to address these issues by providing a common standard for all.

Fig:5.2 Prototype of smart gas cylinder

CHAPTER-6
ADVANTAGES AND APPLICATIONS
Dept of ECE,SREC,NANDYAL.

Page 54

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


Advantages and Applications:
Automatic LPG cylinder Booking and Leakage Management system will ensure a
safe, secured, and provisioned and comfort services for the consumers of LPG. It can display
weight of the gas on an indicator. The machine can caution housewives through its beep. The
machine can also be used by LPG agencies. It can be applied in the following areas,
Domestic (home)
Industries
Water plant
Energy consumption side
Gas agencies

CHAPTER-7
CONCLUSION
Dept of ECE,SREC,NANDYAL.

Page 55

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

CONCLUSION:

The gas leakage detection system was proposed, designed and successfully
implemented in this paper for home safety and industrial applications. This system detects the
leakage of the LPG and alerts the consumer about the leak by SMS and as an emergency
measure the system will turn off the power supply, while activating the alarm. Along with gas
leakage detection, this system gives a fully automated approach towards the gas booking.
Real time weight measurement of the gas and its display on LCD makes it an efficient home
security system and also can be used in industries and other places to detect gas leaks. This
project is implemented using the 8051 processor and simulated using the Keil software. The
cost involved in developing the system is significantly low and is much less than the cost of
gas detectors commercially available in the market.

REFERENCES

1. A CheSoh, M K Hassan, and A J Ishak Vehicle Gas Leakage Detector.

Dept of ECE,SREC,NANDYAL.

Page 56

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


2. ATMega 16 Datasheet; www.atmel.com
3. D M Han and J H Lim (2010), Smart Home Energy Management System Using IEEE
802.15.4 and Zigbee, IEEE Trans. On Consumer Electronics, Vol. 56, No. 3, pp. 1403-1410.
4. Fraiwan L, Lweesy K, Bani-Salma, A Mani N (2011), A Wireless Home Safety Gas
Leakage Detection System, Proc. of 1st Middle East, Conference on Biomedical
Engineering, pp.11-14.
5. G V Hippel (2005), Democratizing Innovation, MIT press, Cambridge, MA.
6. Hanwei Electronics Co. Ltd (2002), MQ-6 GasSensor Technical Data.
7. Kelvin R Sullivan, 7. Kelvin R Sullivan, Understanding Relays, A tutorial on relays.
8. M B Fish, R T Wainer, Standoff Gas Leakage Detectors Based on Tunable Diodes Laser
Absorption Spectroscopy.
9. Nakano S, Goto Y, Yokosawa K, Tsukada K (2005), Hydrogen Gas Detection System
Prototype with Wireless Sensor Networks, Proc. of IEEEConference on Sensors, pp. 1- 4.
10. Nasaruddin N M B, Elamvazuthi I, Hanif N H H B M (2009), Overcoming Gas Detector
Fault Alarm Due to Moisture, Proc. of IEEE Student Conference on Research and
Development, pp. 426-42

KEIL COMPILER
Keil Software is the leading vendor for 8/16-bit development tools (ranked at first
position in the 2004 Embedded Market Study of the Embedded Systems and EE Times
magazine). Keil Software is represented world-wide in more than 40 countries. Since the
Dept of ECE,SREC,NANDYAL.

Page 57

SMART GAS CYLINDER USING EMBEDDED SYSTEMS


market introduction in 1988, the Keil C51 Compiler is the de facto industry standard and
supports more than 500 current 8051 device variants. Now, Keil Software offers development
tools for ARM.
Keil Software makes C compilers, macro assemblers, real-time kernels, debuggers,
simulators, integrated environments, and evaluation boards for the 8051, 251, ARM, and
XC16x/C16x/ST10 microcontroller families.
Keil Software is pleased to announce simulation support for the Atmel AT91
ARM family of microcontrollers. The Keil Vision Debugger simulates the complete ARM
instruction-set as well as the on-chip peripherals for each device in the AT91 ARM/Thumb
microcontroller family. The integrated simulator provides complete peripheral simulation.
Other new features in the Vision Debugger include:
An integrated Software Logic Analyzer that measures I/O signals as well as program
variables and helps developers create complex signal processing algorithms.
An Execution Profiler that measures time spent in each function, source line, and
assembler instruction. Now developers can find exactly where programs spend the most time.
"Using nothing more than the provided simulation support and debug scripts,
developers can create a high-fidelity simulation of their actual target hardware and
environment. No extra hardware or test equipment is required. The Logic Analyzer and
Execution Profiler will help developers when it comes time to develop and tune signaling
algorithms." said Jon Ward, President of Keil Software USA, Inc.

Vision3 :
The Vision3 IDE is a Windows-based software development platform that combines
a robust editor, project manager, and makes facility. Vision3 integrates all tools including
the C compiler, macro assembler, linker/locator, and HEX file generator. Vision3 helps
expedite the development process of your embedded applications by providing the following:

Full-featured source code editor,


Device database for configuring the development tool setting,
Project manager for creating and maintaining your projects,

Dept of ECE,SREC,NANDYAL.

Page 58

SMART GAS CYLINDER USING EMBEDDED SYSTEMS

Integrated make facility for assembling, compiling, and linking your embedded

applications,
Dialogs for all development tool settings,
True integrated source-level Debugger with high-speed CPU and peripheral simulator,
Advanced GDI interface for software debugging in the target hardware and for

connection to Keil ULINK,


Flash programming utility for downloading the application program into Flash ROM,
Links to development tools manuals, device datasheets & users guides.
The Vision3 IDE offers numerous features and advantages that help you quickly and

successfully develop embedded applications. They are easy to use and are guaranteed to help
you achieve your design goals.
The Vision3 IDE and Debugger is the central part of the Keil development tool
chain. Vision3 offers a Build Mode and a Debug Mode.
In the Vision3 Build Mode you maintain the project files and generate the
application.

Dept of ECE,SREC,NANDYAL.

Page 59

You might also like