obstacle detection and avoidance robot

71
OBSTACLE DETECTION AND AVOIDANCE ROBOT Abstract Robot is a system that contains sensors, control systems, manipulators, power supplies and software all working together to perform a task. Designing, building, programming and testing a robot is a combination of physics, mechanical engineering, electrical engineering, structural engineering, mathematics and computing. In some cases biology, medicine, chemistry might also be involved. Obstacle Detecting Robot is a machine that detects any obstacle present in its way and if found, changes its direction automatically. Sensing the obstacle and maneuvering the robot to stay on course, while constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system. The system contains PIR sensor that can detect the obstacle in any direction. If the vehicle encounters the obstacle in the forward direction, the robot changes it direction to left. If there is an obstacle even in the left, it moves to right and if the robot detects an obstacle in the right direction, the vehicle stops. 8

Upload: skrzak

Post on 06-Feb-2016

46 views

Category:

Documents


1 download

DESCRIPTION

OBSTACLE DETECTION AND AVOIDANCE ROBOT

TRANSCRIPT

Page 1: Obstacle Detection and Avoidance Robot

OBSTACLE DETECTION AND AVOIDANCE ROBOT

Abstract

Robot is a system that contains sensors, control systems, manipulators, power supplies and software

all working together to perform a task. Designing, building, programming and testing a robot is a

combination of physics, mechanical engineering, electrical engineering, structural engineering, mathematics

and computing. In some cases biology, medicine, chemistry might also be involved.

Obstacle Detecting Robot is a machine that detects any obstacle present in its way and if found,

changes its direction automatically. Sensing the obstacle and maneuvering the robot to stay on course, while

constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop

system.

The system contains PIR sensor that can detect the obstacle in any direction. If the vehicle encounters

the obstacle in the forward direction, the robot changes it direction to left. If there is an obstacle even in the

left, it moves to right and if the robot detects an obstacle in the right direction, the vehicle stops.

8

Page 2: Obstacle Detection and Avoidance Robot

CHAPTER-1

INTRODUCTION TO EMBEDDED SYSTEMS

An embedded system is a special-purpose computer system designed to perform one or a few

dedicated functions, often with real-time computing constraints. It is usually embedded as part of a complete

device including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal

computer, can do many different tasks depending on programming. Embedded systems control many of the

common devices in use today .Since the embedded system is dedicated to specific tasks, design engineers can

optimize it, reducing the size and cost of the product, or increasing the reliability and performance. Some

embedded systems are mass-produced, benefiting from scale. Physically, embedded systems range from

portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights,

factory controllers, or the systems controlling nuclear power plants. Complexity varies from low, with a

single microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large

chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as many systems have some element

of programmability. For example, Handheld computers share some elements with embedded systems — such

as the operating systems and microprocessors which power them but are not truly embedded systems,

because they allow different applications to be loaded and peripherals to be connected. Embedded systems

span all aspects of modern life and there are many examples of their use. Telecommunications systems

employ numerous embedded systems from telephone switches for the network to mobile phones at the end-

user. Computer networking uses dedicated routers and network bridges to route data.

1.1 Characteristics:

1. Embedded systems are designed to do some specific task, rather than be a general-purpose computer

for multiple tasks. Some also have real-time performance constraints that must be met, for reasons

such as safety and usability; others may have low or no performance requirements, allowing the

system hardware to be simplified to reduce costs.

2. Embedded systems are not always standalone devices. Many embedded systems consist of small,

computerized parts within a larger device that serves a more general purpose. For example, the

Gibson Robot Guitar features an embedded system for tuning the strings, but the overall purpose of

the Robot Guitar is, of course, to play music. Similarly, an embedded system in an automobile

provides a specific function as a subsystem of the car itself.

9

Page 3: Obstacle Detection and Avoidance Robot

3. The software written for embedded systems is often called firmware, and is usually stored in read-

only memory or Flash memory chips rather than a disk drive. It often runs with limited computer

hardware resources: small or no keyboard, screen, and little memory.

1.2 CPU platforms:

Embedded processors can be broken into two broad categories: ordinary microprocessors (μP) and

microcontrollers (μC), which have many more peripherals on chip, reducing cost and size. Contrasting to the

personal computer and server markets, a fairly large number of basic CPU architectures are used; there are

Von Neumann as well as various degrees of Harvard architectures, RISC as well as non-RISC and VLIW;

word lengths vary from 4-bit to 64-bits and beyond (mainly in DSP processors) although the most typical

remain 8/16-bit. Most architectures come in a large number of different variants and shapes, many of which

are also manufactured by several different companies.

1.3 ASIC and FPGA solutions:

A common configuration for very-high-volume embedded systems is the system on a chip (SOC), an

application-specific integrated circuit (ASIC), for which the CPU core was purchased and added as part of the

chip design. A related scheme is to use a field-programmable gate array (FPGA), and program it with all the

logic, including the CPU.

1.4 Peripherals:

Embedded Systems talk with the outside world via peripherals, such as

Serial Communication Interfaces (SCI): RS-232, RS-422, RS-485 etc

Synchronous Serial Communication Interface: I2C, JTAG, SPI, SSC and ESSI

Universal Serial Bus (USB)

Networks: Ethernet, Controller Area Network, LAN networks, etc

Timers: PLL(s), Capture/Compare and Time Processing Units

Discrete IO: aka General Purpose Input/output (GPIO)

Analog to Digital/Digital to Analog (ADC/DAC)

10

Page 4: Obstacle Detection and Avoidance Robot

1.5 Tools:

As for other software, embedded system designers use compilers, assemblers, and debuggers to develop

embedded. However, they may also use some more specific tools:

In circuit debuggers or emulators

Utilities to add a checksum or CRC to a program, so the embedded system can check if the program

is valid.

For systems using digital signal processing, developers may use a math workbench such as

MATLAB, Simulink, MathCAD, or Mathematica to simulate the mathematics. They might also use

