multi power generation from traction system with energy conservation

75
MULTI POWER GENERATION FROM TRACTION SYSTEM WITH ENERGY CONSERVATION A PROJECT REPORT Submitted by M.PRIYA 210211105026 M.RAJESWARI 210211105029 K.VENNINSULA 210211105040 in partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING in ELECTRICAL AND ELECTRONICS ENGINEERING APOLLO ENGINEERING COLLEGE, KANCHEEPURAM

Upload: srivaas131985

Post on 14-Jul-2016

7 views

Category:

Documents


3 download

DESCRIPTION

ME JOURNAL

TRANSCRIPT

Page 1: Multi Power Generation From Traction System With Energy Conservation

MULTI POWER GENERATION FROM TRACTION

SYSTEM WITH ENERGY CONSERVATIONA PROJECT REPORT

Submitted by

M.PRIYA 210211105026

M.RAJESWARI 210211105029

K.VENNINSULA 210211105040

in partial fulfillment for the award of the degree

of

BACHELOR OF ENGINEERING

in

ELECTRICAL AND ELECTRONICS ENGINEERING

APOLLO ENGINEERING COLLEGE, KANCHEEPURAM

ANNA UNIVERSITY:: CHENNAI 600 025

APRIL 2015

Page 2: Multi Power Generation From Traction System With Energy Conservation

ANNA UNIVERSITY: CHENNAI 600 025

BONAFIDE CERTIFICATE

Certified that this project report MULTI POWER GENERATION FROM

TRACTION SYSTEM WITH ENERGY CONSERVATION is the bonafide

work of M.PRIYA (210211105026), M.RAJESWARI (210211105029),

K.VENNINSULA (210211105040) who carried out the project work under my

supervision.

SIGNATURE SIGNATURE

MR.D.RAMASUBRAMANIAN M.E MRS.M.INDIRAPRIYADARSHINI M.E HEAD OF THE DEPARTMENT SUPERVISOR

Department of Electrical and Electronics Engineering, Department of Electrical and Electronics Engineering, Apollo Engineering College, Apollo Engineering College,Mevaloorkuppam, Mevaloorkuppam,Chennai-105 Chennai-105

Submitted for the university project viva-voce Examination held on…………….

INTERNAL EXAMINER EXTERNAL EXAMINER

Page 3: Multi Power Generation From Traction System With Energy Conservation

ACKNOWLEDGEMENT

We express our gratitude to our parents who have been the major

contributors of inspiration and encouragements to us throughout our career. We

sincerely thank our Honorable Chairman, Vice Chairman and Management

for extending invaluable facilities and infrastructure, which helped us to

complete the project on time.

It is our pleasure to express our gratitude to our Principal

Mr. Prof. Dr. A. BASKAR M.E, MBA, Ph.D. and also thank our Vice

Principal Mr. Prof. K.VELUCHAMY MSC, MPhil of Apollo Engineering

College for their sustained interest and encouragement offered throughout the

duration of this project.

We express our thanks to Mr. D.RAMASUBRAMANIAN M.E our

internal project coordinator Mrs. J.HEMAMALINI M.E and project guide

MISS. M.INDIRA PRIYADARSHINI M.E of Apollo Engineering College

for guiding us in all the aspects of our project.

We would also like to thank all our staff and student friends of Apollo

Engineering College for providing the impetus to work and suggest

improvement in all the modules of our project.

Page 4: Multi Power Generation From Traction System With Energy Conservation

ABSTRACT

Our project is “Multi Power Generation Methods from Railway

Traction System with Energy Conservation”. The main aim of our project is

to generate power using different sources from train. The different sources are

solar energy, wind energy, energy from train vibration and energy from train

wheels rotation. A solar panel is fixed at the train to get the solar energy. A

wind model is fixed at the train to obtain the wind energy. While the train

moves, high level energy will be obtained from the wind model. Like the wind

model, a generator will be coupled with the train wheels to get power while in

rotation. While the train is in motion high level vibration will be occurred.

Using this vibration the energy can be taken out using piezo electric

transducers. All these obtained energy will be stored in a battery with an

inverter and can be used for appliances in the train.

Another application is implemented in this project describing about

energy conservation system. In most of the trains all the appliances will be in

ON status even absence of the passengers. This ends will waste of power. To

overcome this situation human sensor is used to monitor the motion of the

passengers inside each and every compartment. When the passengers entered

into the compartment the appliances will be switched ON and will be switched

OFF once they leaves out.

Page 5: Multi Power Generation From Traction System With Energy Conservation

TABLE OF CONTENTS

CHAPTER

NO.

TITLE PAGE

ABSTRACT i

LIST OF TABLE ii

LIST OF FIGURES iii

1. INTRODUCTION 1

1.1 General Introduction

1.2 Existing system

1.3 Proposed system

1

2

2

2. LITERATURE REVIEW 3

2.1 Faruk Yildiz, 2009, “Potential Ambient Energy-

Harvesting Sources and Techniques”

2.2 Loreto Mateu and Francesc Moll, 2007 "Review

of Energy Harvesting Techniques and Applications

for Microelectronics"

2.3 R.J.M. Vullers, R. van Schaijk, I. Doms, C. Van

Hoof, R.Mertens, 2009, “Micropower energy

harvesting”

2.4 Wei Qi, Jinfeng Liu, Xianzhong Chen, and

Panagiotis D. Christofides,2011,“Supervisory

Predictive Control of Standalone Wind/Solar

Energy Generation Systems”

3

3

4

4

3. OVERVIEW OF THE PROJECT 5

Page 6: Multi Power Generation From Traction System With Energy Conservation

3.1 Block diagram of the project

3.2 Circuit diagram of the project

3.3 Description of the blocks

3.3.1 Vibration energy

3.3.1.1 Piezoelectric materials

3.3.1.2 Piezo electric based vibration energy

3.3.2 Wheel rotation

3.3.2.1 Operation principle

3.3.2.2 Speed reduction

3.3.2.3 Torque multiplication

3.3.2.4 Motor varieties

