41
CHAPTER 1. INTRODUCTION AUTOMATED GAS LEAKAGE DETECTION AND PREVENTION SYSTEMis an embedded project. Embedded is the combination of both hardware and software. Hardware in this field is electronics hardware whereas the software is the programming of the microcontroller .After food clothes and shelter security is the basic need of an individual. Here we have successfully implemented a system which provides gas security with buzzer. Along with the buzzer a motor has been installed with the system to turn the gas supply when the leakage has been detected.

part 1 (Autosaved).docx

Embed Size (px)

Citation preview

Page 1: part 1 (Autosaved).docx

CHAPTER 1.

INTRODUCTION

“AUTOMATED GAS LEAKAGE DETECTION AND PREVENTION SYSTEM” is

an embedded project. Embedded is the combination of both hardware and software.

Hardware in this field is electronics hardware whereas the software is the programming of

the microcontroller .After food clothes and shelter security is the basic need of an individual.

Here we have successfully implemented a system which provides gas security with buzzer.

Along with the buzzer a motor has been installed with the system to turn the gas supply when

the leakage has been detected.

Page 2: part 1 (Autosaved).docx

COMPONENTS USED

1) Microcontroller AT89C2051

2) LM7805 Regulator

3) Resistors

4) Crystal oscillator

5) Capacitors

6) Transformer

7) Diodes

8) Transistors

9) Connectors

10) Gas Sensor

11) PCB developing equipments

12) motor

13) Relay

Page 3: part 1 (Autosaved).docx

COMPONENTS DESCRIPTION

1) MICROCONTROLLER AT89C2051

Features

• Compatible with MCS-51™ Products

• 2K Bytes of Re programmable Flash Memory

– Endurance: 1,000 Write/Erase Cycles

• 2.7V to 6V Operating Range

• Fully Static Operation: 0 Hz to 24 MHz

• Two-level Program Memory Lock

• 128 x 8-bit Internal RAM

• 15 Programmable I/O Lines

• Two16-bit Timer/Counters

• Six Interrupt Source

• Programmable Serial UART Channel

• Direct LED Drive Outputs

• On-chip Analog Comparator

• Low-power Idle and Power-down Mod

Page 4: part 1 (Autosaved).docx

TheAT89C2051 is low-voltage; high-performance CMOS 8-bit microcomputer

with2K bytes of Flash programmable and erasable read only memory (PEROM). The

device is manufactured using Atmel’s high-density nonvolatile memory technology

and is compatible with the industry-standard MCS-51 instruction set. By combining

versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C2051 is a

powerful microcomputer, which provides a highly flexible and cost-effective solution

to many embedded control applications.

The AT89C2051 provides the following standard features: 2K bytes of Flash, 128bytes

of RAM, 15 I/O lines, two 16-bit timer/counters, a five vector two-level interrupt

architecture, a full duplex serial port, a precision analog comparator, on-chip oscillator

and clock circuitry. In addition, the AT89C2051 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 contents but freezes the oscillator disabling all other chip functions until the next

hardware reset.

Page 5: part 1 (Autosaved).docx

PIN CONFIGURATION

Fig. 1.2.1

Page 6: part 1 (Autosaved).docx

PIN DESCRIPTION

1) VCC: Supply voltage

2) GND: Ground

3) PORT 1:

Port 1 is an 8-bit bi-directional I/O port. Port pins P1.2 toP1.7 provides internal pull-ups.

P1.0 and P1.1 require external pull-ups. P1.0 and P1.1 also serve as the positive input (AIN0)

and the negative input (AIN1), respectively, of the on-chip precision analog comparator. The

Port 1 output buffers can sink 20 m A and can drive LED displays directly. When 1s are

written to Port 1 pins, they can be used as inputs. When pins P1.2 to P1.7 are used as inputs

and are externally pulled low, they will source current (IIL) because of the internal pull-ups.

Port 1 also receives code data during Flash programming and verification.

4) PORT 3:

Port 3 pins P3.0 to P3.5, P3.7 are seven bi-directional I/O pins with internal pull-ups. P3.6 is

hard-wired as an input to the output of the on-chip comparator and is not accessible as a