libraries for both the host and target which eliminates developing DSP routines as done in DSP nano

RTOS and Unison Operating System.

Custom compilers and linkers may be used to improve optimization for the particular hardware.

An embedded system may have its own special language or design tool, or add enhancements to an

existing language such as Forth or Basic.

Another alternative is to add a Real-time operating system or Embedded operating system, which

may have DSP capabilities like DSP nano RTOS.

1.6 Software tools can come from several sources:

Software companies that specialize in the embedded market

Ported from the GNU software development tools

Sometimes, development tools for a personal computer can be used if the embedded processor is a

close relative to a common PC processor

As the complexity of embedded systems grows, higher level tools and operating systems are

migrating into machinery where it makes sense. For example, cell phones, personal digital assistants and

other consumer computers often need significant software that is purchased or provided by a person other

than the manufacturer of the electronics. In these systems, an open programming environment such as Linux,

NetBSD, OSGI or Embedded Java is required so that the third-party software provider can sell to a large

market.

11

Page 5: Obstacle Detection and Avoidance Robot

CHAPTER-2

OVERVIEW:

Obstacle Detecting Robot is a machine that detects any obstacle present in its way and if found,

changes its direction automatically. Sensing the obstacle and maneuvering the robot to stay on course, while

constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop

system.

The system contains PIR sensor that can detect the obstacle in any direction. If the vehicle encounters

the obstacle in the forward direction, the robot changes it direction to left. If there is an obstacle even in the

left, it moves to right and if the robot detects an obstacle in the right direction, the vehicle stops.

Block Diagram:

12

Page 6: Obstacle Detection and Avoidance Robot

WORKING:

The system contains three IR sensors that can detect the obstacle in any direction. If the vehicle

encounters the obstacle in the forward direction, the robot changes it direction to left. If there is an

obstacle even in the left, it moves to right and if the robot detects an obstacle in the right direction,

the vehicle stops.

Obstacle Detecting Robot is a machine that detects any obstacle present in its way and if

found, changes its direction automatically. Sensing the obstacle and maneuvering the robot to stay

on course, while constantly correcting wrong moves using feedback mechanism forms a simple yet

effective closed loop system.

13

Page 7: Obstacle Detection and Avoidance Robot

CHAPTER 3

AT89S52 MICROCONTROLLER

3.1 AT89S52 MICROCONTROLLER:

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

with 4 Kbytes of Flash Programmable and Erasable Read Only Memory (PEROM).

The device is manufactured using Atmel’s high-density non-volatile memory

technology and is compatible with the industry standard MCS-51Ô instruction set and

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

or by a conventional non-volatile memory programmer. By combining a versatile 8-bit

CPU with Flash on a monolithic chip, the Atmel AT89S52 is a powerful

microcomputer, which provides a highly flexible and cost effective solution to many

embedded control applications.

3.1.1 FEATURES OF MICROCONTROLLER:

Compatible with MCS-51TM Products

4 Kbytes of In-System Reprogram able Flash Memory- Endurance:

1,00Write/Erase Cycles

Fully Static Operation: 0 Hz to 24 MHz

Three-Level Program Memory Lock

128 Bytes Internal RAM

32 Programmable I/O Lines

Two 16-Bit Timer/Counters

Eight Interrupt Sources

Programmable Serial Channel

Low Power Idle and Power Down Modes

3.2 PIN CONFIGURATION:

14

Page 8: Obstacle Detection and Avoidance Robot

Figure 3.1 Pin configuration of AT89S52 microcontroller

3.2.1 LOGIC SYMBOL:

15

Page 9: Obstacle Detection and Avoidance Robot

Figure 3.2 logic symbol of AT89S52

3.3 MEMORY ORGANIZATION:

The 89S52 micro controller has separate address for program memory and data

memory. The logical separation of program and data memory allows the data memory

to be accessed by 8-bit address, which can be quickly stored and manipulated by an 8-

bit CPU. Nevertheless, 16-bit data memory address can also be generated through the

DPTR register. Program memory (ROM, EPROM) can only be read, not written to.

There can be up to 64k bytes if program memory the lowest 4k bytes of program are on

chip. In the ROM less versions, all program memory is external. The read strobe for

external program is the PSEN (program store enable). Data memory (RAM) occupies a

separate address space from program memory the lowest 128 bytes of data memory are

on chip. Up to 64 bytes of external RAM can be addressed in the external data memory

space. In the ROM less version, the lowest 128bytes of data memory are on chip. The

CPU generates read and write signals, RD and WR, as needed during external data

memory access.

16

Page 10: Obstacle Detection and Avoidance Robot

External program memory may be combined if desired by applying the RD and

PSEN signals to the inputs of an AND gate and using the output of the gate as the read

strobe to the external program/data memory.

3.3.1 DATA MEMORY:

FF FFFF

80 AND

7F

B B0000

SFR’S DIRECT

ADDRESSING ONLY

DIRECT ADDRESSING ONLY

64K BYTES EXTERNAL

17

Page 11: Obstacle Detection and Avoidance Robot

3.3.2 PROGRAM MEMORY:

FFFF FFFF

1000

FFF

0000 0000

The 128 byte of RAM are divided into 3 segments

a). Register banks 0 – 3 (00 – 1FH)

b). Bit addressable area (20H – 2FH)

c). Scratch pad area (30H – 7FH)

If the SP is initialized to this area enough bytes should be left aside to

prevent SP data destruction.

60k Bytes External

4k Bytes Internal

64k

Bytes

External

18

Page 12: Obstacle Detection and Avoidance Robot

3.4 SPECIAL FUNCTION REGISTERS:

3.4.1 A & B REGISTERS:

They are used during math and logically operations. The register A is also

used for all data transfers between the micro controller and memory. The B register

is used during multiplication and divided operations. For other instructions it can be

treated as another scratch pad register.