3.3.2.5 Application

3.3.3 Wind energy

3.3.3.1 Introduction

3.3.3.2 Wind energy

3.3.3.3 Advantages

3.3.3.4 Disadvantages

3.3.3.5 Technology

3.3.4 Solar energy

3.3.4.1 Solar panel

3.3.4.2 Special features

3.3.5 Microcontroller unit (AT89S52)

3.3.5.1 Introduction

3.3.5.2 Features

3.3.5.3 Description

3.3.5.4 Block diagram

3.3.5.5 Pin diagram

3.3.5.6 Circuit diagram

5

6

7

7

7

7

8

8

9

9

10

10

10

10

11

12

13

13

15

15

16

17

17

18

18

20

21

22

Page 7: Multi Power Generation From Traction System With Energy Conservation

3.3.5.7 Pin description

3.3.5.8 Application

3.3.6 Regulated power supply

3.3.6.1 Circuit diagram

3.3.6.2 Power supply unit

3.3.6.3 Step down transformer

3.3.6.4 Rectifier unit

3.3.6.5 Input filter

3.3.6.6 Regulator unit

3.3.6.7 Output filter

3.3.6.8 Application

3.3.7 Human motion sensor

3.3.7.1 PIR sensor

3.3.7.2 General description

3.3.7.3 Operation

3.3.7.4 Pin description

3.3.7.5 Sensitivity

3.3.7.6 Features

3.3.8 Relay

3.3.8.1 Introduction

3.3.8.2 Kinds of relay

3.3.9 Inverter

3.3.10 Battery

22

28

29

29

29

29

30

30

30

31

31

32

32

32

32

33

33

34

34

34

35

36

38

4. CONCLUSION 39

4.1 Future scope

4.2 Reference

4.3 Output

39

40

41

5. APPENDICES 43

Page 8: Multi Power Generation From Traction System With Energy Conservation

LIST OF TABLE

TABLE NO. TITLE PAGE NO.

1. Functions of port 1 OF AT89S52 23

2. Functions of port 3 OF AT89S52 24

3. Pin Description of PIR Sensor 33

Page 9: Multi Power Generation From Traction System With Energy Conservation

LIST OF FIGURES

FIGURE NO.

TITLE PAGE NO.

1. Train 2

2. Block diagram of the project 5

3. Circuit diagram 6

4. Piezoelectric based vibration energy 7

5. Train wheel 8

6. Wheel rotation energy 9

7. Wind turbine 11

8. Wind turbine model 12

9. Solar panel 16

10. Solar panel fixed on train 17

11. Atmel AT89S52 chip 19

12. Block diagram of AT89S52 20

13. Pin diagram of AT89S52 21

14. Circuit diagram OF AT89S52 22

15. Power supply Circuit diagram 29

16. 7805 Regulator 30

17. Opreation of PIR sensor 33

18. Human motion sensor (PIR sensor) 34

19. Relay 35

20. Single relay circuit diagram 35

21. Inverter 36

22. Inverter Block diagram 37

23. Storage battery 38

Page 10: Multi Power Generation From Traction System With Energy Conservation

CHAPTER 1: INTRODUCTION

1.1 GENERAL INTRODUCTION

The Embedded Technology is now in its prime and the wealth of

knowledge available is mind-blowing. Embedded technology plays a major role

in integrating the various functions associated with it. This needs to tie up the

various sources of the Department in a closed loop system. This proposal

greatly reduces the manpower, saves time and operates efficiently without

human interference. This project puts forth the first step in achieving the desired

target. With the advent in technology, the existing systems are developed to

have in built intelligence.

Ours being a developing country the power consumption is increasing on

large scale to meet the growing demands. Power generation is widely based on

the non-renewable sources, and these sources being depleting some means have

to be found for power saving.

The first trains were rope-hauled, gravity powered or pulled by horses.

From the early 19th century almost all were powered by steam locomotives.

From the 1910s onwards the steam locomotives began to be replaced by less

labor-intensive and cleaner (but more complex and expensive) diesel

locomotive and electric locomotives, while at about the same time self-

propelled multiple unit vehicles of either power system became much more

common in passenger service.

Page 11: Multi Power Generation From Traction System With Energy Conservation

1.2 EXISTING SYSTEM

Since various types of renewable energy sources were available in older

days, particularly solar energy generation system only implemented in the

trains. The solar panels were fixed at the top of the train to obtain the solar

energy.

Even though a large amount of energy is from the solar panels, it is not

sufficient for the total usage in the train.

FIGURE 1 : Train

1.3 PROPOSED SYSTEM

In the proposed system, following types of renewable sources are used. They

are solar, wind, energy from wheel rotation and energy from train vibration.

Since four energy sources are used, a large amount of energy can be obtained

while combining everything. This can be stored in a battery. This stored

energy is converted from DC to AC using an inverter and supplied to all the

appliances in the trains.

The appliances will be switched ON throughout the day in the trains even the

absence of the people. Due to this large amount of energy is wasted.

To avoid this, human motion sensor is fixed in each and every coach. This

activates the appliances in ON status only if the passengers inside the train.

Else the appliances will be switched OFF automatically.

Page 12: Multi Power Generation From Traction System With Energy Conservation

CHAPTER-2 LITERATURE REVIEW

2.1 Faruk Yildiz, 2009, “Potential Ambient Energy-Harvesting Sources and

Techniques”

Ambient energy harvesting is also known as energy scavenging or power

harvesting, and it is the process where energy is obtained from the environment.

A variety of techniques are available for energy scavenging, including solar and

wind powers, ocean waves, piezoelectricity, thermoelectricity, and physical

motions. Ambient energy sources are classified as energy reservoirs, power

distribution methods, or power-scavenging methods, which may enable portable

or wireless systems to be completely battery independent and self-Sustaining.

The students from different disciplines, such as industrial technology,

construction, design and development and electronics, investigated the

effectiveness of ambient energy as a source of power.

2.2 Loreto Mateu and Francesc Moll, 2007 "Review of Energy Harvesting

