Distance Measurement Using Infrared Sensor

42
PROJECT REPORT ON Distance measurement using InfraRed sensor with ADC0804 & 8051 microcontroller (AT89C51) Submitted by UNDER THE GUIDANCE OF DEPARTMENT OF ELECTRONICS ENGINEERING 1

description

Infrared sensors find numerous applications in electronic systems. Commonly used as obstacle detector, their output is used in digital form (high & low logic) by employing a comparator. This topic explains a way to use the sensor’s output in its original analog form.

Transcript of Distance Measurement Using Infrared Sensor

Page 1: Distance Measurement Using Infrared Sensor

PROJECT REPORT ON

Distance measurement using InfraRed sensor with ADC0804 & 8051 microcontroller (AT89C51)

Submitted by

UNDER THE GUIDANCE OF

DEPARTMENT OF ELECTRONICS ENGINEERING

1

Page 2: Distance Measurement Using Infrared Sensor

PROJECT CERTIFICATEThis is to certify that, the project title,

Distance measurement using InfraRed sensor with ADC0804 & 8051 microcontroller

(AT89C51)

.

IS SUCCESSFULLY COMPLETED BY .

.

In partial fulfillment of degree course in TE. ELECTRONICS ENGINEERING as

Prescribed by MUMBAI UNIVERSITY DURING ACADEMIC YEAR 2014-2015

UNDER THE GUIDANCE OF

PROF .

DATE OF SUBMISSION _______________________________________

PROJECT GUIDE HEAD OF DEPARTMENT

( ) ( )

PRINCIPAL

( )

INTERNAL EXAMINER EXTERNAL EXAMINER

2

Page 3: Distance Measurement Using Infrared Sensor

PREFACE

We take an opportunity to present this project report on “Distance measurement using InfraRed sensor with ADC0804 & 8051 microcontroller (AT89C51) ” & put before readers some information regarding our project.

We have made sincere attempts & taken every care to present this matter in precise & compact form, the language being as simple as possible.

We are sure that the information contained in this volume would certainly prove useful for better insight in the scope and dimension of this project in its true perspective.

The task of completion of this project through being difficult was made quite simple, interesting & successful due to deep involvement & complete dedication of our group members.

3

Page 4: Distance Measurement Using Infrared Sensor

CONTENTS

. . .

Sr.No

Topics Page No.

. .

1. Acknowledgement 52. Introduction To The Project 63. Block diagram 84. Working 135. Components Required 176. Methodology 187. PCB Layout 20 8. Troubleshooting 219. Advantages 2210. Disadvantages 23 11. Application 24 12. Conclusion 25 13. Bibliography 26

4

Page 5: Distance Measurement Using Infrared Sensor

ACKNOWLEDGEMENT

It is indeed a matter of great pleasure and proud privilege to be able to present this project on “Distance measurement using InfraRed sensor with ADC0804 & 8051 microcontroller (AT89C51) ”.

The completion of this project work is a milestone in students life and its execution is inevitable in the hands of guide. We are highly indebted the project guide for her invaluable guidance & appreciation for giving form and substance to this report. It is due to her enduring efforts, patience & enthusiasm, which has given a sense of direction and purposefulness to this project and ultimately made it success.

We would like to tender our sincere thanks to the staff members for their co-operation.

We would also like to express our deep regards and gratitude to the Principle Prof. .

We would wish to thank the non-teaching staff and our friends who have helped us all the time in one way or other.

Really it is highly impossible to repay the debt of all the people who have directly or indirectly helped us for performing the project.

5

Page 6: Distance Measurement Using Infrared Sensor

INTRODUCTION TO THE PROJECT

Infrared sensors find numerous applications in electronic systems. Commonly used as obstacle detector, their output is used in digital form (high & low logic) by employing a comparator.  This topic explains a way to use the sensor’s output in its original analog form. Thus, along with detecting an obstacle, its exact distance can also be obtained. This is achieved by processing the output of IR sensor through an ADC0804 (analog to digital converter). The ADC is calibrated to get almost accurate distance measurement.

 The measured distance is also displayed on an LCD screen. The ADC0804 and LCD are interfaced with 8051 microcontroller (AT89C51) to perform these operations. The major drawback of IR based sensors is their capability of detecting short distances.