3.4.2 PSW (PROGRAM STATUS WORD):

It contains math flags; user flags F0 and register select bits RS1 and RS0 to

determine the working register bank.

3.4.3 STACK AND STACK POINTER:

Stack is used to hold and retrieve data quickly. The 8 – bit SP is

incremented before data is stored during PUSH and CALL executions. While the

stack may reside anywhere in on-chip RAM, the SP is initialized to 07H after the

stack to begin at manipulated as a 16 – bit register or as two independent 8 – bit

registers.

3.4.4 PC (PROGRAM COUNTER):

It addresses the memory locations that program instructions are to be

fetched. It is the only register that does not have any internal address.

3.4.4 FLAGS:

They are 1–bit register provided to store the results of certain program

instructions. Other instructions can test the conditions of the flags and make the

decisions accordingly. To conveniently address, they are grouped inside the PSW

and PCON.

19

Page 13: Obstacle Detection and Avoidance Robot

The micro controller has 4 main flags: carry(c), auxiliary carry (AC),

over flow (OV), parity (P) and 3 general-purpose flagsF0, GF0 and GF1.

3.4.5 PORTS:

All ports are bi-directional; each consists of a latch, an output driver and an

input buffer. P0, P1, P2 and P3 are the SFR latches ports 0, 1, 2 and 3 respectively.

The main functions of each port are mentioned below.

Port0: input/output bus port, address output port and data input/output port.

Port1: Quasi-bi-directional input/output port.

Port2: Quasi-bi-directional input/output port and address output port.

Port3: Quasi-bi-directional input/output port and control input/output pin.

3.4.6 SBUF (SERIAL BUFFER):

The microcontroller has serial transmission circuit that uses SBUF register

to hold data. It is actually two separate registers, a transmit buffer and a receive

buffer register. When data is moved to SBUF, it goes to transmit buffer, where it is

held for serial transmission and when it is moved from SBUF, it comes from the

receive buffer.

3.5 TIMER REGISTER:

Register pairs (TH0, TL1), (TH1, TL1) are the 16-bit counter registers for

timer/counters 0 and 1.

3.5.1 CONTROL REGISTERS:

SFR’s, IP, TMOD, SCON, and PCON contain control and status bits for the

interrupt system, Timers/counters and the serial port.

3.5.2 OSCILLATOR AND CLOCK CIRCUIT:

This circuit generates the clock pulses by which all internal operations are

20

Page 14: Obstacle Detection and Avoidance Robot

synchronized. For the microcontroller to yield standard baud rates, the crystal

frequency is chosen as 11.059MHz.

3.5.3 RESET:The reset switch is the RST pin of the microcontroller, which is the input to

a Schmitt trigger. It is accomplished by holding the RST pin HIGH for at least two

machine cycles while the oscillator frequency is running the CPU responds by

generating an internal reset.

3.5.4 TIMERS/COUNTERS:

A micro controller has two 16- bit Timer/Counter register T0 and T1

configured to operate either as timers or event counters. There are no restrictions on

the duty cycle of the external input signal, but it should be for at least one full

machine to ensure that a given level is sampled at least once before it changes.

Timers 0 and 1 have four operating modes: 13-bit mode, 16 – bit mode, 8 – bit auto-

reload mode. Control bits C/t in TMOD SFR select the timer or counter function.

MODE 0:Both timers in MODE0 are counters with a divide – by – 32 pre-scalar. The

timer register is configured as a 13 – bit register with all 8 bits of TH1 and the

lower 5-bit of TL1.The upper 3 bits of TL1 are in determinate and should be

ignored. Setting the run flags (TR1) doesn’t clear the register or the registers.

MODE 1:Mode 1 is same as mode 0, except that the timer register is run with all 16

bits. The clock is applied to the combined high and low timer registers. An

overflow occurs on the overflow flag. The timer continues to count.

MODE 2:This mode configures the timer register as an 8 – bit counter (TL1/0) with

automatic reload. Overflow from TL1/0 not only sets TF1/0, but also reloads TL1/0

with the contents of TH1/0, which is preset by software. The reload leaves

unchanged.

MODE 3:Mode 3 is used for application that requires an extra 8 – bit timer or counter.

21

Page 15: Obstacle Detection and Avoidance Robot

Timer 1 in mode 3 simply holds its count. The effect is same as setting TR0. Timer

0 its mode 3 establishes TL0 and TL1 as two separate counters. TL0 uses the timer0

control bits C/T, GATE, TR0, INT0 and TF0. TH0 is locked into a timer function

and over the use of TR1 and TR2 from timer 1. Thus TH0 controls the timer 1

interrupts.

3.6 INTERRUPTS:The micro controller provides 6 interrupt sources, 2 external interrupts, 2

timer interrupts and a serial port interrupt and a reset. The external interrupts (INT0

& INT1) can each be either level activated or transition activated depending on bits

IT0 and IT1 in register TCON. The flags that actually generate these interrupts are

IE0 & IE1 bits in TCON.

TF0 and TF1 generate the timer 0 & 1 interrupts, which are set by a roll over

in their respective timer/counter registers. When a timer interrupt is generated the

on-chip hardware clears the flag that generated it when the service routine is

vectored to.

The serial port interrupt is generated by logical OR of R1 & T1. Neither of

these flags is cleared by hardware when service routine is vectored to. In fact, the

service routine itself determines whether R1 & T1 generated the interrupt, and the

bit is cleared in the software.

Upon reset, all interrupts are disabled, meaning that none will be responded

to by the micro controller if they are activated. The interrupts must be enabled by

software in order for the micro controller to respond to them.

3.7 SERIAL INTERFACE:The serial port is full duplex, i.e. it can transmit and receive simultaneously.

It is also receive buffered which implies it can begin receiving a second byte before

a previously byte has been read from the receive register. The serial port receives

and transmits register and reading SBUF accesses a physically separate receive

register.

This serial interface had four modes of operation:

22

Page 16: Obstacle Detection and Avoidance Robot

MODE 0:In this mode of operation the serial data enters and exists through

RXD.TXD outputs the shift clock. Eight data bits are transmitted/ received, with the

LSB first, the baud rate is fixed at 1/12 of the oscillator frequency. Reception is

initialized by the condition RI-0 and REN=1.

MODE 1:In this mode 10 bits (a start bit 0, 8 data bits with LSB first and a stop bit are

transmitted through TXD port received through RXD. At the receiving end the stop

bits goes into RB8 in the SFR SCON. The baud rate is variable.

MODE 2:In the 2, 16 bits (a start bit 0, 8 data bits (LSDB first), a programmable 9th

data bit and a stop bit) are transmitted through TXD or received through RXD.The

baud rate is programmable to either 1/32 or 1/64 of the oscillator frequency

MODE 3:

The function of mode 3 is same as mode 2 except that the baud rate is

variable. Reception is initialized by the incoming start bit if REN=1.

3.8 BAUDRATE CALCULATIONS: Baud rate in mode 0 is fixed.

Mode 0 baud rate=oscillator frequency/12

(1 machine cycle=12 clock. cycles)

The baud rate in mode 2 depends on the value of SMOD bit in PCON

Register.

SMOD=0, baud rate= (1/64) x oscillator frequency.

SMOD=1baud rate= (1/32) oscillator frequency.

I.e. mode 2 baud rate= [2(POW) SMOD/64)] x oscillator frequency.

In the modes 1 and 3, timer 1 over flow rate and the value of SMOD

determines the baud rate. Baud rate of mode 1 and 3 = [(2(POW)

SMOD/32)] x timer 1 over flow rate.

The timer 1 interrupt should be disabled in this application.

23

Page 17: Obstacle Detection and Avoidance Robot

3.9 PROGRAM MEMORY LOCK BITS:

On the chip are three lock bits, which can be left un-programmed (u) or can

be programmed (p) to obtain the additional features listed in the table below.

When lock bit 1 is programmed, the logic level at the EA pin is sampled and latched

during reset.

If the device is powered up without a reset, the latch initializes to a random

value, and holds that value until reset is activated. It is necessary so that the latched

value of EA be in agreement with the current logic level at that pin in order for the

device to function properly.

24

Page 18: Obstacle Detection and Avoidance Robot

CHAPTER 4

IMPLEMENTATION OF HARDWARE

4.1 LED (LIGHT EMITTING DIODE):

4.1.1 Introduction:

A light-emitting diode (LED) is a semiconductor diode that emits light when an electrical

current is applied in the forward direction of the device, as in the simple LED circuit. The effect

is a form of electroluminescence. Where incoherent and narrow-spectrum light is emitted from

the p-n junction.

LEDs are widely used as indicator lights on electronic devices and increasingly in higher power

applications such as flashlights and area lighting. An LED is usually a small area (less than 1

mm2) light source, often with optics added to the chip to shape its radiation pattern and assist in

reflection. The color of the emitted light depends on the composition and condition of the semi

conducting material used, and can be infrared, visible, or ultraviolet. Besides lighting, interesting

applications include using UV-LEDs for sterilization of water and disinfection of devices , and

as a grow light to enhance photosynthesis in plants.

4.1.2 Basic principle:

Like a normal diode, the LED consists of a chip of semi conducting material

impregnated, or doped, with impurities to create a p-n junction. As in other diodes, current flows

easily from the p-side, or anode, to the n-side, or cathode, but not in the reverse direction.

Charge-carriers electrons and holes flow into the junction from electrodes with different

25

Page 19: Obstacle Detection and Avoidance Robot

voltages. When an electron meets a hole, it falls into a lower energy level, and releases energy in

the form of a photon.

The wavelength of the light emitted, and therefore its color, depends on the band gap energy of

the materials forming the p-n junction. In silicon or germanium diodes, the electrons and holes

recombine by a non-radiative transition which produces no optical emission, because these are

indirect band gap materials. The materials used for the LED have a direct band gap with energies

corresponding to near-infrared, visible or near-ultraviolet light. LED development began with

infrared and red devices made with gallium arsenide. Advances in materials science have made

possible the production of devices with ever-shorter wavelengths, producing light in a variety of

colors. LEDs are usually built on an n-type substrate, with an electrode attached to the p-type

layer deposited on its surface. P-type substrates, while less common, occur as well. Many

commercial LEDs, especially GaN/InGaN, also use sapphire substrate.

4.2 LED Display types:

Bar graph

Seven segment

Star burst

Dot matrix

26

Page 20: Obstacle Detection and Avoidance Robot

4.3Basic LED types:

4.3.1Miniature LEDs

Different sized LEDs. 8 mm, 5mm and 3 mm

These are mostly single-die LEDs used as indicators, and they come in various-size packages:

surface mount

2 mm

3 mm (T1)

5 mm (T1³⁄₄)

10 mm

Other sizes are also available, but less common.

Common package shapes:

Round, dome top

Round, flat top

Rectangular, flat top (often seen in LED bar-graph displays)

Triangular or square, flat top

27

Page 21: Obstacle Detection and Avoidance Robot

The encapsulation may also be clear or semi opaque to improve contrast and viewing angle.

There are three main categories of miniature single die LEDs:

Low current — typically rated for 2 mA at around 2 V (approximately 4 mW consumption).

Standard — 20 mA LEDs at around 2 V (approximately 40 mW) for red, orange, yellow & green,

and 20 mA at 4–5 V (approximately 100 mW) for blue, violet and white.

Ultra-high output — 20 mA at approximately 2 V or 4–5 V, designed for viewing in direct

sunlight.

4.3.2 Five- and twelve-volt LEDs:

These are miniature LEDs incorporating a series resistor, and may be connected directly

to a 5 V or 12 V supply.

4.3.3 Flashing LEDs:

Flashing LEDs are used as attention seeking indicators where it is desired to avoid the

complexity of external electronics. Flashing LEDs resemble standard LEDs but they contain

an integrated multivibrator circuit inside which causes the LED to flash with a typical period

of one second. In diffused lens LEDs this is visible as a small black dot. Most flashing LEDs

emit light of a single color, but more sophisticated devices can flash between multiple colors

and even fade through a color sequence using RGB color mixing.

4.3.4 High power LEDs

High power LEDs from lumileds mounted on a star shaped heat sink High power LEDs (HPLED)

can be driven at more than one ampere of current and give out large amounts of light. Since overheating

destroys any LED the HPLEDs must be highly efficient to minimize excess heat, furthermore they are

often mounted on a heat sink to allow for heat dissipation. If the heat from a HPLED is not removed the

device will burn out in seconds.

A single HPLED can often replace an incandescent bulb in a flashlight or be set in an

array to form a powerful LED lamp. LEDs have been developed that can run directly from mains

28

Page 22: Obstacle Detection and Avoidance Robot

power without the need for a DC converter. For each half cycle part of the LED diode emits light

and part is dark, and this is reversed during the next half cycle. Current efficiency is 80 lm/W..

4.3.5 Multi-color LEDs:

A “bi-color LED” is actually two different LEDs in one case. It consists of two dies

connected to the same two leads but in opposite directions. Current flow in one direction

produces one color, and current in the opposite direction produces the other color. Alternating

the two colors with sufficient frequency causes the appearance of a third color. A “tri-color

LED” is also two LEDs in one case, but the two LEDs are connected to separate leads so that the

two LEDs can be controlled independently and lit simultaneously.

RGB LEDs contain red, green and blue emitters, generally using a four-wire connection with one

common (anode or cathode). The Taiwanese LED manufacturer ever light has introduced a 3

watt RGB package capable of driving each die at 1 watt.

4.3.5 Alphanumeric LEDs:

LED displays are available in seven-segment and starburst format. Seven-segment

displays handle all numbers and a limited set of letters. Starburst displays can display all letters.

Seven-segment LED displays were in widespread use in the 1970s and 1980s, but increasing use

of liquid crystal displays, with their lower power consumption and greater display flexibility, has

reduced the popularity of numeric and alphanumeric LED displays.

4.4 Applications:

Automotive applications with LEDS:

Instrument Panels & Switches, Courtesy Lighting, CHMSL, Rear Stop/Turn/Tai,

Retrofits, New Turn/Tail/Marker Lights.

Consumer electronics & general indication:

29

Page 23: Obstacle Detection and Avoidance Robot

Household appliances, VCR/ DVD/ Stereo/Audio/Video devices, Toys/Games

Instrumentation, Security Equipment, Switches.

Illumination with LEDs:

Architectural Lighting, Signage (Channel Letters), Machine Vision, Retail Displays,

Emergency Lighting (Exit Signs), Neon and bulb Replacement, Flashlights, Accent Lighting -

Pathways, Marker Lights.

Sign applications with LEDs:

Full Color Video, Monochrome Message Boards, Traffic/VMS, Transportation –

Passenger Information.

Signal application with LEDs:

Traffic, Rail, Aviation, Tower Lights, Runway Lights, Emergency/Police Vehicle

Lighting.

Mobile applications with LEDs:

Mobile Phone, PDA's, Digital Cameras, Lap Tops, General Backlighting.

Photo sensor applications with LEDs

Medical Instrumentation, Bar Code Readers, Color & Money Sensors, Encoders, Optical

Switches, Fiber Optic Communication.

SWITCHES:

Introduction:

30

Page 24: Obstacle Detection and Avoidance Robot

A switch is a mechanical device used to connect and disconnect an electric circuit at

will. Switches cover a wide range of types, from subminiature up to industrial plant switching

megawatts of power on high voltage distribution lines.

In applications where multiple switching options are required (e.g., a telephone service),

mechanical switches have long been replaced by electronic switching devices which can be

automated and intelligently controlled.

The switch is referred to as a "gate" when abstracted to mathematical form. In the

philosophy of logic, operational arguments are represented as logic gates. The use of electronic

gates to function as a system of logical gates is the fundamental basis for the computer i.e. a

computer is a system of electronic switches which function as logical gates. A railroad switch is

not electrical, but a mechanical device to divert a train from one track to another.

Three tactile switches. Major scale is inches.

PASSIVE INFRARED SENSOR(PIR):

PIR Sensor Brief Introduction:

This PIR Sensor Switch Can Detect the Infrared Rays released by Human Body Motion within

the detection Area (14 Meters), and Start the Load - Light Automatically. This Unit is Suitable for

31

Page 25: Obstacle Detection and Avoidance Robot

Outdoor use (Corridor, Staircase, Courtyard etc.)

Electricity: It has been estimated that a single unit of energy saved at the end use point is equal to 2.3 units

of energy produced.

If energy efficient methods are implemented properly about 25000mw equivalent capacity of

power can be created through promotion of energy efficient measures.

PIR Sensor: A PIR Sensor is a Passive Infrared Sensor which controls the switching on/off of the

lighting load when it detects a moving target.

O The built in sensor turns on/off the connected lighting load when it detects motion in the

coverage area. It has different working principle during the day time and the night time.

O During the day, the built in photocell sensor saves electricity by deactivating the lighting load

connected to the sensor.

O During the night the connected lighting load is turned on by adjusting the luminosity knob

O An adjustable time knob lets you select how long the light stays on after activation.

Working Principle: -

O The PIR Sensor senses the motion of a human body by the change in surrounding ambient

temperature when a human body passes across.

O Then it turns on the lighting load to which it is connected.

32

Page 26: Obstacle Detection and Avoidance Robot

O The lighting load remains on until it senses motion.

O Once the motion is seized it switches off the lighting load.

O During the night, the LUX adjustment knob allows you to adjust the luminosity based on