Techniques and Applications for Microelectronics"

The trends in technology allow the decrease in both size and power

consumption of complex digital systems. This decrease in size and power gives

rise to new paradigms of computing and use of electronics, with many small

devices working collaboratively or at least with strong communication

capabilities. Currently, these devices are powered by batteries. However,

batteries present several disadvantages: the need to either replace or recharge

them periodically and their big size and weight compared to high technology

electronics. One possibility to overcome these power limitations is to extract

(harvest) energy from the environment to either recharge a battery, or even to

directly power the electronic device.

Page 13: Multi Power Generation From Traction System With Energy Conservation

2.3 R.J.M. Vullers, R. van Schaijk, I. Doms, C. Van Hoof, R.Mertens,

2009, “Micropower energy harvesting”

More than a decade of research in the field of thermal, motion, vibration and electromagnetic radiation energy harvesting has yielded increasing power output and smaller embodiments. Power management circuits for rectification and DC–DC conversion are becoming able to efficiently convert the power from these energy harvesters. This paper summarizes recent energy harvesting results and their power management circuits

2.4 Wei Qi, Jinfeng Liu, Xianzhong Chen, and Panagiotis D. Christofides, y 2011 “Supervisory Predictive Control of Standalone Wind/Solar Energy Generation Systems”

This work focuses on the development of a supervisory model predictive

control method for the optimal management and operation of hybrid standalone

wind-solar energy generation systems. We design the supervisory control

system via model predictive control which computes the power references for

the wind and solar subsystems at each sampling time while minimizing a

suitable cost function. The power references are sent to two local controllers

which drive the two subsystems to the requested power references. We discuss

how to incorporate practical considerations, for example, how to extend the life

time of the equipment by reducing the peak values of inrush or surge currents,

into the formulation of the model predictive control optimization problem. We

present several simulation case studies that demonstrate the applicability and

effectiveness of the proposed supervisory predictive control architecture.

Page 14: Multi Power Generation From Traction System With Energy Conservation

CHAPTER 3: OVERVIEW OF PROJECT

3.1 BLOCK DIAGRAM OF THE PROJECT

FIGURE 2: Block Diagram Of The Project

Page 15: Multi Power Generation From Traction System With Energy Conservation

3.2 CIRCUIT DIAGRAM

FIGURE 3: Circuit Diagram of the Project

Page 16: Multi Power Generation From Traction System With Energy Conservation

3.3 DESCRIPTION OF THE BLOCKS

3.3.1 VIBRATION ENERGY

3.3.1.1Piezoelectric Materials:

Certain single crystal materials exhibit the following phenomenon: when the

crystal is mechanically strained, or when the crystal is deformed by the

application of an external stress, electric charges appear on certain of the crystal

surfaces; and when the direction of the strain reverses, the polarity of the

electric charge is reversed. This is called the direct piezoelectric effect, and the

crystals that exhibit it are classed as piezoelectric crystals

3.3.1.2Piezo Electric based Vibration Energy

Piezoelectricity is the electric charge that accumulates in certain solid materials

(such as crystals, certain ceramics) in response to applied mechanical stress.

The word piezoelectricity means electricity resulting from pressure. The

piezoelectric effect is understood as the linear electromechanical interaction

between the mechanical and the electrical state in crystalline materials with no

inversion symmetry.

FIGURE 4: Piezo Electric based Vibration Energy

Page 17: Multi Power Generation From Traction System With Energy Conservation

3.3.2 WHEEL ROTATION

Gear motors are complete motive force systems consisting of an electric

motor and a reduction gear train integrated into one easy-to-mount and -

configure package. This greatly reduces the complexity and cost of designing

and constructing power tools, machines and appliances calling for high torque at

relatively low shaft speed or RPM.

Gear motors allow the use of economical low-horsepower motors to

provide great motive force at low speed such as in lifts, winches, medical tables,

jacks and robotics. They can be large enough to lift a building or small enough

to drive a tiny clock.

FIGURE 5: Train Wheel

3.3.2.1 OPERATION PRINCIPLE:Most synchronous AC electric motors have output ranges of from 1,200

to 3,600 revolutions per minute. They also have both normal speed and stall-

speed torque specifications. The reduction gear trains used in gear motors are

designed to reduce the output speed while increasing the torque. The increase in

torque is inversely proportional to the reduction in speed. Reduction gearing

allows small electric motors to move large driven loads, although more slowly

than larger electric motors. Reduction gears consist of a small gear driving a

Page 18: Multi Power Generation From Traction System With Energy Conservation

larger gear. There may be several sets of these reduction gear sets in a reduction

gear box.

FIGURE 6: Wheel Rotation Energy

3.3.2.2 SPEED REDUCTION:Sometimes the goal of using a gear motor is to reduce the rotating shaft

speed of a motor in the device being driven, such as in a small electric clock

where the tiny synchronous motor may be spinning at 1,200 rpm but is reduced

to one rpm to drive the second hand, and further reduced in the clock

mechanism to drive the minute and hour hands. Here the amount of driving

force is irrelevant as long as it is sufficient to overcome the frictional effects of

the clock mechanism.

Page 19: Multi Power Generation From Traction System With Energy Conservation

3.3.2.3 TORQUE MULTIPLICATION:Another goal achievable with a gear motor is to use a small motor to

generate a very large force albeit at a low speed. These applications include the

lifting mechanisms on hospital beds, power recliners, and heavy machine lifts

where the great force at low speed is the goal.

3.3.2.4 MOTOR VARIETIES:Most industrial gear motors are AC-powered, fixed-speed devices,

although there are fixed-gear-ratio, variable-speed motors that provide a greater

degree of control. DC gear motors are used primarily in automotive applications

such as power winches on trucks, windshield wiper motors and power seat or

power window motors.

3.3.2.5 APPLICATIONS:What power can openers, garage door openers, stair lifts, rotisserie

motors, timer cycle knobs on washing machines, power drills, cake mixers and

electromechanical clocks have in common is that they all use various

integrations of gear motors to derive a large force from a relatively small