general purpose I/O pin. The Port 3 output buffers can sink 20 MA. 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 (IIL) because of the pull-

ups.

Port 3 also serves the functions of various special features of theAT89C2051 as listed below:

Port 3 also receives some control signals for Flash programming and verification.

TABLE 1.2.1

Page 7: part 1 (Autosaved).docx

5) RST:

Reset input. All I/O pins are reset to 1s as soon as RST goes high. Holding the RST pin high

for two machine cycles while the oscillator is running resets the device.

Each machine cycle takes 12 oscillator or clock cycles.

6) XTAL1:

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

7) XTAL2:

Output from the inverting oscillator amplifier.

Fig 1.2.2

Page 8: part 1 (Autosaved).docx

AT89C2051 SPECIAL FUNCTION REGISTERS:

A map of the on-chip memory area called the Special Function Register SFR) pace is shown

in the table below.

Note that not all of the addresses are occupied and unoccupied addresses may not be

implemented on the chip. Read accesses to these addresses will in general return random

data, and write accesses will have an indeterminate effect. User software should not write 1s

to these unlisted locations, since they may be used in future products to invoke new features.

In that case, the reset or inactive values of the new bits will always be 0

Table 1.2.2: AT89C2051 SFR Map and Reset Values

Page 9: part 1 (Autosaved).docx

RESTRICTION ON CERTAIN INSTRUCTIONS:

The AT89C2051 and is an economical and cost-effective member of Atmel’s growing family

of microcontrollers .It contains 2K bytes of flash program memory. It is fully compatible

with the MCS-51 architecture, and can be programmed using the MCS-51 instruction set.

However there are a few considerations one must keep in mind when utilizing certain

instructions to program this device.

All the instructions related to jumping or branching should be restricted such that the

destination address falls within the physical program memory space of the device, which

is2K for the AT89C2051. This should be her responsibility of the software programmer. For

example, LJMP 7E0Hwould be a valid instruction for the AT89C2051 (with 2K of memory)

whereas JMP 900H would not.

Page 10: part 1 (Autosaved).docx

BRANCHING INSTRUCTION:

LCALL, LJMP, ACALL, AJMP, SJMP, JMP @A+DPTR

These unconditional branching instructions will execute correctly as long as the programmer

keeps in mind that the destination branching address must fall within the physical boundaries

of the program memory size (locations 00H to7FFH for the 89C2051). Violating the physical

space limits May cause unknown program behavior.

CJNE [...], DJNZ [...], JB, JNB, JC, JNC, JBC, JZ, JNZ

These conditional branching instructions the same rule above applies. Again, violating the

memory boundaries may cause erratic execution .For applications involving interrupts the

normal interrupt service routine address locations of the 80C51 family architecture have been

preserved.

Page 11: part 1 (Autosaved).docx

PROGRAMMING ALGORITHM

1) Power-up sequence:

Apply power between VCC and GND pins Set RST and XTAL1 to GND

2) Set pin RST to “H”

Set pin P3.2 to “H”

3) Apply the appropriate combination of “H” or “L” logic levels to pins P3.3, P3.4, P3.5,

P3.7 to select one of the programming operations shown in the PEROM Programming

Modes table.

To Program and Verify the Array:

4) Apply data for Code byte at location 000H to P1.0 to

P1.7.

5) Raise RST to 12V to enable programming.

6) Pulse P3.2 once to program a byte in the PEROM array or the lock bits. The byte-write

cycle is self-timed and typically takes 1.2 ms.

7) To verify the programmed data, lower RST from 12V to logic “H” level and set pins P3.3

to P3.7 to the appropriate levels. Output data can be read at the port P1 pins.

8) To program a byte at the next address location, pulseXTAL1 pin once to advance the

internal address

9) Repeat steps 5 through 8, changing data and advancing the counter. Apply new data to the

port P1 pins. Address counter for the entire 2K bytes array or until the end of the object file

is reached.

10) Power-off sequence:

Set XTAL1 to “L”

Set RST to “L”

Turn VCC power off

Page 12: part 1 (Autosaved).docx