which the lighting load will either switch on/off automatically.

Applications:

O Common toilets, for lights & exhaust fans

O Common staircases

O For parking lights

O For garden lights

O For changing rooms in shops

O For corridors & many more

Cost Effectiveness :In just Rs. 750 you save the most precious form of energy, electricity.

L293D DRIVER CIRCUIT

Introduction:

The L293 and L293D are quadruple high-current half-H drivers. The L293 is designed to

provide bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. The L293D is

designed to provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V.

Both devices are designed to drive inductive loads such as relays, solenoids, dc and bipolar

33

Page 27: Obstacle Detection and Avoidance Robot

stepping motors, as well as other high-current/high-voltage loads in positive-supply applications.

All inputs are TTL compatible. Each output is a complete totem-pole drive circuit, with a

Darlington transistor sink and a pseudo- Darlington source. Drivers are enabled in pairs, with

drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN. When an enable input is

high, the associated drivers are enabled, and their outputs are active and in phase with their

inputs. When the enable input is low, those drivers are disabled, and their outputs are off and in

the high-impedance state. With the proper data inputs, each pair of drivers forms a full-H (or

bridge) reversible drive suitable for solenoid or motor applications.

Features:

Featuring Unit rode L293 and L293D

Products Now From Texas Instruments

Wide Supply-Voltage Range: 4.5 V to 36 V

Separate Input-Logic Supply

Internal ESD Protection

Thermal Shutdown

High-Noise-Immunity Inputs

Functionally Similar to SGS L293 and SGS L293D

Output Current 1 A Per Channel(600 mA for L293D)

Peak Output Current 2 A Per Channel (1.2 A for L293D)

Output Clamp Diodes for Inductive Transient Suppression (L293D)

34

Page 28: Obstacle Detection and Avoidance Robot

Pin diagram:

Description:

On the L293, external high-speed output clamp diodes should be used for inductive

transient suppression. A VCC1 terminal, separate from VCC2, is provided for the logic inputs to

35

Page 29: Obstacle Detection and Avoidance Robot

minimize device power dissipation. The L293and L293D is characterized for operation from 0oC

to 70oC.

Block diagram:

36

Page 30: Obstacle Detection and Avoidance Robot

Logic diagram:

Applications:

Audio

Automotive

Broadband

Digital control

Military

Optical networking

Security

Telephony

Video & Imaging

Wire less

37

Page 31: Obstacle Detection and Avoidance Robot

POWER SUPPLY:

Power supply is a reference to a source of electrical power. A device or system that

supplies electrical or other types of energy to an output load or group of loads is called a power

supply unit or PSU. The term is most commonly applied to electrical energy supplies, less often

to mechanical ones, and rarely to others.

This power supply section is required to convert AC signal to DC signal and also to

reduce the amplitude of the signal. The available voltage signal from the mains is 230V/50Hz

which is an AC voltage, but the required is DC voltage (no frequency) with the amplitude of +5V

and +12V for various applications.

In this section we have Transformer, Bridge rectifier, are connected serially and voltage

regulators for +5V and +12V (7805 and 7812) via a capacitor (1000µF) in parallel are connected

parallel as shown in the circuit diagram below. Each voltage regulator output is again is

connected to the capacitors of values (100µF, 10µF, 1 µF, 0.1 µF) are connected parallel through

which the corresponding output (+5V or +12V) are taken into consideration.

38

Page 32: Obstacle Detection and Avoidance Robot

Circuit Explanation:

1) Transformer

A transformer is a device that transfers electrical energy from one circuit to another

through inductively coupled electrical conductors. A changing current in the first circuit (the

primary) creates a changing magnetic field; in turn, this magnetic field induces a changing

voltage in the second circuit (the secondary). By adding a load to the secondary circuit, one can

make current flow in the transformer, thus transferring energy from one circuit to the other.

The secondary induced voltage VS, of an ideal transformer, is scaled from the primary VP

by a factor equal to the ratio of the number of turns of wire in their respective windings:

39

Page 33: Obstacle Detection and Avoidance Robot

Basic principle:

The transformer is based on two principles: firstly, that an electric current can produce a

magnetic field (electromagnetism) and secondly that a changing magnetic field within a coil of

wire induces a voltage across the ends of the coil (electromagnetic induction). By changing the

current in the primary coil, it changes the strength of its magnetic field; since the changing

magnetic field extends into the secondary coil, a voltage is induced across the secondary.

A simplified transformer design is shown below. A current passing through the primary

coil creates a magnetic field. The primary and secondary coils are wrapped around a core of very

high magnetic permeability, such as iron; this ensures that most of the magnetic field lines

produced by the primary current are within the iron and pass through the secondary coil as well

as the primary coil.

Fig An ideal step-down transformer showing magnetic flux in the core

40

Page 34: Obstacle Detection and Avoidance Robot

Induction law:

The voltage induced across the secondary coil may be calculated from Faraday's law of

induction, which states that:

Where VS is the instantaneous voltage, NS is the number of turns in the secondary coil

and Φ equals the magnetic flux through one turn of the coil. If the turns of the coil are oriented

perpendicular to the magnetic field lines, the flux is the product of the magnetic field strength B

and the area A through which it cuts. The area is constant, being equal to the cross-sectional area

of the transformer core, whereas the magnetic field varies with time according to the excitation

of the primary. Since the same magnetic flux passes through both the primary and secondary

coils in an ideal transformer, the instantaneous voltage across the primary winding equals

Taking the ratio of the two equations for VS and VP gives the basic equation for stepping

up or stepping down the voltage

Ideal power equation:

If the secondary coil is attached to a load that allows current to flow, electrical

power is transmitted from the primary circuit to the secondary circuit. Ideally, the

transformer is perfectly efficient; all the incoming energy is transformed from the

primary circuit to the magnetic field and into the secondary circuit. If this condition is