electric motor at a manageable speed. In industry, gear motor applications in

jacks, cranes, lifts, clamping, robotics, conveyance and mixing are too

numerous to count.

3.3.3 WIND ENERGY

3.3.3.1 INTRODUCTIONWinds are caused by the uneven heating of the atmosphere by the sun, the

irregularities of the earth's surface, and rotation of the earth. The earth’s surface

is made of different types of land and water. These surfaces absorb the sun’s

heat at different rates, giving rise to the differences in temperature and

subsequently to winds. During the day, the air above the land heats up more

quickly than the air over water. The warm air over the land expands and rises,

and the heavier, cooler air rushes in to take its place, creating winds. At night,

the winds are reversed because the air cools more rapidly over land than over

Page 20: Multi Power Generation From Traction System With Energy Conservation

water. In the same way, the large atmospheric winds that circle the earth are

created because the land near the earth's equator is heated more by the sun than

the land near the North and South Poles. Humans use this wind flow for many

purposes: sailing boats, pumping water, grinding mills and also generating

electricity. Wind turbines convert the kinetic energy of the moving wind into

electricity.

FIGURE 7: Wind Turbine 

3.3.3.2 WIND ENERGY Wind Energy, like solar is a free energy resource. But is much

intermittent than solar. Wind speeds may vary within minutes and affect the

power generation and in cases of high speeds- may result in overloading of

generator. Energy from the wind can be tapped using turbines.

Setting up of these turbines needs little research before being established. Be it a

small wind turbine on a house, a commercial wind farm or any offshore

installation, all of them, at first, need the Wind Resource to be determined in the

area of proposed site. The Wind Resource data is an estimation of average and

peak wind speeds at a location based on various meteorological. The next step is

Page 21: Multi Power Generation From Traction System With Energy Conservation

to determine access to the transmission lines or nearest control centre where the

power generated from the turbines can be conditioned, refined, stored or

transmitted. It is also necessary to survey the impact of putting up wind turbines

on the community and wildlife in the locality. If sufficient wind resources are

found, the developer will secure land leases from property owners, obtain the

necessary permits and financing; purchase and install wind turbines. The

completed facility is often sold to an independent operator called an

independent power producer (IPP) who generates electricity to sell to the local

utility, although some utilities own and operate wind farms directly. Wind mills

can be set up ranging scales of:

 On-shore grid connected Wind Turbine systems

Off-shore Wind turbine systems

Small Wind and Hybrid Energy Decentralized systems

FIGURE 8: Wind Turbine Model

Page 22: Multi Power Generation From Traction System With Energy Conservation

3.3.3.3 ADVANTAGES  Can be used for both distributed generation or grid interactive power

generation using on-shore or off shore technologies.

Ranges of power producing turbines are available. Micro-turbines are

capable of producing 300W to 1MW and large wind turbines have typical

size of 35kW-3MW.

Wind turbine is suitable to install in remote rural area, water pumping and

grinding mills

Average capacity factor can be close or higher than 30%

3.3.3.4 DISADVANTAGE  The total cost can be cheaper than solar system but more expensive than

hydro.

Electricity production depends on- wind speed, location, season and air

temperature. Hence various monitoring systems are needed and may cost

expensive.

High percentage of the hardware cost (for large WT) is mostly spent on

the tower designed to support the turbine

3.3.3.5 TECHNOLOGYThe range of wind speeds that are usable by a particular wind turbine for

electricity generation is called productive wind speed. The power available from

wind is proportional to cube of the wind's speed. So as the speed of the wind

falls, the amount of energy that can be got from it falls very rapidly. On the

other hand, as the wind speed rises, so the amount of energy in it rises very

rapidly; very high wind speeds can overload a turbine. Productive wind speeds

will range between 4 m/sec to 35 m/sec. The minimum prescribed speed for

optimal performance of large scale wind farms is about 6 m/s. Wind power

potential is mostly assessed assuming 1% of land availability for wind farms

required @12 ha/MW in sites having wind power density exceeding 200

W/sq.m. at 50 m hub-height.

Page 23: Multi Power Generation From Traction System With Energy Conservation

 The energy in the wind turns two or three propeller-like blades around a rotor.

The rotor is connected to the main shaft, which spins a generator to create

electricity. Wind turbines are mounted on a tower to capture the most energy.

At 100 feet (30 meters) or more above ground, they can take advantage of faster

and less turbulent wind. Wind turbines can be used to produce electricity for a

single home or building, or they can be connected to an electricity grid

(shown here) for more widespread electricity distribution. Furthermore projects

are going on exploring in Research Design and Development to achieve

following goals:

 Continue cost reduction: improved site assessment, better modeling for

aerodynamics, intelligent/recyclable materials, stand-alone and hybrid

systems.

Increase value and reduce uncertainties: forecasting power performance,

improving standards and engineering integrity and storage techniques.

Enable large-scale use: Load flow control and adaptive power quality

Minimize environmental impacts: Noise impacts, Flora and Fauna,

utilization of land resources and aesthetics integration

A wind turbine is a device that converts kinetic energy from the wind

into mechanical energy. If the mechanical energy is used to produce electricity,

the device may be called a wind generator or wind charger. If the mechanical

energy is used to drive machinery, such as for grinding grain or pumping water,

the device is called a windmill or wind pump. Developed for over a millennium,

today's wind turbines are manufactured in a range of vertical and horizontal axis

types. The smallest turbines are used for applications such as battery charging

or auxiliary power on sailing boats; while large grid-connected arrays of

turbines are becoming an increasingly large source of commercial electric

power.

Page 24: Multi Power Generation From Traction System With Energy Conservation

3.3.4 SOLAR ENERGY

3.3.4.1 SOLAR PANEL

A photovoltaic module or photovoltaic panel is a packaged

interconnected assembly of photovoltaic cells, also known as solar cells. The

photovoltaic module, known more commonly as the solar panel, is then used as

a component in a larger photovoltaic system to offer electricity for commercial

and residential applications.

Because a single photovoltaic module can only produce a certain amount