Data Polling: The AT89C2051 features Data Polling to indicate the end of a write cycle.

During a write cycle, an attempted read of the last byte written will result in the complement

of the written data on P1.7. Once the write cycle has been completed, true data is valid on all

outputs, and the next cycle may begin. Data Polling may begin any time after a write cycle

has been initiated.

Ready/Busy: The Progress of byte programming can also be monitored by the RDY/BSY

output signal. Pin P3.1 is pulled low after P3.2 goes High during programming to indicate

BUSY. P3.1 is pulled High again when programming is done to indicate READY.

Program Verify: If lock bits LB1 and LB2 have not been programmed code data can be

read back via the data lines for verification:

1. Reset the internal address counter to 000H by bringing RST from “L” to “H”.

2. Apply the appropriate control signals for Read Code data and read the output data at the

port P1 pins.

3. Pulse pin XTAL1 once to advance the internal address counter.

4. Read the next code data byte at the port P1 pins.

5. Repeat steps 3 and 4 until the entire array is read .The lock bits cannot be verified directly.

Verification of the lock bits is achieved by observing that their features are enabled.

Chip Erase: The entire PEROM array (2K bytes) and the two Lock Bits are erased

electrically by using the proper combination of control signals and by holding P3.2 low for

10 ms. The code array is written with all “1”s in the Chip.

Erase operation and must be executed before any nonblank memory byte can be re-

programmed.

Reading the Signature Bytes: The signature bytes are read by the same procedure as a

normal verification of locations 000H, 001H, and 002H, except that P3.5 and P3.7 must be

pulled to logic low. The values returned are as follows.

(000H) = 1EH indicates manufactured by Atmel

(001H) = 21H indicates 89C2051.

Page 13: part 1 (Autosaved).docx

Programming Interface:

Every code byte in the Flash array can be written and using the appropriate combination of

control signals can erase the entire array. The write operation cycle is self timed and once

initiated, will automatically time itself to completion.

All major programming vendors offer worldwide support for the Atmel micro controller

series. Please contact your local programming vendor for the appropriate software revision.

Flash Programming Modes

TABLE 1.2.3

Notes: 1. The internal PEROM address counter is reset to 000H on the rising edge of RST

and is advanced by a positive pulse at XTAL 1 pin.

2. Chip Erase requires a 10 ms PROG pulse.

3. P3.1 is pulled Low during programming to indicate RDY/BS.

Page 14: part 1 (Autosaved).docx

Fig 1.2.3 Programming the Flash Memory Fig 1.2.4Verifying the Flash Memory

Flash Programming and Verification Characteristics:

Table 1.2.4

Page 15: part 1 (Autosaved).docx

Baud Rate Generator:

Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON

Note that the baud rates for transmit and receive can be different if Timer 2 is used for the

receiver or transmitter and Timer 1 is used for the other function. Setting RCLK and/or

TCLK puts Timer 2 into its baud rate generator mode, as shown in Figure4. The baud rate

generator mode is similar to the auto-reload mode, in that a rollover in TH2 causes the Timer

2 registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are

preset by software.

The baud rates in Modes 1 and 3 are determined by Timer2’s overflow rate according to the

following equation.

The Timer can be configured for either timer or counter operation. In most applications, it is

configured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2

when it is used as a baud rate generator. Normally as a timer, it increments every machine

cycle (at 1/12 the oscillator frequency). The baud rate formula is given below.

Where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit

unsigned integer. Timer 2 as a baud rate generator is shown in Figure 4. This figure is valid

only if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and will

not generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX will set

EXF2 but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus when

Timer 2 is in use as a baud rate generator, T2EX can be used as an extra external interrupt.

Note that when Timer 2 is running (TR2 = 1) as a timer in the baud rate generator mode,

TH2 or TL2 should not be read from or written to. Under these conditions, the Timer is

incremented every state time, and the results of a read or write may not be accurate.

Page 16: part 1 (Autosaved).docx

2) POWER SUPPLY SECTION:

RMLT CONNECTOR: It is a connector used to connect the step down transformer to the

bridge rectifier.

BRIDGE WAVE RECTIFIER: It is used to give pure DC supply.