met, the incoming electric power must equal the outgoing power.

Pincoming = IPVP = Poutgoing = ISVS

41

Page 35: Obstacle Detection and Avoidance Robot

Giving the ideal transformer equation

Pin-coming = IPVP = Pout-going = ISVS

Giving the ideal transformer equation

If the voltage is increased (stepped up) (VS > VP), then the current is decreased (stepped

down) (IS < IP) by the same factor. Transformers are efficient so this formula is a reasonable

approximation.

If the voltage is increased (stepped up) (VS > VP), then the current is decreased (stepped

down) (IS < IP) by the same factor. Transformers are efficient so this formula is a reasonable

approximation.

The impedance in one circuit is transformed by the square of the turns ratio. For

example, if an impedance ZS is attached across the terminals of the secondary coil, it appears to

the primary circuit to have an impedance of

42

Page 36: Obstacle Detection and Avoidance Robot

This relationship is reciprocal, so that the impedance ZP of the primary circuit appears to

the secondary to be

Detailed operation:

The simplified description above neglects several practical factors, in particular the

primary current required to establish a magnetic field in the core, and the contribution to the field

due to current in the secondary circuit.

Models of an ideal transformer typically assume a core of negligible reluctance with two

windings of zero resistance. When a voltage is applied to the primary winding, a small current

flows, driving flux around the magnetic circuit of the core. The current required to create the flux

is termed the magnetizing current; since the ideal core has been assumed to have near-zero

Reluctance, the magnetizing current is negligible, although still required to create the

magnetic field.

The changing magnetic field induces an electromotive force (EMF) across each winding.

Since the ideal windings have no impedance, they have no associated voltage drop, and so the

voltages VP and VS measured at the terminals of the transformer, are equal to the corresponding

EMFs. The primary EMF, acting as it does in opposition to the primary voltage, is sometimes

termed the "back EMF". This is due to Lenz's law which states that the induction of EMF would

always be such that it will oppose development of any such change in magnetic field.

1) Bridge Rectifier

A diode bridge or bridge rectifier is an arrangement of four diodes in a bridge

configuration that provides the same polarity of output voltage for any polarity of input voltage.

43

Page 37: Obstacle Detection and Avoidance Robot

When used in its most common application, for conversion of alternating current (AC) input into

direct current (DC) output, it is known as a bridge rectifier. A bridge rectifier provides full-wave

rectification from a two-wire AC input, resulting in lower cost and weight as compared to a

center-tapped transformer design, but has two diode drops rather than one, thus exhibiting

reduced efficiency over a center-tapped design for the same output voltage.

Basic Operation:

When the input connected at the left corner of the diamond is positive with respect to the

one connected at the right hand corner, current flows to the right along the upper colored path to

the output, and returns to the input supply via the lower one.

When the right hand corner is positive relative to the left hand corner, current flows along

the upper colored path and returns to the supply via the lower colored path.

44

Page 38: Obstacle Detection and Avoidance Robot

In each case, the upper right output remains positive with respect to the lower right one.

Since this is true whether the input is AC or DC, this circuit not only produces DC power when

supplied with AC power: it also can provide what is sometimes called "reverse polarity

protection". That is, it permits normal functioning when batteries are installed backwards or DC

input-power supply wiring "has its wires crossed" (and protects the circuitry it powers against

damage that might occur without this circuit in place).

Prior to availability of integrated electronics, such a bridge rectifier was always

constructed from discrete components. Since about 1950, a single four-terminal component

containing the four diodes connected in the bridge configuration became a standard commercial

component and is now available with various voltage and current ratings.

45

Page 39: Obstacle Detection and Avoidance Robot

Output smoothing (Using Capacitor):

For many applications, especially with single phase AC where the full-wave bridge

serves to convert an AC input into a DC output, the addition of a capacitor may be important

because the bridge alone supplies an output voltage of fixed polarity but pulsating magnitude

(see diagram above).

46

Page 40: Obstacle Detection and Avoidance Robot

The function of this capacitor, known as a reservoir capacitor (aka smoothing capacitor)

is to lessen the variation in (or 'smooth') the rectified AC output voltage waveform from the

bridge. One explanation of 'smoothing' is that the capacitor provides a low impedance path to the

AC component of the output, reducing the AC voltage across, and AC current through, the

resistive load. In less technical terms, any drop in the output voltage and current of the bridge

tends to be cancelled by loss of charge in the capacitor.

This charge flows out as additional current through the load. Thus the change of load

current and voltage is reduced relative to what would occur without the capacitor. Increases of

voltage correspondingly store excess charge in the capacitor, thus moderating the change in

output voltage / current. Also see rectifier output smoothing.

The simplified circuit shown has a well deserved reputation for being dangerous,

because, in some applications, the capacitor can retain a lethal charge after the AC power source

is removed. If supplying a dangerous voltage, a practical circuit should include a reliable way to

safely discharge the capacitor. If the normal load cannot be guaranteed to perform this function,

perhaps because it can be disconnected, the circuit should include a bleeder resistor connected as

close as practical across the capacitor. This resistor should consume a current large enough to

discharge the capacitor in a reasonable time, but small enough to avoid unnecessary power

waste.

Because a bleeder sets a minimum current drain, the regulation of the circuit, defined as

percentage voltage change from minimum to maximum load, is improved. However in many

cases the improvement is of insignificant magnitude.

The capacitor and the load resistance have a typical time constant τ = RC where C and R

are the capacitance and load resistance respectively. As long as the load resistor is large enough

so that this time constant is much longer than the time of one ripple cycle, the above

configuration will produce a smoothed DC voltage across the load.

In some designs, a series resistor at the load side of the capacitor is added. The smoothing

can then be improved by adding additional stages of capacitor–resistor pairs, often done only for

sub-supplies to critical high-gain circuits that tend to be sensitive to supply voltage noise.

47

Page 41: Obstacle Detection and Avoidance Robot