6

Page 7: Distance Measurement Using Infrared Sensor

BLOCK DIAGRAM

IR led

7

Page 8: Distance Measurement Using Infrared Sensor

An IR LED, also known as IR transmitter, is a special purpose LED that transmits infrared rays in the range of 760 nm wavelength. Such LEDs are usually made of gallium arsenide or aluminium gallium arsenide. They, along with IR receivers, are commonly used as sensors.The appearance is same as a common LED. Since the human eye cannot see the infrared radiations, it is not possible for a person to identify whether the IR LED is working or not, unlike a common LED. To overcome this problem, the camera on a cellphone can be used. The camera can show us the IR rays being emanated from the IR LED in a circuit.

Pin Diagram: 

Preset

8

Page 9: Distance Measurement Using Infrared Sensor

A preset is a three legged electronic component which can be made to offer varying resistance in a circuit. The resistance is varied by adjusting the rotary control over it. The adjustment can be done by using a small screw driver or a similar tool. The resistance does not vary linearly but rather varies in exponential or logarithmic manner. Such variable resistors are commonly used for adjusting sensitivity along with a sensor. The variable resistance is obtained across the single terminal at front and one of the two other terminals. The two legs at back offer fixed resistance which is divided by the front leg. So whenever only the back terminals are used, a preset acts as a fixed resistor. Presets are specified by their fixed value resistance

9

Page 10: Distance Measurement Using Infrared Sensor

Pin Diagram:  

10

Page 11: Distance Measurement Using Infrared Sensor

Lcd

LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments and other multi segment LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on.

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, Command and Data.

The command register stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor position, controlling display etc. The data register stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.

11

Page 12: Distance Measurement Using Infrared Sensor

Pin Diagram: 

12

Page 13: Distance Measurement Using Infrared Sensor

Pin Description:  

 

 Pin No

 Function  Name

1 Ground (0V) Ground2 Supply voltage; 5V (4.7V – 5.3V)  Vcc3 Contrast adjustment; through a variable resistor  VEE

4Selects command register when low; and data register when high

Register Select

5Low to write to the register; High to read from the register

Read/write

6Sends data to data pins when a high to low pulse is given

Enable

7

8-bit data pins

DB08 DB19 DB2

10 DB311 DB412 DB513 DB614 DB715 Backlight VCC (5V) Led+16 Backlight Ground (0V) Led-

 

13

Page 14: Distance Measurement Using Infrared Sensor