REGULATOR LM7805: It is used to give regulated power supply.

Page 17: part 1 (Autosaved).docx

3) RESISTORS:

Resistors are used to limit the value of current in a circuit. Resistors offer opposition to the

flow of current. They are expressed in ohms for which the symbol is ‘’. Resistors are

broadly classified as

(1) Fixed Resistors

(2) Variable Resistors

Fixed Resistors: The most common of low wattage, fixed type resistors is the molded-carbon

composition resistor. The resistive material is of carbon clay composition. The leads are

made of tinned copper. Resistors of this type are readily available in value ranging from few

ohms to about 20M, having a tolerance range of 5 to 20%. They are quite inexpensive.The

relative size of all fixed resistors changes with the power rating.

Another variety of carbon composition resistors is the metalized type. It is made by

deposition a homogeneous film of pure carbon over a glass, ceramic or other insulating core.

This type of film-resistor is sometimes called the precision type, since it can be obtained with

an accuracy of 1%.

Lead Tinned Copper Material

Variable resistor: In electronic circuits, sometimes it becomes necessary to adjust the values

of currents and voltages. For example it is often desired to change the volume of sound,the

brightness of a television picture etc. Such adjustments can be done by using variable

resistors.

Coding of Resistor:

Some resistors are large enough in size to have their resistance printed on the body. However

there are some resistors that are too small in size to have numbers printed on them.

Therefore, a system of colour coding is used to indicate their values. For fixed, moulded

composition resistor four colour bands are printed on one end of the outer casing. The colour

bands are always read left to right from the end that has the bands closest to it. The first and

Page 18: part 1 (Autosaved).docx

second band represents the first and second significant digits, of the resistance value. The

third band is for the number of zeros that follow the second digit. In case the third band is

gold or silver, it represents a multiplying factor of 0.1to 0.01. The fourth band represents the

manufacture’s tolerance.

Fig 1.2.5 resistor chart

Most resistors have 4 bands:

The first band gives the first digit.

The second band gives the second digit.

The third band indicates the number of zeroes.

The fourth band is used to show the tolerance (precision) of the resistor

For example, if a resistor has a colour band sequence: yellow, violet, orange and gold

Then its range will be

Yellow=4 violet=7 orange=10 gold=±5%

=47KΏ ±5%

9 white

8 silver

7 purple

6 blue

4 yellow

3 orange

2 red

1 brown

0 black

5 green

9 white

8 silver

7 purple

6 blue

4 yellow

3 orange

2 red

1 brown

0 black

5 green

9 white

8 silver

7 purple

6 blue

4 yellow

3 orange

2 red

1 brown

0 black

5 green

9 white

8 silver

7 purple

6 blue

4 yellow

3 orange

2 red

1 brown

0 black

5 green

Page 19: part 1 (Autosaved).docx

4) CRYSTAL OSCILLATOR:

It is often required to produce a signal whose frequency or pulse rate is very stable and

exactly known. This is important in any application where anything to do with time or exact

measurement is crucial. It is relatively simple to make an oscillator that produces some sort

of a signal, but another matter to produce one of relatively precise frequency and stability.

FM radio stations must have a carrier frequency accurate within 10Hz of its assigned

frequency, which may be from 530 to 1710 kHz. SSB radio systems used in the HF range (2-

30 MHz) must be within 50 Hz of channel frequency for acceptable voice quality, and within

10 Hz for best results. Some digital modes used in weak signal communication may require

frequency stability of less than 1 Hz within a period of several minutes. The carrier

frequency must be known to fractions of a hertz in some cases. An ordinary quartz watch

must have an oscillator accurate to better than a few parts per million. One part per million

will result in an error of slightly less than one half second a day, which would be about 3

minutes a year. This might not sound like much, but an error of 10 parts per million would

result in an error of about a half an hour per year. A clock such as this would need resetting

about once a month, and more often if you are the punctual type. A programmed VCR with a

clock this far off could miss the recording of part of a TV show. Narrow band SSB

communications at VHF and UHF frequencies still need 50 Hz frequency accuracy. At 440