of wattage, installations intended to produce larger electrical power capacity

require an installation of several modules or panels and this is known as a

photovoltaic array. A photovoltaic installation typically includes an array of

photovoltaic modules or panels, an inverter, batteries and interconnection

wiring. Photovoltaic systems are used for either on- or off-grid applications, and

for solar panels on spacecraft.

Solar Panels use light energy (photons) from the sun to generate

electricity through photovoltaic effect (this is the photo-electric effect). The

majority of modules use wafer-based crystalline silicon cells or a thin-film cell

based on cadmium telluride or silicon. Crystalline silicon, which is commonly

used in the wafer form in photovoltaic (PV) modules, is derived from silicon, a

commonly used semi-conductor.

Page 25: Multi Power Generation From Traction System With Energy Conservation

FIGURE 9: Solar Panel

3.3.4.2 SPECIAL FEATURES:

3W solar panel, for 10-15V DC applications

Made of multi-crystalline solar silicone cells

Peak power: 3 Watts (day time with fully sun shine)

Open voltage circuit (Voc): 8V

Maximum power voltage (Vmp): 15V

Maximum power current (Imp): 200mA

Nominal working temperature: 43±2 degrees C

Installation: solar panel face directly to the sun

Weight: less than 1kg

Working life: more than 25 years

Standard testing condition: 25 degrees C, AM1.5 spectrum,

Insulation: ≥ 100MΩ

Wind pressure: 60m/s (200kg/m2)

Page 26: Multi Power Generation From Traction System With Energy Conservation

FIGURE 10 : Solar panel fixed on roof of the train

3.3.5 AT89S52 MICROCONTROLLER UNIT:

3.3.5.1 INTRODUCTION:

A Micro controller consists of a powerful CPU tightly coupled with

memory, various I/O interfaces such as serial port, parallel port timer or

counter, interrupt controller, data acquisition interfaces-Analog to Digital

converter, Digital to Analog converter, integrated on to a single silicon chip. If a

system is developed with a microprocessor, the designer has to go for external

memory such as RAM, ROM, EPROM and peripherals. But controller is

provided all these facilities on a single chip. Development of a Micro controller

reduces PCB size and cost of design. One of the major differences between a

Microprocessor and a Micro controller is that a controller often deals with bits

not bytes as in the real world application. Intel has introduced a family of Micro

controllers called the MCS-52.

AT89S52 is 8-bit micro controller, which has 4 KB on chip flash

memory, which is just sufficient for our application. The on-chip Flash ROM

allows the program memory to be reprogrammed in system or by conventional

non-volatile memory Programmer. Moreover ATMEL is the leader in flash

Page 27: Multi Power Generation From Traction System With Energy Conservation

technology in today’s market place and hence using AT 89C52 is the optimal

solution.

3.3.5.2 FEATURES: Compatible with MCS®-51 Products

8K Bytes of In-System Programmable (ISP) Flash Memory –

Endurance: 1000 Write/Erase Cycles

4.0V to 5.5V Operating Range

Fully Static Operation: 0 Hz to 33 MHz

Three-level Program Memory Lock

256 x 8-bit Internal RAM

32 Programmable I/O Lines

Three 16-bit Timer/Counters

Eight Interrupt Sources

Full Duplex UART Serial Channel

Low-power Idle and Power-down Modes

Interrupt Recovery from Power-down Mode

Watchdog Timer

Dual Data Pointer

Power-off Flag

Fast Programming Time

Flexible ISP Programming (Byte and Page Mode)

Green (Pb/Halide-free) Packaging Option

3.3.5.3 DESCRIPTION:

The AT89S52 is a low-power, high-performance CMOS 8-bit

microcontroller with 8K bytes of in-system programmable Flash memory. The

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

technology and is compatible with the Indus-try-standard 80C51 instruction set

and pin out. The on-chip Flash allows the program memory to be reprogrammed

Page 28: Multi Power Generation From Traction System With Energy Conservation

in-system or by a conventional nonvolatile memory programmer. By combining

a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip,

the Atmel AT89S52 is a powerful microcontroller which provides a highly-

flexible and cost-effective solution to many embedded control applications.

The AT89S52 provides the following standard features: 8K bytes of

Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, 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 AT89S52 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 con-tents but freezes the oscillator, disabling all other chip functions

until the next interrupt or hardware reset.

FIGURE 11: ATMEL AT89S52 Chip

Page 29: Multi Power Generation From Traction System With Energy Conservation

3.3.5.4 BLOCK DIAGRAM

FIGURE 12: Block Diagram of AT89S52

Page 30: Multi Power Generation From Traction System With Energy Conservation

3.3.5.5 PIN DESCRIPTION:

FIGURE 13: Pin Diagram Of AT89S52

Page 31: Multi Power Generation From Traction System With Energy Conservation

3.3.5.6 CIRCUIT DIAGRAM

FIGURE 14: Circuit Diagram ofAT89S52

3.3.5.7 PIN DESCRIPTION:

VCC Supply voltage.

GND Ground.

Port 0

Port 0 is an 8-bit open drain bidirectional I/O port. As an output port,

each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins

can be used as high-impedance inputs. Port 0 can also be configured to be the

multiplexed low-order address/data bus during accesses to external program and

data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the

code bytes during Flash programming and outputs the code bytes during

program verification. External pull-ups are required during program

verification.

Page 32: Multi Power Generation From Traction System With Energy Conservation

Port 1

Port 1 is an 8-bit bidirectional 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 pulled high by the inter-nal pull-ups and can be used as inputs. As

inputs, Port 1 pins that are externally being pulled low will source current (IIL)

because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to

be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2

trigger input (P1.1/T2EX), respectively, as shown in the following table. Port 1

also receives the low-order address bytes during Flash programming and

verification.

TABLE 1: Functions of Port-1 of AT89S52

Port 2

Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2

output buffers can sink/source four TTL inputs. When 1s are written to Port 2

pins, they are pulled high by the internal pull-ups and can be used as inputs. As

inputs, Port 2 pins that are externally being pulled low will source current (IIL)