The idealized waveforms shown above are seen for both voltage and current when the

load on the bridge is resistive. When the load includes a smoothing capacitor, both the voltage

and the current waveforms will be greatly changed. While the voltage is smoothed, as described

above, current will flow through the bridge only during the time when the input voltage is greater

than the capacitor voltage. For example, if the load draws an average current of n Amps, and the

diodes conduct for 10% of the time, the average diode current during conduction must be 10n

Amps. This non-sinusoidal current leads to harmonic distortion and a poor power factor in the

AC supply.

In a practical circuit, when a capacitor is directly connected to the output of a bridge, the

bridge diodes must be sized to withstand the current surge that occurs when the power is turned

on at the peak of the AC voltage and the capacitor is fully discharged. Sometimes a small series

resistor is included before the capacitor to limit this current, though in most applications the

power supply transformer's resistance is already sufficient.

Output can also be smoothed using a choke and second capacitor. The choke tends to

keep the current (rather than the voltage) more constant. Due to the relatively high cost of an

effective choke compared to a resistor and capacitor this is not employed in modern equipment.

Some early console radios created the speaker's constant field with the current from the

high voltage ("B +") power supply, which was then routed to the consuming circuits, (permanent

magnets were considered too weak for good performance) to create the speaker's constant

magnetic field. The speaker field coil thus performed 2 jobs in one: it acted as a choke, filtering

the power supply, and it produced the magnetic field to operate the speaker.

2) Voltage Regulator

A voltage regulator is an electrical regulator designed to automatically maintain a

constant voltage level.

The 78xx (also sometimes known as LM78xx) series of devices is a family of self-

contained fixed linear voltage regulator integrated circuits. The 78xx family is a very popular

choice for many electronic circuits which require a regulated power supply, due to their ease of

48

Page 42: Obstacle Detection and Avoidance Robot

use and relative cheapness. When specifying individual ICs within this family, the xx is replaced

with a two-digit number, which indicates the output voltage the particular device is designed to

provide (for example, the 7805 has a 5 volt output, while the 7812 produces 12 volts). The 78xx

line is positive voltage regulators, meaning that they are designed to produce a voltage that is

positive relative to a common ground. There is a related line of 79xx devices which are

complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to

provide both positive and negative supply voltages in the same circuit, if necessary.

78xx ICs have three terminals and are most commonly found in the TO220 form factor,

although smaller surface-mount and larger TrO3 packages are also available from some

manufacturers. These devices typically support an input voltage which can be anywhere from a

couple of volts over the intended output voltage, up to a maximum of 35 or 40 volts, and can

typically provide up to around 1 or 1.5 amps of current (though smaller or larger packages may

have a lower or higher current rating).

CHAPTER 5

SOFTWARE IMPLEMENTATION

Keil Software:

Installing the Keil software on a Windows PC

Insert the CD-ROM in your computer’s CD drive

On most computers, the CD will “auto run”, and you will see the Keil installation menu.

If the menu does not appear, manually double click on the Setup icon, in the root

directory: you will then see the Keil menu.

On the Keil menu, please select “Install Evaluation Software”. (You will not require a

license number to install this software).

Follow the installation instructions as they appear.

49

Page 43: Obstacle Detection and Avoidance Robot

Loading the Projects:

The example projects for this book are NOT loaded automatically when you install the Keil

compiler.

These files are stored on the CD in a directory “/Pont”. The files are arranged by chapter: for

example, the project discussed in Chapter 3 is in the directory “/Pont/Ch03_00-Hello”.

Rather than using the projects on the CD (where changes cannot be saved), please copy the files

from CD onto an appropriate directory on your hard disk.

Note: You will need to change the file properties after copying: file transferred from the CD will

be ‘read only’.

Configuring the Simulator:

Open the Keil Vision2

Go to Project – Open Project and browse for Hello in Ch03_00 in Pont and open it.

50

Page 44: Obstacle Detection and Avoidance Robot

Go to Project – Select Device for Target ‘Target1’

Select 8051(all variants) and click OK

51

Page 45: Obstacle Detection and Avoidance Robot

Now we need to check the oscillator frequency:

52

Page 46: Obstacle Detection and Avoidance Robot

Go to project – Options for Target ‘Target1’

Make sure that the oscillator frequency is 12MHz.

53

Page 47: Obstacle Detection and Avoidance Robot

Building the Target:

Build the target as illustrated in the figure below

54

Page 48: Obstacle Detection and Avoidance Robot

Running the Simulation:

Having successfully built the target, we are now ready to start the debug session and run

the simulator.

First start a debug session

The flashing LED we will view will be connected to Port 1. We therefore want to observe the

activity on this port

55

Page 49: Obstacle Detection and Avoidance Robot

To ensure that the port activity is visible, we need to start the ‘periodic window update’ flag

56

Page 50: Obstacle Detection and Avoidance Robot

Go to Debug - Go

57

Page 51: Obstacle Detection and Avoidance Robot

While the simulation is running, view the performance analyzer to check the delay durations.

58

Page 52: Obstacle Detection and Avoidance Robot

Go to Debug – Performance Analyzer and click on it

59

Page 53: Obstacle Detection and Avoidance Robot

Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button

60

Page 54: Obstacle Detection and Avoidance Robot

CHAPTER 6

RESULT ANALYSYS

When a obstacle comes the Robot changes its direction

61

Page 55: Obstacle Detection and Avoidance Robot

REFERENCES

1. Microprocessors and Microcontroller by A.K.RAY

2. The 8051 Microcontroller and Embedded Systems by MUHAMMAD ALI

MAZIDI

3. Fundamentals of Embedded Software by DANIEL W LEWIS

4. Programing and Customize the Microcontroller by MYKE PREBKO

5. Programing and Customize the AVR by DHANANJAY and V.GADRE

6. www.electronicsforu.com

7. www.futurelec.com

8. www.uctros.com

62