MHz, this is slightly more than 0.1 part per million.

Fig 1.2.6 Crystal Oscillator

Page 20: part 1 (Autosaved).docx

5) CAPACITORS

A capacitor or condenser is a passive electronic component consisting of a pair of

conductors separated by a dielectric (insulator). When a potential difference (voltage) exists

across the conductors, an electric field is present in the dielectric. This field stores energy

and produces a mechanical force between the conductors. The effect is greatest when there is

a narrow separation between large areas of conductor, hence capacitor conductors are often

called plates.

An ideal capacitor is characterized by a single constant value, capacitance, which is

measured in farads. This is the ratio of the electric charge on each conductor to the potential

difference between them. In practice, the dielectric between the plates passes a small amount

of leakage current. The conductors and leads introduce an equivalent series resistance and the

dielectric has an electric field strength limit resulting in a breakdown voltage.

Capacitors are widely used in electronic circuits to block the flow of direct current while

allowing alternating current to pass, to filter out interference, to smooth the output of power

supplies, and for many other purposes. They are used in resonant circuits in radio frequency

equipment to select particular frequencies from a signal with many frequencies.

Fig 1.2.6

Page 21: part 1 (Autosaved).docx

Charge separation in a parallel-plate capacitor causes an internal electric field. A dielectric

(orange) reduces the field and increases the capacitance.

Fig 1.2.7 A simple demonstration of a parallel-plate capacitor

A capacitor consists of two conductors separated by a non-conductive region. The non-

conductive substance is called the dielectric medium, although this may also mean a vacuum

or a semiconductor depletion region chemically identical to the conductors. A capacitor is

assumed to be self-contained and isolated, with no net electric charge and no influence from

an external electric field. The conductors thus contain equal and opposite charges on their

facing surfaces, and the dielectric contains an electric field. The capacitor is a reasonably

general model for electric fields within electric circuits.

An ideal capacitor is wholly characterized by a constant capacitance C, defined as the ratio of

charge ±Q on each conductor to the voltage V between them

Page 22: part 1 (Autosaved).docx

Fig 1.2.8

Sometimes charge buildup affects the mechanics of the capacitor, causing the capacitance to

vary. In this case, capacitance is defined in terms of incremental changes:

In SI units, a capacitance of one farad means that one coulomb of charge on each conductor

causes a voltage of one volt across the device.

Energy storage

Work must be done by an external influence to move charge between the conductors in a

capacitor. When the external influence is removed, the charge separation persists and energy

is stored in the electric field. If charge is later allowed to return to its equilibrium position,

the energy is released. The work done in establishing the electric field, and hence the amount

of energy stored, is given by:

Page 23: part 1 (Autosaved).docx

6) GAS SENSOR:

The gas sensor module (MQ-5) is used for gas leakage detection in homes, industry and

vehicles. It detects gas as it has a fast response time once it gets pre heated measurements are

almost instantaneous. Note that its sensitivity is adjusted by potentiometer. It works at 5V.It

is compatible with all the ports.

Features:

High sensitivity to LPG, natural gas, town gas Low sensitivity to alcohol and smoke Fast response Stable and long life

Application:

They are used in gas leakage detecting equipment in family and industry, are suitable for

detecting of

LPG, natural gas, town gas, avoid the noise of alcohol and cooking fumes and cigarette

smoke.

Page 24: part 1 (Autosaved).docx

Specifications:

Structure and configuration, basic measuring circuit

Fig

sensor composed by micro AL2O3 ceramic tube, T in Dioxide (SnO2) sensitive layer ,

measuring electrode and heater are fixed into a crust made by plastic and stainless

steel net. The heater provides necessary work conditions for work of sensitive components.

Page 25: part 1 (Autosaved).docx

The enveloped MQ-5 have 6 pin ,4 of them are used to fetch signals, and other 2

are used

for providing heating curren

Page 26: part 1 (Autosaved).docx

7) MOTOR:

Motor is a device that creates motion, not an engine; it usually refers to either an electrical

motor or an internal combustion engine. It may also refer to:

Electric motor, a machine that converts electricity into a mechanical motion