because of the internal pull-ups. Port 2 emits the high-order address byte during

fetches from external program memory and during accesses to external data

memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port

2 uses strong internal pull-ups when emitting 1s. During accesses to external

data memory that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents

Page 33: Multi Power Generation From Traction System With Energy Conservation

of the P2 Special Function Register. Port 2 also receives the high-order address

bits and some control signals during Flash programming and verification. Port

Pin

Alternate Functions P1.0 T2 (external count input to Timer/Counter 2),

clock-out P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction

control) P1.5 MOSI (used for In-System Programming) P1.6 MISO (used for

In-System Programming) P1.7 SCK (used for In-System Programming)

Port 3

Port 3 is an 8-bit bidirectional 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 (IIL)

because of the pull-ups. Port 3 receives some control signals for Flash

programming and verification. Port 3 also serves the functions of various

special features of the AT89S52, as shown in the following table.

TABLE 2: Functions of Port-3

RST

Reset input. A high on this pin for two machine cycles while the

oscillator is running resets the device. This pin drives high for 98 oscillator

Page 34: Multi Power Generation From Traction System With Energy Conservation

periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address

8EH) can be used to disable this feature. In the default state of bit DISRTO, the

RESET HIGH out feature is enabled.

ALE/PROG

Address Latch Enable (ALE) 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. Note, however, that one ALE pulse is

skipped during each access to external data memory. 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 (PSEN) is the read strobe to external program

memory. When the AT89S52 is executing code from external program memory,

PSEN is activated 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.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock

operating circuit.

Page 35: Multi Power Generation From Traction System With Energy Conservation

XTAL2

Output from the inverting oscillator amplifier.

MEMORY ORGANIZATION

MCS-51 devices have a separate address space for Program and Data

Memory. Up to 64K bytes each of external Program and Data Memory can be

addressed.

PROGRAM MEMORY

If the EA pin is connected to GND, all program fetches are directed to

external memory. On the AT89S52, if EA is connected to VCC, program

fetches to addresses 0000H through 1FFFH are directed to internal memory and

fetches to addresses 2000H through FFFFH are to external memory.

DATA MEMORY

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128

bytes occupy a parallel address space to the Special Function Registers. This

means that 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 which use direct addressing access the SFR space. For

example, the following direct addressing instruction accesses the SFR at

location 0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect

addressing access the upper 128 bytes of RAM. For example, the following

indirect addressing instruction, where R0 contains 0A0H, accesses the data byte

at address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0, #data

Note that stack operations are examples of indirect addressing, so the upper 128

bytes of data RAM are available as stack space.

WATCHDOG TIMER (One-time Enabled with Reset-out)

The WDT is intended as a recovery method in situations where the CPU

may be subjected to software upsets. The WDT consists of a 14-bit counter and

Page 36: Multi Power Generation From Traction System With Energy Conservation

the Watchdog Timer Reset (WDTRST) SFR. The WDT is defaulted to disable

from exiting reset. To enable the WDT, a user must write 01EH and 0E1H in

sequence to the WDTRST register (SFR location 0A6H). When the WDT is

enabled, it will increment every machine cycle while the oscillator is running.

The WDT timeout period is dependent on the external clock frequency. There is

no way to disable the WDT except through reset (either hardware reset or WDT

overflow reset). When WDT over-flows, it will drive an output RESET HIGH

pulse at the RST pin.

USING THE WDT

To enable the WDT, a user must write 01EH and 0E1H in sequence to the

WDTRST register (SFR location 0A6H). When the WDT is enabled, the user

needs to service it by writing 01EH and 0E1H to WDTRST to avoid a WDT

overflow. The 14-bit counter overflows when it reaches 16383 (3FFFH), and

this will reset the device. When the WDT is enabled, it will increment every

machine cycle while the oscillator is running. This means the user must reset the

WDT at least every 16383 machine cycles. To reset the WDT the user must

write 01EH and 0E1H to WDTRST. WDTRST is a write-only register. The

WDT counter cannot be read or written. When WDT overflows, it will generate

an output RESET pulse at the RST pin. The RESET pulse duration is

98xTOSC, where TOSC = 1/FOSC. To make the best use of the WDT, it should

be serviced in those sections of code that will periodically be executed within

the time required to prevent a WDT reset.

WDT DURING POWER DOWN AND IDLE

In Power-down mode the oscillator stops, which means the WDT also

stops. While in Power-down mode, the user does not need to service the WDT.

There are two methods of exiting Power-down mode: by a hardware reset or via

a level-activated external interrupt which is enabled prior to entering Power-

down mode. When Power-down is exited with hardware reset, servicing the

WDT should occur as it normally does whenever the AT89S52 is reset. Exiting

Page 37: Multi Power Generation From Traction System With Energy Conservation

Power-down with an interrupt is significantly different. The interrupt is held

low long enough for the oscillator to stabilize. When the interrupt is brought

high, the interrupt is serviced. To prevent the WDT from resetting the device

while the interrupt pin is held low, the WDT is not started until the interrupt is

pulled high. It is suggested that the WDT be reset during the interrupt service

for the interrupt used to exit Power-down mode. To ensure that the WDT does

not overflow within a few states of exiting Power-down, it is best to reset the

WDT just before entering Power-down mode. Before going into the IDLE

mode, the WDIDLE bit in SFR AUXR is used to determine whether the WDT

continues to count if enabled. The WDT keeps counting during IDLE

(WDIDLE bit = 0) as the default state. To prevent the WDT from resetting the

AT89S52 while in IDLE mode, the user should always set up a timer that will

periodically exit IDLE, service the WDT, and reenter IDLE mode. With

WDIDLE bit enabled, the WDT will stop to count in IDLE mode and resumes

the count upon exit from IDLE

3.3.5.8 APPLICATIONS

The AT89C51 application is an implementation of a moving display. This

application was selected for its simplicity and ability to show graphically the

results of in-circuit re programming. The text to be displayed is programmed

into the controller as part of its firmware, and cannot be changed without