AT89C51

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (PEROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times.

 

In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually.

 

Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts.

14

Page 15: Distance Measurement Using Infrared Sensor

Pin Diagram:  

Pin Description:  

15

Page 16: Distance Measurement Using Infrared Sensor

 Pin No

 Function  Name

1

8 bit input/output port (P1) pins

P1.0

2 P1.1

3 P1.2

4 P1.3

5 P1.4

6 P1.5

7 P1.6

8 P1.7

9 Reset pin; Active high Reset

10Input (receiver) for serial communication

RxD

8 bit input/output port (P3) pins

P3.0

11Output (transmitter) for serial communication

TxD P3.1

12 External interrupt 1 Int0 P3.2

13 External interrupt 2 Int1 P3.3

14 Timer1 external input T0 P3.4

15 Timer2 external input T1 P3.5

16Write to external data memory

Write P3.6

17Read from external data memory

Read P3.7

18Quartz crystal oscillator (up to 24 MHz)

Crystal 2

19 Crystal 1

20 Ground (0V) Ground

21 8 bit input/output port (P2) pins

/

High-order address bits when interfacing with external memory

 P2.0/ A8

22  P2.1/ A9

23  P2.2/ A10

24  P2.3/ A11

25  P2.4/ A12

26  P2.5/ A13

16

Page 17: Distance Measurement Using Infrared Sensor

27 P2.6/ A14

28  P2.7/ A15

29Program store enable; Read from external program memory

PSEN

30Address Latch Enable ALE

Program pulse input during Flash programming Prog

31

External Access Enable;  Vcc for internal program executions

EA

Programming enable voltage; 12V (during Flash programming)

Vpp

32

8 bit input/output port (P0) pins

Low-order address bits when interfacing with external memory

 P0.7/ AD7

33  P0.6/ AD6

34  P0.5/ AD5

35  P0.4/ AD4

36  P0.3/ AD3

37  P0.2/ AD2

38  P0.1/ AD1

39  P0.0/ AD0

40 Supply voltage; 5V (up to 6.6V) Vcc

17

Page 18: Distance Measurement Using Infrared Sensor

ADC0804

Analog to digital converters find huge application as an intermediate device to convert the signals from analog to digital form. These digital signals are used for further processing by the digital processors. Various sensors like temperature, pressure, force etc. convert the physical characteristics into electrical signals that are analog in nature.

ADC0804 is a very commonly used 8-bit analog to digital convertor. It is a single channel IC, i.e., it can take only one analog signal as input. The digital outputs vary from 0 to a maximum of 255. The step size can be adjusted by setting the reference voltage at pin9. When this pin is not connected, the default reference voltage is the operating voltage, i.e., Vcc. The step size at 5V is 19.53mV (5V/255), i.e., for every 19.53mV rise in the analog input, the output varies by 1 unit. To set a particular voltage level as the reference value, this pin is connected to half the voltage. For example, to set a reference of 4V (Vref), pin9 is connected to 2V (Vref/2), thereby reducing the step size to 15.62mV (4V/255). 

ADC0804 needs a clock to operate. The time taken to convert the analog value to digital value is dependent on this clock source. An external clock can be given at the Clock IN pin. ADC 0804 also has an inbuilt clock which can be used in absence of external clock. A suitable RC circuit is connected between the Clock IN and Clock R pins to use the internal clock.  

18

Page 19: Distance Measurement Using Infrared Sensor

Pin Diagram:  

19

Page 20: Distance Measurement Using Infrared Sensor

Pin Description:  

Pin No

Function Name

1 Activates ADC; Active low Chip select

2Input pin; High to low pulse brings the data from internal

registers to the output pins after conversionRead

3 Input pin; Low to high pulse is given to start the conversion Write4 Clock Input pin; to give external clock. Clock IN5 Output pin; Goes low when conversion is complete Interrupt6 Analog non-inverting input Vin(+)7 Analog inverting Input; normally ground Vin(-)

8 Ground(0V)Analog Ground

9 Input pin; sets the reference voltage for analog input Vref/210 Ground(0V) Digital Ground11

8 bit digital output pins

D712 D613 D514 D415 D316 D217 D118 D019 Used with Clock IN pin when internal clock source is used Clock R20 Supply voltage; 5V Vcc

20

Page 21: Distance Measurement Using Infrared Sensor

WORKING

21

Page 22: Distance Measurement Using Infrared Sensor

This project mainly consists of three units:

A sensor unit, ADC component LCD module.

The IR receiver detects the IR radiations transmitted by an IR LED. The output voltage level of this IR sensor depends upon the intensity of IR rays received by the receiver. The intensity, in turn, depends on the distance between the sensor module and the obstacle. When the distance between IR pair and obstacle is lesser, more IR radiations fall on the receiver, and vice versa. The receiver along with a resistor forms a voltage divider whose output is supplied as the input for ADC0804.

22

Page 23: Distance Measurement Using Infrared Sensor

COMPONENTS REQUIRED

RESISTORS (+5% CARBON,1/4W)

R1 - 1KΩ 1NOS R2 - 4.7KΩ 1NOSR3 - 10KΩ 1NOS R4 - 47KΩ 1NOSVR1 - 100KΩ 1NOS(PRESET) H

CAPACITORS

C1,2 - 0.01μF 2NOSC3 - 100 μF/ 1NOS 16V

MISC IC1 - 1C555 1NOS T1 - BC548 1NOSLS - 2 ½” 8E SPK/. 1NOSD1 - 1N4148 GER DIODE 1NOS

23

Page 24: Distance Measurement Using Infrared Sensor

METHODOLOGY

Design your circuit board. Use PCB Wizard software to draw your circuit board. You can also use a perforated board that has pre-drilled holes in it to help you see how your circuit board's components would be placed and work in reality.

Buy a plain board that is coated with a fine layer of copper on one side from a retailer.

Scrub the board with a scouring pad and water to make sure the copper is clean. Let the board dry.

Print your circuit board's design onto the dull side of a sheet of blue transfer paper. Make sure the design is oriented correctly for transfer.

Place the blue transfer paper on the board with the circuit board's printed design against the copper.

Lay a sheet of ordinary white paper over the blue paper. Following the transfer paper's instructions, iron over the white and blue paper to transfer the design onto the copper board. Iron every design detail that appears near an edge or corner of the board with the tip of the iron.

Let the board and blue paper cool. Peel the blue paper slowly away from the board to see the transferred design.

24

Page 25: Distance Measurement Using Infrared Sensor

Examine the transfer paper to check for any black toner from the printed design that failed to transfer to the copper board. Make sure the board's design is oriented correctly.

Replace any missing toner on the board with ink from a black permanent marker. Allow the ink to dry for a few hours.

Remove exposed parts of the copper from the board using ferric chloride in a process called etching.

Wash all the etching equipment and the circuit board thoroughly with plenty of running water.

Drill 0.03 inch (0.8 mm) lead component holes into your circuit board with high-speed steel or carbide drill bits. Wear safety goggles and a protective mask to protect your eyes and lungs while you drill.

Scrub the board clean with a scouring pad and running water. Add your board's electrical components and solder them into place.

25

Page 26: Distance Measurement Using Infrared Sensor

PCB LAYOUT

26

Page 27: Distance Measurement Using Infrared Sensor

TROUBLESHOOTING

After building up the entire project we came to know that our project was not working, this condition was havoc for us.

After Troubleshooting the circuit we came across following faults:-

Two of the IC pins were short circuited.

This problem was solved by desoldering those pins, & again soldering them back to the PCB with care.

A wrong diode was installed instead of 1n4148 germanium diode.

This time we replaced that diode with a 1n4148 germanium diode and observed whether the circuit is working or not.

Transistor was faulty.

After checking the hfe of the transistor we came to a conclusion that we have to change the transistor as it was damage due to use of improper soldering techniques.

27

Page 28: Distance Measurement Using Infrared Sensor

ADVANTAGES

1. Early WarningMany fires occur at night or in a room or section that no one may be in at the time. The audible alert from the fire alarm can wake individuals up who may otherwise sleep while inhaling smoke. The alert can also provide an early signal during the day to individuals who, if not for the alarm, would not have the time needed to escape the home or building before the fire spreads out of control.

2. Flexibility to place them in specific rooms and areas of your choice.

3. Low CostA fire system that is remotely monitored on a continuous basis is normally part of an agreement with an alarm company that also includes burglar alarms.

28

Page 29: Distance Measurement Using Infrared Sensor

DISADVANTAGES

1. Susceptible to nuisance alarms if placed too close to cooking.

2. May be slow to respond slow smoldering fires.

 

3. None what so ever!!! They are there to save lives- whatever they do. Although they could be a nuisance if they do cause false activations by themselves.

29

Page 30: Distance Measurement Using Infrared Sensor

APPLICATION

1. Fire alarms can be used in any place like parks, theaters, HOTELS, restaurants, boats, ships, etc.

2. Fire alarms can be also used as temperature sensors in some applications, when the temperature goes up abruptly it can inform.

3. Fire alarm can be used in our home for safety purpose and it is a very good precautionary measure.

30

Page 31: Distance Measurement Using Infrared Sensor

CONCLUSION

A fire alarm is a device that detects the presence of fire and atmospheric changes relating tosmoke. In some cases, a firm alarm is a part of a complete security system, in addition to aburglary protection system. The fire alarm operates to alert people to evacuate a location inwhich a fire or smoke accumulation is present.

When functioning properly, a fire alarm will sound to notify people of an immediate fireemergency. Fire alarms can be found in homes, schools, churches and businesses, andfunction as the catalyst to saving lives. For most fire alarms, when sounded, a beep, bell orhorn noise is made. This distinct sound exists to allow the notification to be heard The fire alarm constructed by this project work is reliable at low cost.

31

Page 32: Distance Measurement Using Infrared Sensor

BIBLIOGRAPHY

CIRCUITS AND NETWORKS –A SUDHAKAR, SHYAMMOHAN.PILLAI

OP-AMPS AND LINEAR INTEGRATED CIRCUITS – RAMAKANT A.GAYAKWAD

www.nfpa.org

en.wikipedia.org

www.ask.com

32