1) AC motor, an electric motor that is driven by alternating current.

Synchronous motor, an alternating current motor distinguished by a rotor

spinning with coils passing magnets at the same rate as the alternating

current and resulting magnetic field which drives it.

Induction motor, also called a squirrel-cage motor, a type of

asynchronous alternating current motor where power is supplied to the

rotating device by means of electromagnetic induction.

2) DC motor, an electric motor that runs on direct current electricity.

Brushed DC electric motor, an internally commutated electric motor

designed to be run from a direct current power source.

Brushless DC motor, a synchronous electric motor which is powered by

direct current electricity and has an electronically controlled commutation

system, instead of a mechanical commutation system based on brushes.

Page 27: part 1 (Autosaved).docx

Fig 1.2.9 schematic of a DC motor

Fig 1.2.10 DC motor

Page 28: part 1 (Autosaved).docx

8) BUZZER:

It is an electronic signaling device which produces buzzing sound. It is commonly used in

automobiles, phone alarm systems and household appliances. Buzzers work in the same

manner as an alarm works. They are generally equipped with sensors or switches connected

to a control unit and the control unit illuminates a light on the appropriate button or control

panel, and sound a warning in the form of a continuous or intermittent buzzing or beeping

sound.

The word "buzzer" comes from the rasping noise that buzzers made when they were

electromechanical devices, operated from stepped-down AC line voltage at 50 or 60 cycles.

Typical uses of buzzers and beepers include alarms, timers and confirmation of user input

such as a mouse click or keystroke.

Fig. Buzzer Fig Electronic symbol for a buzzer

Page 29: part 1 (Autosaved).docx

Types of Buzzers

The different types of buzzers are electric buzzers, electronic buzzers, mechanical buzzers,

electromechanical, magnetic buzzers, piezoelectric buzzers and piezo buzzers.

(i) Electric buzzers –

A basic model of electric buzzer usually consists of simple circuit components such as

resistors, a capacitor and 555 timer IC or an integrated circuit with a range of timer and

multi-vibrator functions. It works through small bits of electricity vibrating together which

causes sound.

(ii) Electronic buzzers

An electronic buzzer comprises an acoustic vibrator comprised of a circular metal plate

having its entire periphery rigidly secured to a support, and a piezoelectric element adhered

to one face of the metal plate. A driving circuit applies electric driving signals to the vibrator

to vibrationally drive it at a 1/N multiple of its natural frequency, where N is an integer, so

that the vibrator emits an audible buzzing sound. The metal plate is preferably mounted to

undergo vibration in a natural vibration mode having only one nodal circle. The drive circuit

includes an inductor connected in a closed loop with the vibrator, which functions as a

capacitor, and the circuit applies signals at a selectively variable frequency to the closed loop

to accordingly vary the inductance of the inductor to thereby vary the period of oscillation of

the acoustic vibrator and the resultant frequency of the buzzing sound.

(iii) Mechanical Buzzer

A joy buzzer is an example of a purely mechanical buzzer.

(iv) Piezo Buzzers/ Piezoelectric Buzzers

A piezo buzzer is made from two conductors that are separated by Piezo crystals.  When a

voltage is applied to these crystals, they push on one conductor and pull on the other. The

result of this push and pull is a sound wave.

Page 30: part 1 (Autosaved).docx

9) DIODES:

A PN junctions is known as a semiconductor or crystal diode.A crystal diode has two

terminal when it is connected in a circuit one thing is decide is weather a diode is forward or

reversed biased. There is a easy rule to ascertain it. If the external CKT is trying to push the

conventional current in the direction of error, the diode is forward biased. One the other hand

if the conventional current is trying is trying to flow opposite the error head, the diode is

reversed biased putting in simple words.

Fig 1.2.11

1. If arrowhead of diode symbol is positive W.R.T Bar of the symbol, the diode is

forward biased.

2. The arrowhead of diode symbol is negative W.R.T bar ,the diode is the reverse bias.

Page 31: part 1 (Autosaved).docx

processor

Fig 1.3.1 BLOCK DIAGRAM

POWER SUPPLY

BUZZER

MOTOR

GAS

SENSOR