reprogramming the device.0287D-B–9/97.

The Microcontroller can be applicable in the following fields:

1. Instrumentation.

2. Communication Systems.

3. Control Systems.

4. Peripheral Controllers.

5. Process Control Systems.

Page 38: Multi Power Generation From Traction System With Energy Conservation

3.3.6 REGULATED POWER SUPPLY

3.3.6.1 CIRCUIT DIAGRAM:

FIGURE 15: Power Supply Circuit Diagram

3.3.6.2 POWER SUPPLY UNIT:

Consists of following units

Step down transformer

Rectifier unit

Input filter

Regulator unit

Output filter

3.3.6.3 STEP-DOWN TRANSFORMER:

The Step down Transformer is used to step down the main supply voltage

from 230V AC to lower value. This 230 AC voltage cannot be used directly,

thus it is stepped down. The Transformer consists of primary and secondary

coils. To reduce or step down the voltage, the transformer is designed to contain

less number of turns in its secondary core. The output from the secondary coil is

also AC waveform. Thus the conversion from AC to DC is essential. This

conversion is achieved by using the Rectifier Circuit/Unit.

3.3.6.4 RECTIFIER UNIT:

Page 39: Multi Power Generation From Traction System With Energy Conservation

The Rectifier circuit is used to convert the AC voltage into its

corresponding DC voltage. There are Half-Wave, Full-Wave and bridge

Rectifiers available for this specific function. The most important and simple

device used in Rectifier circuit is the diode. The simple function of the diode is

to conduct when forward biased and not to conduct in reverse bias.

The Forward Bias is achieved by connecting the diode’s positive with

positive of the battery and negative with battery’s negative. The efficient circuit

used is the Full wave Bridge rectifier circuit. The output voltage of the rectifier

is in rippled form, the ripples from the obtained DC voltage are removed using

other circuits available. The circuit used for removing the ripples is called Filter

circuit.

3.3.6.5 INPUT FILTER:

Capacitors are used as filter. The ripples from the DC voltage are

removed and pure DC voltage is obtained. And also these capacitors are used to

reduce the harmonics of the input voltage. The primary action performed by

capacitor is charging and discharging.

It charges in positive half cycle of the AC voltage and it will discharge in

negative half cycle. So it allows only AC voltage and does not allow the DC

voltage. This filter is fixed before the regulator. Thus the output is free from

ripples.

3.3.6.6 REGULATOR UNIT:

FIGURE 16: 7805 Regulator

Regulator regulates the output voltage to be always constant. The output

voltage is maintained irrespective of the fluctuations in the input AC voltage.

As and then the AC voltage changes, the DC voltage also changes. Thus to

Page 40: Multi Power Generation From Traction System With Energy Conservation

avoid this Regulators are used. Also when the internal resistance of the power

supply is greater than 30 ohms, the output gets affected. Thus this can be

successfully reduced here.

The regulators are mainly classified for low voltage and for high voltage.

Further they can also be classified as:

i) Positive regulator

1---> input pin

2---> ground pin

3---> output pin

It regulates the positive voltage.

ii) Negative regulator

1---> ground pin

2---> input pin

3---> output pin

It regulates the negative voltage.

3.3.6.7 OUTPUT FILTER:

The Filter circuit is often fixed after the Regulator circuit.

Capacitor is most often used as filter. The principle of the capacitor is to charge

and discharge. It charges during the positive half cycle of the AC voltage and

discharges during the negative half cycle. So it allows only AC voltage and does

not allow the DC voltage. This filter is fixed after the Regulator circuit to filter

any of the possibly found ripples in the output received finally. Here we used

0.1µF capacitor. The output at this stage is 5V and is given to the

Microcontroller.

3.3.6.8 APPLICATIONS

Can be used in

Railway Traction System

Buses ,Lorries and various types of vehicle

Page 41: Multi Power Generation From Traction System With Energy Conservation

Homes and Industries.

3.3.7 HUMAN MOTION SENSOR

3.3.7.1 PIR SENSOR

A Passive Infrared sensor (PIR sensor) is an electronic device that measures

infrared (IR) light radiating from objects in its field of view. PIR sensors are

often used in the construction of PIR-based motion detectors (see below).

Apparent motion is detected when an infrared source with one temperature,

such as a human, passes in front of an infrared source with another temperature,

such as a wall.

All objects emit what is known as black body radiation. It is usually

infrared radiation that is invisible to the human eye but can be detected by

electronic devices designed for such a purpose. The term passive in this instance

means that the PIR device does not emit an infrared beam but merely passively

accepts incoming infrared radiation.

3.3.7.2 GENERAL DESCRIPTION:

In our project we use the model GH-718 sensor. The PIR sensor is a

pyroelectric device that detects motion by measuring changes in the infrared

levels emitted by surrounding objects. This motion can be detected by checking

for a high signal on a single i/o pin.

3.3.7.3 OPERATION:

Pyroelectric devices, such as the PIR sensor, have elements made of a

crystalline material that generates an electric charge when exposed to infrared

radiation. The changes in the amount of infrared striking the element change the

voltages generated, which are measured by an on-board amplifier. The device

contains a special filter called a fresnel lens, which focuses the infrared signals

Page 42: Multi Power Generation From Traction System With Energy Conservation

onto the elements. As the ambient infrared signals change rapidly, the on-board

amplifier trips the output to indicate motion.

FIGURE 17: Operation of PIR Sensor

3.3.7.4 PIN DESCRIPTION:

PIN NAME FUNCTION

- Ground Connects to ground or

VSS

+ V+ Connects to VDD(3.3v

to 5v)

Out Output Connects to an i/o pin

set to input mode

TABLE 3: Pin Description of PIR Sensor

3.3.7.5 SENSITIVITY:

Page 43: Multi Power Generation From Traction System With Energy Conservation

The PIR sensor has a range of approximately 20feet. The sensor is

designed to adjust to slowly changing conditions that would happen normally as

the day progresses and the environmental conditions change, but responds by

making its output high when sudden changes occur, such as when there is

motion.

FIGURE 18: Human Motion Sensor (PIR Sensor)

3.3.7.6 FEATURES:

Single bit output.

Small size makes it easy to conceal.

Compatible with all parallax microcontrollers

3.3v and 5v operation with less than 100uA current draw

3.3.8 RELAY

Page 44: Multi Power Generation From Traction System With Energy Conservation

3.3.8.1 INTRODUCTION

A relay is an electronically controlled switch. So, relays come in the same

varieties as switches. If all that is required is a simple on – off switch (a single

pole single throw relay), then it is simpler, cheaper and more reliable to use one

of the drivers discussed at the Starter level.A relay consists of an electromagnet

and coil plus one or more switches. The switch changes over when the current

in the electromagnet is switched off and on.

FIGURE 19: Relay

3.3.8.2 KINDS OF RELAY

Single pole single throw (SPST)

Single pole double throw (SPDT)

Double pole double throw (DPDT)

Page 45: Multi Power Generation From Traction System With Energy Conservation

FIGURE 20: Single Relay Circuit DiagramA relay is an electrically operated switch. Current flowing through the

coil of the relay creates a magnetic field which attracts a lever and

changes the switch contacts. The coil current can be on or off so relays

have two switch positions and they are double throw (changeover)

switches.

Relays allow one circuit to switch a second circuit which can be

completely separate from the first. For example a low voltage battery

circuit can use a relay to switch a 230V AC mains circuit. There is no

electrical connection inside the relay between the two circuits; the link is

magnetic and mechanical.

3.3.9 INVERTER

An inverter is an electrical device that converts direct current (DC)

to alternating current (AC); the converted AC can be at any required voltage

and frequency with the use of appropriate transformers, switching, and control

circuits.

Page 46: Multi Power Generation From Traction System With Energy Conservation

FIGURE 21: InverterSolid-state inverters have no moving parts and are used in a wide range of

applications, from small switching power supplies in computers, to

large electric utility high-voltage direct current applications that transport bulk

power. Inverters are commonly used to supply AC power from DC sources such

as solar panels or batteries.

FIGURE 22:Inverter Block Diagram

There are two main types of inverter. The output of a modified sine

wave inverter is similar to a square wave output except that the output goes to

zero volts for a time before switching positive or negative. It is simple and low

cost (~$0.10USD/Watt) and is compatible with most electronic devices, except

Page 47: Multi Power Generation From Traction System With Energy Conservation

for sensitive or specialized equipment, for example certain laser printers.

A pure sine wave inverter produces a nearly perfect sine wave output

(<3% total harmonic distortion) that is essentially the same as utility-supplied

grid power. Thus it is compatible with all AC electronic devices. This is the

type used in grid-tie inverters. Its design is more complex, and costs 5 or 10

times more per unit power (~$0.50 to $1.00USD/Watt).  The electrical inverter

is a high-power electronic oscillator. It is so named because early mechanical

AC to DC converters were made to work in reverse, and thus were "inverted",

to convert DC to AC.

The inverter performs the opposite function of a rectifier.

3.3.10 BATTERY

A rechargeable battery, storage battery, or accumulator is a type of electrical

battery. It comprises one or more electrochemical cells, and is a type of

energy accumulator. It is known as a secondary cell because its

electrochemical reactions are electrically reversible. Rechargeable batteries

come in many different shapes and sizes, ranging from button cells to

megawatt systems connected to stabilize an electrical distribution network.

Page 48: Multi Power Generation From Traction System With Energy Conservation

FIGURE 23: Storage Battery

CHAPTER 4: CONCLUSION

This experimental research study incorporates energy-friendly devices and

generating energy from ambient energy sources. Ambient energy sources let

individuals and communities create and consume energy locally. The

promotion of renewable energy sources by home owners has brought a

particular focus to the passive and active use of natural energy sources. Such

research is needed to increase the use of ambient energy sources by

Page 49: Multi Power Generation From Traction System With Energy Conservation

providing detailed information to the public about the reliability of the

sources. Since human motion sensor is implemented in our project energy is

conserved and hence there is no wastage of power.

4.1 FUTURE SCOPE

In future our project can implemented in

Homes

Institutions

Industries

Vehicles

Traffic Signals to sense the vehicles presence.

4.2 REFERENCE

• C. Eichhorn, R. Tchagsim, N. Wilhelm, G. Biancuzzi and P. Woias; IEEE

MEMS 2011, Cancun, MEXICO, January 23-27, 2011 “An Energy-

Autonomous Self-Tunable Piezoelectric Vibration Energy Harvesting

System”

Page 50: Multi Power Generation From Traction System With Energy Conservation

• Özge Zorlu, Emre Tan Topal, and Haluk Külah; IEEE Sensors Journal,

Vol. 11, No. 2, February 2011 “A Vibration-Based Electromagnetic

Energy Harvester Using Mechanical Frequency Up-Conversion Method”

• V. Leonov; IEEE Sensors, Oct. 2012, pp. 1–4“Thermoelectric energy

harvesters for powering wearable sensors “

• Vladimir Leonov, IEEE Sensors Journal, Vol. 13, No. 6, June 2013

“Thermoelectric Energy Harvesting of Human Body Heat for Wearable

Sensors”

• Wei Qi, Jinfeng Liu, Xianzhong Chen, and Panagiotis D. Christofides,

Fellow; IEEE Transactions on Control Systems Technology, Vol. 19, No.

1, January 2011 “Supervisory Predictive Control of Standalone

Wind/Solar Energy Generation Systems”

4.3 OUTPUT

Page 51: Multi Power Generation From Traction System With Energy Conservation

FIGURE 24

Page 52: Multi Power Generation From Traction System With Energy Conservation

FIGURE 25

CHAPTER 5: APPENDICES

#include<reg51.h>

sbit pir=P1^0;

Page 53: Multi Power Generation From Traction System With Energy Conservation

sbit realy=P1^1;

void main()

{

while(1)

{

if(pir==1)

{

relay=1;

}

else

{

relay=0;

}

}

}