65
OBSTACLE DETECTION BASED ROBOT USING IR SENSORS A Mini Project report submitted in Partial fulfillment of the requirements For the award of degree of BACHELOR OF TECHNOLOGY In ELECTRONICS AND COMMUNICATION ENGINEERING By Under the esteemed guidance of Prof. M.V.H.BHASKARA MURTHY M.Tech (Ph.D) Department of E.C.E S.RAMAKRISHNA SAI V.CH.PAVAN KUMAR PATNAIK (08MP1A0450) (08MP1A0457) 1

Obstacle Detection Based Robot

Embed Size (px)

Citation preview

Page 1: Obstacle Detection Based Robot

OBSTACLE DETECTION BASED ROBOT

USING IR SENSORS

A Mini Project report submitted in

Partial fulfillment of the requirements

For the award of degree of

BACHELOR OF TECHNOLOGY

In

ELECTRONICS AND COMMUNICATION ENGINEERING

By

Under the esteemed guidance of

Prof. M.V.H.BHASKARA MURTHY M.Tech (Ph.D)

Department of E.C.E

S.RAMAKRISHNA SAI V.CH.PAVAN KUMAR PATNAIK

(08MP1A0450) (08MP1A0457)

L.HARISANKAR P.GANESH

(08MP1A0433) (08MP1A0439)

1

Page 2: Obstacle Detection Based Robot

SRI VAISHNAVI COLLEGE OF ENGINEERING

SINGUPURAM, SRIKAKULAM, ANDHRA PRADESH.

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

2011

CERTIFICATE

This is to certify that the mini project work entitled “OBSTACLE

DETECTION BASED ROBOT USING IR SENSORS”, is a bonafide work done by

S.RAMAKRISHNA SAI, V.CH.PAVAN KUMAR PATNAIK, L.HARISANKAR,

P.GANESH submitted in partial fulfilment of the requirements for the award of the degree of

BACHELOR OF TECHNOLOGY in ELECTRONICS AND COMMUNICATION

ENGINEERING.

UNDERGUIDENCE HEAD OF THE DEPARTMENT, E.C.E

M.V.H.BHASKARA MURTHY M.V.H.BHASKARA MURTHY

2

Page 3: Obstacle Detection Based Robot

ACKNOWLEDGEMENT

This report would be incomplete without the mention of those who have directly or

indirectly helped us during the tenure of this project.

We would like to thank Dr.L.S.SASTRY, Principal, SRI VAISHNAVI COLLEGE

OF ENGINEERING for having permitted us to take up this project.

We would also like to express our deepest sense of gratitude towards

Prof.M.V.H.BHASKARA MURTHY, Head of the Department, Electronics and

communication Engineering, Sri Vaishnavi College of Engineering and Sri

T.MANIKYALA RAO, the Project coordinator, E.C.E Department, Sri Vaishnavi

College of Engineering for their invaluable help during this project. Their guidance has been

instrumental and has proved to be of immense help at every stage of the project.

We would like to thank our guide Sri M.V.H.BHASKARA MURTHY , Head of

the Department, Electronics and communication Engineering, Sri Vaishnavi College of

Engineering for constantly monitoring our progress and suggesting improvements at various

stages in the project

We would like to thank all the other staff members of Electronics and

communication Engineering Department, Sri Vaishnavi College of Engineering for

Co-operating with us all through the period of project.

Lastly, we would like to thank everyone who has been involved in the progress of the

project, whose contributions, have added a lot of value.

3

Page 4: Obstacle Detection Based Robot

ABSTRACT

In robotics, obstacle avoidance is the task of satisfying some control objective subject

to non-intersection or non-collision position of constraints. Normally obstacle avoidance is

considered to be distinct from path planning in that one is usually implemented as a reactive

control which a controller will then guide a robot along.

Whenever robot senses any obstacle automatically diverts its position to left/right and

follows the path. Robot consists of two motors, which control the side pair wheels of each

and help in moving forward and backward direction. It senses the object with help of obstacle

sensor. IR pair is used for detecting the obstacle.

In this project we develop a robot such that it will be moving according to path

assigned to it if at all there is any obstacle in between then the robot stops and change its

direction. This sort of project is very much useful in the industries where the automated

supervision is required.

Hardware specification are Regulated power supply, AVR Series Micro controller, IR

sensor, DC Motor. Software tools are WINAVR to compile the source file and generate the

hexadecimal code, AVR Studio 4.18.

This robot can be applied at the toys where children will play. ROBOT can be used

for the army application by fixing a cam to it. We can apply number of IR pairs for the safe

direction control. This project is considered to be the key link to the 3rd generation of

robotics.

4

Page 5: Obstacle Detection Based Robot

LIST OF FIGURES

Figure number Name Page number

BLOCK DIAGRAM OF THE PROJECT

Figure1.1 Block diagram of Embedded System

Figure 1.2 Basic Layout of Microcontroller

Figure 2.1 Block Diagram of Microcontroller-ATMEGA8

Figure 2.2 Architecture of ATMEGA8

Figure 2.3 Pin Diagram of ATMEGA8

Figure 2.4 A simple 5V DC Regulated Power Supply System

Figure 2.5 Step down transformer

Figure 2.6 Dc Motor

Figure 2.7 Parts of Dc motor

Figure 2.8 Basic Commutator

Figure 2.9 A Simple Electric Motor

Figure 2.10 DC Motor Rotations vs. Polarity

Figure 2.11 Obstacle Sensor

Figure 2.12 Circuit Diagram of Obstacle Sensor

Figure 3.1 Electromagnetic Spectrum

Figure 3.2 A radio frequency energy wave superimposed

upon an infrared energy wave

5

Page 6: Obstacle Detection Based Robot

Contents

Chapter1. Embedded Systems

1.1 Introduction

1.2 Examples of Embedded Systems

1.3 Microcontrollers and Microprocessors

1.4 Typical Microcontroller Architecture and Features

1.5 The UART: What it is and how it works

1.5.1 Synchronous Serial Transmission

1.5.2 Asynchronous Serial Transmission

Chapter2. Hardware

2.1 Microcontroller (ATMEGA8)

2.1.1 Features

2.1.2 AVR Description

2.1.3 Architecture

2.1.4 Pin Diagram

2.1.5 Pin Description

2.2 Power Supply

2.2.1 Step down Transformer

2.2.2 Rectifier Unit

2.2.3 Filter

2.2.4 Regulator Unit

2.3 Motors

2.3.1 Definition

2.3.2 Dc Motor

2.3.3 Principle

2.3.4 Construction

2.3.5 Working of Dc Motor

2.3.6 Advantages and Disadvantages

6

Page 7: Obstacle Detection Based Robot

2.4 Obstacle Sensor

2.4.1 Circuit of Obstacle Sensor

2.4.2 Features

2.4.3 Applications

Chapter3. Software (AVR STUDIO)

3.1 Introduction

3.2 Why AVR?

3.3 WINAVR

3.3.1 Compiler

3.4 AVRISP2

3.4.1 Features

Chapter4. Infrared Technology

4.1 Introduction

4.2 Wireless Communication

4.3 Infrared Technology

4.4 IR Advantages

4.5 IR Disadvantages

4.6 Health Risks

4.7 Security

4.8 Importance of Standards

Chapter5. Code

Chapter6. Applications and Result

6.1 Applications

6.2 Result

Chapter7. Future Aspects and Conclusion

7.1 Future Aspects

7.2 Conclusion

References

7

Page 8: Obstacle Detection Based Robot

Introduction

A robot obstacle detection system comprising: a robot housing which navigates with

respect to a surface; a sensor subsystem having a defined relationship with respect to the

housing and aimed at the surface for detecting the surface, the sensor subsystem including: an

optical emitter which emits a directed beam having a defined field of emission, and a photon

detector having a defined field of view which intersects the field of emission of the emitter at

a finite region; and a circuit in communication with the detector for redirecting the robot

when the surface does not occupy the region to avoid obstacles. 

Obstacle sensors are nothing but the IR pair. As the transmitter part travel IR rays

from to receiver here also transmitter send the data receiver but these IR pair are places

beside each other. So whenever the obstacle sensor found an obstacle in between its way the

IR rays reflects in a certain angle.

BLOCK DIAGRAM:

POWER SUPPLY:

Power supply can be broken down into a series of blocks, each of which performs a

particular function. The transformer is 230v AC supply. Transformers work only with AC

8

Page 9: Obstacle Detection Based Robot

and here we are using step down transformer because to step down high voltage AC mains to

low voltage AC (i.e.; 230v to12v). This transformer is fed into rectifier.

In bridge rectifier there are several ways of connecting diodes to make a rectifier to

convert AC to DC and it is most important and it produces full-wave with varying DC so that

we go for smoothing capacitor it smooth the DC from varying greatly to a small ripple. By

using regulator we can eliminate the ripple. In regulator to set DC output to a fixed voltage.

MICRO CONTROLLER:

Here we are using ATMEGA8 microcontroller. This is used to control all the

operations of a circuit to get the accurate result. The micro controller we use is of the 28 pins

and of 3 ports.

DC MOTOR:

Motors are used for the movement of the robot. Here we use the dc motor as it has

the principle of the speed controlling.

OBSTACLE SENSOR:

The obstacle senor is used avoiding the robot from the clash to any external devices or

any obstacle which comes in its way. Here we are using the IR communications the

transmitter and the receiver parts. The transmitter produces the IR rays and they are received

by the receiver section.

9

Page 10: Obstacle Detection Based Robot

Chapter 1

Embedded Systems

1.1 Introduction

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

dedicated function. An embedded system performs one or few pre-defined tasks usually with

very specific requirements and often includes task-specific hardware and mechanical parts

not usually found in a general-purpose computer. Since the system is dedicated to specific

tasks, design engineers can optimize it by reducing the size and cost of the product.

Physically, the 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. In terms of complexity embedded systems run with

a single microcontroller chip to very complex with multiple units, peripherals and networks

mounted inside a large chassis or enclosure.

Mobile phones or handheld computers share some elements with embedded systems,

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

embedded systems themselves because they tend to be more general purpose allowing

different applications to be loaded and peripherals to be connected.

As the embedded system is the combination of both software and hardware .Software

deals with the languages like WINAVR, C, and VB etc., and Hardware deals with Processors,

Peripherals, and Memory.

Memory: It is used to store data or address.

Peripherals: These are the external devices connected

Processor: It is an IC which is used to perform some task

Processors are classified into four types like:

1. Micro Processor (µp)

2. Micro controller (µc)

3. Digital Signal Processor (DSP)

10

Page 11: Obstacle Detection Based Robot

Embedded System

Software Hardware

WINAVRCVB Etc.,

ProcessorPeripheralsmemory

4. Application Specific Integrated Circuits (ASIC)

Figure1.1 Block diagram of Embedded System

1.2 Examples of Embedded Systems

An embedded system typically has a specialized function with programs stored on

ROM. Examples of embedded systems are chips that monitor automobile functions, including

engine controls, antilock brakes, air bags, active suspension systems, environmental systems,

security systems, and entertainment systems. Everything needed for those functions is custom

designed into specific chips. No external operating system is required.

Another example is a chip for a microwave oven. It is specifically designed to run the

front-panel controls and all the timing and electronics of the oven.

Network managers will need to manage more and more embedded systems devices,

ranging from printers to scanners, to handheld computing devices, to cell phones. All of these

have a need to connect with other devices, either directly or through a wireless or direct-

connect network. Most will have custom operating systems or variations of existing operating

systems (e.g., Microsoft Windows CE).

It's easy to picture nearly every electronic device as having an embedded system. For

example, refrigerators, washing machines, and even coffee brewers will benefit in some way

11

Page 12: Obstacle Detection Based Robot

from embedded systems. A critical feature of an embedded system is its ability to

communicate, so embedded systems support Ethernet, Bluetooth (wireless), infrared, or other

technologies.

A weather station on top of a building may employ an embedded system that gathers

information from external sensors. This information can be pushed or pulled. In the push

scenario, the data is automatically sent to devices that have requested it. In the pull scenario,

users or network devices access the weather station to read the latest information.

If the weather station is connected to the Internet, it may have its own IP address and,

ideally, will provide information to anyone that accesses the IP address. In this sense, the

weather station is acting as a mini-Web server. In fact, many embedded systems are basically

Web servers on a chip. The chips contain HTTP and HTML functions, and custom

applications appropriate for the environment in which the chip will be used.

1.3 Microcontrollers and Microprocessors

A microcontroller (or MCU) is a computer-on-a-chip. It is a type of microprocessor

emphasizing self-sufficiency and cost-effectiveness, in contrast to a general-purpose

microprocessor (the kind used in a PC).

A microprocessor is a programmable digital electronic component that incorporates

the functions of a central processing unit (CPU) on a single semi conducting integrated circuit

(IC). The microprocessor was born by reducing the word size of the CPU from 32 bits to 4

bits, so that the transistors of its logic circuits would fit onto a single part. One or more

microprocessors typically serve as the CPU in a computer system, embedded system, or

handheld device.

1.4 Typical Microcontroller Architecture and Features

The basic internal designs of microcontrollers are pretty similar. Figure 1.2, the block

diagram of a typical microcontroller. All components are connected via an internal bus and

are all integrated on one chip. The modules are connected to the outside world via I/O pins.

12

Page 13: Obstacle Detection Based Robot

Figure 1.2 Basic Layout of Microcontroller

The following list contains the modules typically found in a microcontroller. You can

find a more detailed description of these components in later sections.

Processor Core: The CPU of the controller. It contains the arithmetic logic unit, the control

unit, and the registers (stack pointer, program counter, accumulator register, register file . . .).

Memory: The memory is sometimes split into program memory and data memory. In larger

controllers, a DMA controller handles data transfers between peripheral components and the

memory.

Interrupt Controller: Interrupts are useful for interrupting the normal program flow in case

of (important) external or internal events. In conjunction with sleep modes, they help to

conserve power.

Timer/Counter: Most controllers have at least one and more likely 2-3 Timer/Counters,

which can be used to timestamp events, measure intervals, or count events. Many controllers

also contain PWM (pulse width modulation) outputs, which can be used to drive motors or

for safe breaking (antilock brake system, ABS). Furthermore the PWM output in conjunction

with an external filter be used to realize a cheap digital/analog converter.

Digital I/O: Parallel digital I/O ports are one of the main features of microcontrollers. The

number of I/O pins varies from 3-4 to over 90, depending on the controller family and the

controller type.

13

Page 14: Obstacle Detection Based Robot

Analog I/O: Apart from a few small controllers, most microcontrollers have integrated

analog/digital converters, which differ in the number of channels (2-16) and their resolution

(8-12 bits). The analog module also generally features an analog comparator. In some cases,

the microcontroller includes digital/analog converters.

1.5 The UART: What it is and how it works

The Universal Asynchronous Receiver/Transmitter (UART) controller is the key

component of the serial communications subsystem of a computer. The UART takes bytes of

data and transmits the individual bits in a sequential fashion. At the destination, a second

UART re-assembles the bits into complete bytes.

Serial transmission is commonly used with modems and for non-networked

communication between computers, terminals and other devices.

There are two primary forms of serial transmission: Synchronous and Asynchronous.

Depending on the modes that are supported by the hardware, the name of the communication

sub-system will usually include A if it supports Asynchronous communications and S if it

supports Synchronous communications. Both forms are described below.

Some common acronyms are:

UART Universal Asynchronous Receiver/Transmitter

USART Universal Synchronous-Asynchronous Receiver/Transmitter

1.5.1 Synchronous Serial Transmission

Synchronous serial transmission requires that the sender and receiver share a clock

with one another, or that the sender provide a strobe or other timing signal so that the receiver

knows when to “read” the next bit of the data. In most forms of serial Synchronous

communication, if there is no data available at a given instant to transmit, a fill character must

be sent instead so that data is always being transmitted. Synchronous communication is

usually more efficient because only data bits are transmitted between sender and receiver, and

synchronous communication can be more costly if extra wiring and circuits are required to

share a clock signal between the sender and receiver.

14

Page 15: Obstacle Detection Based Robot

A form of Synchronous transmission is used with printers and fixed disk devices in

that the data is sent on one set of wires while a clock or strobe is sent on a different wire.

Printers and fixed disk devices are not normally serial devices because most fixed disk

interface standards send an entire word of data for each clock or strobe signal by using a

separate wire for each bit of the word. In the PC industry, these are known as Parallel

devices.

The standard serial communications hardware in the PC does not support

Synchronous operations. This mode is described here for comparison purposes only.

1.5.2 Asynchronous Serial Transmission

Asynchronous transmission allows data to be transmitted without the sender having to

send a clock signal to the receiver. Instead, the sender and receiver must agree on timing

parameters in advance and special bits are added to each word which is used to synchronize

the sending and receiving units.

When a word is given to the UART for Asynchronous transmissions, a bit called the

"Start Bit" is added to the beginning of each word that is to be transmitted. The Start Bit is

used to alert the receiver that a word of data is about to be sent, and to force the clock in the

receiver into synchronization with the clock in the transmitter. These two clocks must be

accurate enough to not have the frequency drift by more than 10% during the transmission of

the remaining bits in the word. (This requirement was set in the days of mechanical

teleprinters and is easily met by modern electronic equipment.)

After the Start bit, the individual bits of the word of data are sent with the Least

Significant Bit (LSB) being sent first. Each bit in the transmission is transmitted for exactly

the same amount of time as all of the other bits, and the receiver “looks” at the wire at

approximately halfway through the period assigned to each bit to determine if the bit is a 1 or

a 0. For example, if it takes two seconds to send each bit, the receiver will examine the signal

to determine if it is a 1 or a 0 after one second has passed, then it will wait two seconds and

then examine the value of the next bit, and so on.

The sender does not know when the receiver has “looked” at the value of the bit. The

sender only knows when the clock says to begin transmitting the next bit of the word. When

15

Page 16: Obstacle Detection Based Robot

the entire data word has been sent, the transmitter may add a Parity Bit that the transmitter

generates. The Parity Bit may be used by the receiver to perform simple error checking. Then

at least one Stop Bit is sent by the transmitter.

When the receiver has received all of the bits in the data word, it may check for the

Parity Bits (both sender and receiver must agree on whether a Parity Bit is to be used), and

then the receiver looks for a Stop Bit. If the Stop Bit does not appear when it is supposed to,

the UART considers the entire word to be garbled and will report a Framing Error to the host

processor when the data word is read. The usual cause of a Framing Error is that the sender

and receiver clocks were not running at the same speed, or that the signal was interrupted.

Regardless of whether the data was received correctly or not, the UART automatically

discards the Start, Parity and Stop bits. If the sender and receiver are configured identically,

these bits are not passed to the host.

If another word is ready for transmission, the Start Bit for the new word can be sent as

soon as the Stop Bit for the previous word has been sent because asynchronous data is “self

synchronizing”, if there is no data to transmit, the transmission line can be idle.

16

Page 17: Obstacle Detection Based Robot

Chapter 2

Hardware

Hardware Modules:

The Hardware modules of this project:

Microcontroller Power Supply unit Motors Obstacle Sensor

2.1 Microcontroller (Atmega8):

Microprocessors and microcontrollers step from basic idea.Most microprocessors

have many operational codes (opcodes) for moving data from external memory to the CPU.

The microprocessor is concerned with rapid movment of code and data from external

addresses to the chip.The microcontroller is concerned with the rapid movment of bits within

the chip.The microcontroller can function as a computer with the addition of no external

digital parts.

2.1.1 Features:

High-performance, Low-power AVR 8-bit Microcontroller.

Advanced RISC Architecture

130 Powerful Instructions – Most Single-clock Cycle Execution – 32 x 8

General Purpose Working Registers

Fully Static Operation

Up to 16 MIPS Throughput at 16 MHz – On-chip 2-cycle

Multiplier.

High Endurance Non-volatile Memory segments.

8K Bytes of In-System Self-programmable Flash program memory

– 512 Bytes EEPROM ,1K Byte Internal SRAM

Write/Erase Cycles: 10,000 Flash/100,000 EEPROM –

Data retention: 20 years at 85°C/100 years at 25°C

Optional Boot Code Section with Independent Lock Bits

In-System Programming by On-chip Boot Program.

True Read-While-Write Operation.

17

Page 18: Obstacle Detection Based Robot

Programming Lock for Software Security.

Peripheral Features.

One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture

Mode

Real Time Counter with Separate Oscillator – Three PWM Channels

8-channel ADC in TQFP and QFN/MLF package

6-channel ADC in PDIP package Six

Channels10-bit Accuracy Byte-oriented

Two-wire Serial Interface – Programmable

Serial USART

Programmable Watchdog Timer with Separate On-chip Oscillator

– On-chip Analog Comparator

Special Microcontroller Features

Power-on Reset and Programmable Brown-out

Detection – Internal Calibrated RC Oscillator

External and Internal Interrupt Sources

Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-

down, and Standby

I/O and Packages

23 Programmable I/O Lines

28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF

Operating Voltages

2.7 - 5.5V (ATmega8L)

4.5-5.5V (ATmega8)

Power Consumption at 4 MHz, 3V, 25C

Active: 3.6 mA

Idle Mode: 1.0 mA

Power-down Mode: 0.5 µA

2.1.2 A.V.R Description:

18

Page 19: Obstacle Detection Based Robot

The AVR core combines a rich instruction set with 32 general purpose working

registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU),

allowing two independent registers to be accessed in one single instruction executed in one

clock cycle. The resulting architecture is more code efficient while achieving throughputs up

to ten times faster than conventional CISC microcontrollers.

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

technology. The Flash Program memory can be reprogrammed In-System through an SPI

serial interface by a conventional non-volatile memory programmer or by an On-chip boot

program running on the AVR core. By combining an 8-bit RISC CPU with In-System Self-

Programmable Flash on a monolithic chip, the Atmel ATmega8 is a powerful microcontroller

that provides a highly-flexible and cost-effective solution to many embedded control

applications.

The ATmega8 AVR is supported with a full suite of program and system

development tools, including C compilers, macro assemblers, program debugger/simulators,

In-Circuit Emulators, and evaluation kits.

BLOCK DIAGRAM:

Figure 2.1 Block Diagram of Microcontroller-ATMEGA8

2.1.3 Architecture:

19

Page 20: Obstacle Detection Based Robot

Figure 2.2 Architecture of ATMEGA8

2.1.4 PinDiagram:

20

Page 21: Obstacle Detection Based Robot

Figure 2.3 Pin Diagram of ATMEGA8

2.1.5 Pin Description

VCC Digital supply voltage.

GND Ground.AREF AREF is the analog reference pin for the A/D Converter

ADC7.6 In the TQFP and QFN/MLF package, ADC7..6 serve as analog inputs to the A/D converter These pins are powered from the analog supply and serve as 10-bit ADC channel

AVCC

AVCC is the supply voltage pin for the A/D Converter, Port C (3.0), and

ADC (7.6). It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that Port C (5.4) use digital supply voltage, VCC.

RESET It is input. A low level on this pin for longer than minimum pulse

21

Page 22: Obstacle Detection Based Robot

generates input.

Port B (PB7..PB0)

XTAL1/XTAL2/TOSC1/TOS2

Port B is an 8-bit bi-directional I/O port with internal pull-up resistors

(selected for each bit). Port B output buffers have symmetrical drive

characteristics with both high sink and source capability. As inputs,

Port B pins that are externally pulled low will source current if the pull-

up resistors are activated. The Port B pins are tri-stated when a reset

condition becomes active, even if the clock is not running .Depending

on the clock selection fuse settings, PB6 can be used as input to the

inverting.

Port C (PC5..PC0)

PC6/RESET

Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin

Port D (PD7..PD0) Port C output buffers have symmetrical drive characteristics with both high sink and source

2.2 POWER SUPPLY:

Power supply block consists of following units:

Step down transformer

Bridge rectifier circuit

Filter

Voltage regulators

Figure 2.4 A simple 5V DC Regulated Power Supply System

22

Page 23: Obstacle Detection Based Robot

2.2.1 Step Down Transformer:

The step-down transformer is used to step down the supply voltage of 230v ac from

mains to lower values as the various IC’s used in this project require reduced voltages. 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 outputs

from the secondary coil which is centre tapped are the ac values of 0v and 12v. The

conversion of these ac values to dc values is done using the full wave rectifier.

Figure 2.5 Step down transformer

2.2.2 Rectifier Unit:

A bridge rectifier is an arrangement of four diodes connected in a circuit. That

provides the polarity of output voltage of any polarity of the input voltage. When used in

its most common application, for conversion of alternating current (A.C) input into direct

current (D.C) output, it is known as a bridge rectifier. The diagram describes a diode-

bridge design known as a full wave rectifier. This design can be used to rectify single

phase A.C. when no transformer centre tap is available. A bridge rectifier makes use of

four diodes in a bridge arrangement to achieve full wave rectification. This is a widely

used configuration, both with individual diodes wired as shown and with single

component bridges where the diode bridge is wired internally.

For both positive and negative swings of the transformer, there is a forward path

through the diode bridge. Both conduction paths cause current to flow in the same

direction through the load resister, accomplishing full-wave rectification. While one set of

diodes is forward biased, the other set is reverse biased and effectively eliminated from the

circuit.

23

Page 24: Obstacle Detection Based Robot

2.2.3 Filter:

Capacitors are used as filters. The ripples from the dc voltages are removed and pure

dc voltage is obtained. 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.

2.2.4 Regulator unit:

Regulator regulates the output voltage to a specific value. The output voltage is

maintained irrespective of the fluctuations in the input dc voltage. Whenever there are any

ac voltage fluctuations, the dc voltage also changes, and to avoid this regulators are used.

2.3 Motors

2.3.1 DEFINITION:

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

electrical motor or an internal combustion engine.

It may also refer to:

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

o AC motor, an electric motor that is driven by alternating current

Synchronous motor, an alternating current motor distinguished by a

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

alternating current and resulting magnetic field which drives it

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

asynchronous alternating current motor where power is supplied to the

rotating device by means of electromagnetic induction

o DC motor, an electric motor that runs on direct current electricity

Brushed DC electric motor, an internally commutated electric motor

designed to be run from a direct current power source

Brushless DC motor, a synchronous electric motor which is powered

by direct current electricity and has an electronically controlled

24

Page 25: Obstacle Detection Based Robot

commutation system, instead of a mechanical commutation system

based on brushes

o Electrostatic motor, a type of electric motor based on the attraction and

repulsion of electric charge

o Servo motor, an electric motor that operates a servo, commonly used in

robotics.

2.3.2 DC Motor

A DC motor is an electromechanical device that converts electrical energy into

mechanical energy that can be used to do many useful works. DC motors comes in various

ratings like 6V and 12V. It has two wires or pins. When connected with power supply the

shaft rotates. You can reverse the direction of rotation by reversing the polarity of input.

Figure 2.6 Dc Motor

Motor gives power to your MCU. Means power to do physical works, for example

move your robot. So it is essential to know how to control a DC motor effectively with a

MCU. We can control a DC motor easily with microcontrollers. We can start it, stop it or

make it go either in clockwise or anti clock wise direction. We can also control its speed but

it will be covered in latter tutorial. The design of the brushed DC motor is quite simple.

Permanent magnets

Electro-magnetic windings

2.3.3 Principle

When a rectangular coil carrying current is placed in a magnetic field, a torque acts on

the coil which rotates it continuously. When the coil rotates, the shaft attached to it also

rotates and thus it is able to do mechanical work.

25

Page 26: Obstacle Detection Based Robot

Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator,

commutator, field magnet(s), and brushes. In most common DC motors the external magnetic

field is produced by high-strength permanent magnets. The stator is the stationary part of the

motor -- this includes the motor casing, as well as two or more permanent magnet pole

pieces. The rotor (together with the axle and attached commutator) rotates with respect to the

stator. The rotor consists of windings (generally on a core), the windings being electrically

connected to the commutator. The above diagram shows a common motor layout -- with the

rotor inside the stator (field) magnets.

2.3.4 Construction:

Figure 2.7 Parts of Dc motor

Parts of a DC Motor:

Armature

A D.C. motor consists of a rectangular coil made of insulated copper wire wound on a

soft iron core. This coil wound on the soft iron core forms the armature. The coil is mounted

on an axle and is placed between the cylindrical concave poles of a magnet.

Commutator

A commutator is used to reverse the direction of flow of current. Commutator is a

copper ring split into two parts C1 and C2. The split rings are insulated from each other and

mounted on the axle of the motor. The two ends of the coil are soldered to these rings. They

rotate along with the coil. Commutator rings are connected to a battery. The wires from the

battery are not connected to the rings but to the brushes which are in contact with the rings.

26

Page 27: Obstacle Detection Based Robot

Figure 2.8 Basic Commutator

Brushes:

Two small strips of carbon, known as brushes press slightly against the two split

rings, and the split rings rotate between the brushes. The carbon brushes are connected to a

D.C. source.

2.3.5 Working of a DC Motor

When the coil is powered, a magnetic field is generated around the armature. The left

side of the armature is pushed away from the left magnet and drawn towards the right causing

rotation.

Figure 2.9 A Simple Electric Motor

27

Page 28: Obstacle Detection Based Robot

When the coil turns through 900, the brushes lose contact with the commutator and the

current stops flowing through the coil.

Direction of Rotation

A DC Motor has two wires. We can call them as positive terminal and negative

terminal, although these are pretty much arbitrary names (unlike a battery where these

polarities are vital and not to be mixed!). On a motor, we say that when the + wire is

connected to + terminal on a power source, and the - wire is connected to the - terminal

source on the same power source, the motor rotates clockwise (if you are looking towards the

motor shaft). If you reverse the wire polarities so that each wire is connected to the opposing

power supply terminal, then the motor rotates counter clockwise. Notice this is just an

arbitrary selection and that some motor manufacturers could easily choose the opposing

convention. As long as you know what rotation you get with one polarity, you can always

connect in such a fashion that you get the direction that you want on a per polarity basis.

Figure 2.10 DC Motor Rotation vs Polarity

Facts:

DC Motor rotation has nothing to do with the voltage magnitude or the current

magnitude flowing through the motor.

DC Motor rotation does have to do with the voltage polarity and the direction of the

current flow.

28

Page 29: Obstacle Detection Based Robot

Motor Start and Stop:

Starting a motor is a very hazardous moment for the system. Since you have an

inductance whose energy storage capacity is basically empty, the motor will first act as an

inductor because current cannot change abruptly in an inductor, but the truth of the matter is

that this is one of the instances in which you will see the highest currents flowing into the

motor. Stopping the motor is not as harsh as starting. The reason why the motor stops so fast

is because as a short is applied to the motor terminals, the Back EMF is shorted. Because

Back EMF is directly proportional to speed making Back EMF = 0.

2.3.6Advantages and Disadvantages:

Advantages:

Easy to understand design

Easy to control speed

Easy to control torque

Simple, cheap drive design

Disadvantages:

Expensive to produce

Can't reliably control at lowest speeds

Physically larger

High maintenance

Dust

2.4 OBSTACLE SENSOR

Figure 2.11 Obstacle Sensor

29

Page 30: Obstacle Detection Based Robot

This sensor is a short range obstacle detector with no dead zone. It has a reasonably

narrow detection area which can be increased using the dual version. Range can also be

increased by increasing the power to the IR LEDs or adding more IR LEDs

The photo below shows my test setup with some IR LED's (dark blue) as a light

source and two phototransistors in parallel for the receiver. This setup works like a first LDR

but with IR. It has a range of about 10-15cm (4-6 inches) with my hand as the object being

detected.

2.4.1 Circuit of obstacle sensors:

Starting from the left you can see two IR LEDs with a resistor and transistor in series.

The transistor allows the processor to turn the LEDs on or off. This is necessary to tell the

difference between the ambient IR from daylight and indoor lighting and the reflected light

from the LEDs that indicates the presence of an object.

Next we have two phototransistors in parallel with a 1M resistor in series. You could

use only one but I wanted to cover a wider area so my transistors will point in slightly

different directions. If either one detects IR it will allow more current to flow. Since

volts=current x resistance, even a small increase in current will create a reasonable increase

in voltage across the 1M resistor. Unfortunately the low input impedance of many A/D

converters will act like a small resistor in parallel with the 1M resistor and dramatically

reduce the output to the processor. This is where our BC549 transistor comes in to save the

day. In conjunction with the 1K and 10K resistors it amplifies the signal so that the analog

input on the processor gets a nice strong signal.  The BC549 is not too critical and it has hfe

of 490 when measured with a multimeter. You should probably have hfe of at least 200-300.

This has the advantage that you can flex the leds and transistors outward to cover a

large area. This is a reversing sensor to prevent him reversing into anything and as such will

cover a wide area. I will make single Led/Phototransistor sensors for front left and front right.

This will allow him to avoid crashing into obstacles when his rangefinder/object tracker is

looking elsewhere.

Note: That the phototransistors are slightly forward of the blue LEDs. This helps stop stray

light from the LEDs being detected.

30

Page 31: Obstacle Detection Based Robot

Figure 2.12 Circuit Diagram of Obstacle Sensor

2.4.2 Features

Modulated IR transmitter

Ambient light protected IR receiver

3 pin easy interface connectors

Bus powered module

Indicator LED

Up to 12 inch range for white object

Can differentiate between dark and light colors.

2.4.3 Applications

Proximity Sensor

Obstacle Detector Sensor

Line Follower Sensor

Wall Follower Sensor

31

Page 32: Obstacle Detection Based Robot

Chapter 3

Software

AVR STUDIO

3.1 Introduction:

AVR Studio is a Development Tool for the AT90S Series of AVR micro controllers.

This manual describes the how to install and use AVR Studio. It enables the user to fully

control execution of programs on the AT90S In-Circuit Emulator or on the built-in AVR

Instruction Set Simulator. AVR Studio supports source level execution of Assembly

programs assembled with the Atmel Corporation's AVR Assembler and C programs compiled

with IAR Systems’ ICCA90 C Compiler for the AVR microcontrollers. AVR Studio runs

under Microsoft Windows95 and Microsoft Windows NT.

AVR Studio enables execution of AVR programs on an AVR In-Circuit Emulator or

the built-in AVR Instruction Set Simulator. In order to execute a program using AVR Studio,

it must first be compiled with IAR Systems' C Compiler or assembled with Atmel's AVR

Assembler to generate an object file which can be read by AVR Studio.

The key window in AVR Studio is the Source window. When an object file is opened,

the Source window is automatically created. The Source window displays the code currently

being executed on the execution target (i.e. the Emulator or the Simulator), and the text

marker is always placed on the next statement to be executed. The Status bar indicates

whether the execution target is the AVR In-Circuit Emulator or the built-in Instruction Set

Simulator.

By default, it is assumed that execution is done on source level, so if source

information exists, the program will start up in source level mode. In addition to source level

execution of both C and Assembly programs, AVR Studio can also view and execute

programs on a disassembly level. The user can toggle between source and disassembly mode

when execution of the program is stopped.

All necessary execution commands are available in AVR Studio, both on source level

and on disassembly level. The user can execute the program, single step through the code

either by tracing into or stepping over functions, step out of functions, place the cursor on a

statement and execute until that statement is reached, stop the execution, and reset the

execution target. In addition, the user can have an unlimited number of code breakpoints, and

32

Page 33: Obstacle Detection Based Robot

every breakpoint can be defined as enabled or disabled. The breakpoints are remembered

between sessions.

The Source window gives information about the control flow of the program. In

addition,

AVR Studio offers a number of other windows which enables the user to have full

control of the status of every element in the execution target. The available windows are:

1. Watch window: Displays the values of defined symbols. In the Watch window, the

user can watch the values of for instance variables in a C program.

2. Register window: Displays the contents of the register file. The registers can be

modified when the execution is stopped.

3. Memory windows: Displays the contents of the Program Memory, Data Memory,

I/O Memory or EEPROM Memory. The memories can be viewed as hexadecimal values or

as ASCII characters. The memory contents can be modified when the execution is stopped.

4. Peripheral windows: Displays the contents of the status registers associated with

the different peripheral devices:

• EEPROM Registers

• I/O Ports

• Timers etc.

5. Message window: Displays messages from AVR Studio to the user

6. Processor window: Displays vital information about the execution target, including

Program Counter, Stack Pointer, Status Register and Cycle Counter. These parameters can be

modified when the execution is stopped.

3.2 Why AVR?

As microprocessors evolved, devices increased in complexity with new hardware and

new instructions to accomplish new tasks. These microprocessors became known as CISC or

Complex Instruction Set Computers. Complex is often an understatement; some of the CISCs

that I’ve worked with have mind-numbingly complex instruction sets. Some of the devices

have so many instructions that it becomes difficult to figure out the most efficient way to do

anything that isn’t built into the hardware.

Then somebody figured that if they designed a very simple core processor that only

did a few things but did them very fast and efficiently, they could make a much cheaper and

easier to program computer. Thus was born the RISC, Reduced Instruction Set Computers.

33

Page 34: Obstacle Detection Based Robot

The downside was that you had to write additional assembly language software to do all the

things that the CISC computer had built in. For instance, instead of calling a divide

instruction in a CISC device, you would have to do a series of subtractions to accomplish a

division using a RISC device. This ‘disadvantage’ was offset by price and speed, and is

completely irrelevant when you program with C since the complier generates the assembly

code for you.

Although I’ll admit that ‘CISC versus RISC’ and ‘C versus assembly language’

arguments often seem more like religious warfare than logical discourse, I have come to

believe that the AVR, a RISC device, programmed in C is the best way to microcontroller

salvation (halleluiah brother).

The folks that designed the AVR as a RISC architecture and instruction set while

keeping C programming language in mind. In fact they worked with C compiler designers

from IAR to help them with the hardware design to help optimize it for C programming.

3.3 WINAVR

WINAVR is not just one tool, like many other software names. It is instead a set of

tools, these tools include avr-gcc (the command line compiler), avr-libc (the compiler library

that is essential for avrgcc), avr-as (the assembler), avrdude (the programming interface),

avarice (JTAG ICE interface), avr-gdb (the de-bugger), programmers notepad (editor) and a

few others. These tools are all compiled for Microsoft Windows and put together with a nice

installer program.

When referring to the version, you are most of the time referring to the version of the

compiler, avr-gcc.

For example currently WinAVR includes version 3.3 of avr-gcc. However, it is not

WinAVR 3.3 as some people call it, to refer to which release you are using that is done by

date. For example WinAVR 20030424. The 20030424 is a date code, which is discussed

later.

WinAVR is a suite of executable, open source software development tools for the

Atmel AVR series of RISC microprocessors hosted on the Windows platform. It includes the

GNU GCC compiler for C and C++.

34

Page 35: Obstacle Detection Based Robot

WinAVR is a collection of executable software development tools for the Atmel AVR

processor hosted on Windows.

These software development tools include:

Compilers

Assembler

Linker

Librarian

File converter

Other file utilities

C Library

Programmer software

Debugger

In-Circuit Emulator software

Editor / IDE

Many support utilities

3.3.1 Compiler

The compiler in WinAVR is the GNU Compiler Collection, or GCC. This compiler is

incredibly flexible and can be hosted on many platforms; it can target many different

processors / operating systems (back-ends), and can be configured for multiple different

languages (front-ends).

The GCC included in WinAVR is targeted for the AVR processor, is built to execute

on the Windows platform, and is configured to compile C, or C++.

Avr-gcc is just a "driver" program only. The compiler itself is called cc1.exe for C, or

cc1plus.exe for C++. Also, the preprocessor cpp.exe will usually automatically be prepended

with the target name: avr-cpp.exe. The actual set of component programs called is usually

derived from the suffix of each source code file being processed.

3.4 AVRISP2:

The AVRISP2 combined with AVR studio can program all AVR 8-bir RISC

microcontrollers with ISP interface.

35

Page 36: Obstacle Detection Based Robot

3.4.1 Features

AVR studio compatible(avr studio 4.2 or later)

Supports all AVR devices with ISP interface

Programs both flash and EEPROM

Supports fuses and lock bit programming

Adjustable programming speed(50Hz to 8MHz sck frequency)\

USB2.0 compliant(full speed, 12 Mbps)

Powered from USB, does not require external power supply

Target interface protection

Short-circuit protection

36

Page 37: Obstacle Detection Based Robot

Chapter 4

Infrared Technology

4.1 Introduction:

As next-generation electronic information systems evolve, it is critical that all people

have access to the information available via these systems. Examples of developing and

future information systems include interactive television, touch screen-based information

kiosks, and advanced Internet programs. Infrared technology, increasingly present in

mainstream applications, holds great potential for enabling people with a variety of

disabilities to access a growing list of information resources. Already commonly used in

remote control of TVs, VCRs and CD players, infrared technology is also being used and

developed for remote control of environmental control systems, personal computers, and

talking signs.

For individuals using augmentative and alternative communication (AAC) devices,

infrared or other wireless technology can provide an alternate, more portable, more

independent means of accessing computers and other electronic information systems.

4.2 Wireless Communication:

Wireless communication, as the term implies, allows information to be exchanged

between two devices without the use of wire or cable. Information is being transmitted and

received using electromagnetic energy, also referred to as electromagnetic radiation. One of

the most familiar sources of electromagnetic radiation is the sun; other common sources

include TV and radio signals, light bulbs and microwaves.

The electromagnetic spectrum classifies electromagnetic energy according to

frequency or wavelength (both described below). As shown in Figure 1, the electromagnetic

spectrum ranges from energy waves having extremely low frequency (ELF) to energy waves

having much higher frequency, such as x-rays.

37

Page 38: Obstacle Detection Based Robot

Figure 3.1 Electromagnetic Spectrum

In Figure 8, A horizontal bar represents a range of frequencies from 10 Hertz (cycles

per second) to 10 to the 18th power Hertz. Some familiar allocated frequency bands are

labelled on the spectrum. Approximate locations are as follows. (Exponential powers of 10

are abbreviated as 10exp.)

10 Hertz: extremely low frequency or ELF.

10exp5 Hertz: AM radio.

10exp8 Hertz: FM radio.

10exp16 Hertz: Infrared (frequency range is below the visible light spectrum).

10exp16 Hertz: Visible Light.

10exp16 Hertz: Ultraviolet (frequency range is above the visible light spectrum).

10exp18 Hertz: X-rays.]

4.3 Infrared Technology:

Infrared radiation is the region of the electromagnetic spectrum between microwaves

and visible light. In infrared communication, an LED transmits the infrared signal as bursts of

non-visible light. At the receiving end a photodiode or photoreceptor detects and captures the

light pulses, which are then processed to retrieve the information they contain.

Figure 9 depicts an infrared energy wave and a radio energy wave, and illustrates the

two different energy wavelengths. As is expected based on the electromagnetic spectrum, the

infrared wave is higher frequency and therefore shorter wavelength than the radio wave.

Conversely, the radio wave is lower frequency and therefore longer wavelength than the

infrared wave.

38

Page 39: Obstacle Detection Based Robot

Figure 3.2 A radio frequency energy wave superimposed upon an infrared energy wave

The above illustrates the inverse relationship between frequency and wavelength. The

infrared energy wave completes nearly 5 and a half cycles in the time that the radio frequency

wave completes 2 cycles. ]

Infrared technology is highlighted because of its increasing presence in mainstream

applications, its current and potential usage in disability-related applications, and its

advantages over other forms of wireless communication.

Some common applications of infrared technology are listed below.

1. Augmentative communication devices

2. Car locking systems

3. Computers, Headphones

4. Emergency response systems

5. Environmental control systems

6. Home security systems

4.4 IR Advantages:

1. Low power requirements: therefore ideal for laptops, telephones, personal digital

assistants.

2. Low circuitry costs: $2-$5 for the entire coding/decoding circuitry.

3. Simple circuitry: no special or proprietary hardware is required, can be incorporated

into the integrated circuit of a product

4. Higher security: directionality of the beam helps ensure that data isn't leaked or

spilled to nearby devices as it's transmitted

39

Page 40: Obstacle Detection Based Robot

5. Few international regulatory constraints: IrDA (Infrared Data Association) functional

devices will ideally be usable by international travellers, no matter where they may be

6. High noise immunity: not as likely to have interference from signals from other

devices

4.5 IR Disadvantages:

1. Line of sight: transmitters and receivers must be almost directly aligned (i.e. able to

see each other) to communicate

2. Blocked by common materials: people, walls, plants, etc. can block transmission

3. Short range: performance drops off with longer distances

4. Light, weather sensitive: direct sunlight, rain, fog, dust, pollution can affect

transmission

5. Speed: data rate transmission is lower than typical wired transmission

4.6 Health Risks:

Any time electric current travels through a wire, the air, or runs an appliance, it

produces an electromagnetic field. It is important to remember that electromagnetic fields are

found everywhere that electricity is in use. While researchers have not established an ironclad

link between the exposure to electromagnetic fields and ailments such as leukemia, the

circumstantial evidence concerns many people.

In scientific terms, human body can act as an antenna, as it has a higher conductivity

for electricity than air. Therefore, when conditions are right human body may have

experienced a small "tingle" of electric current from a poorly grounded electric appliance. As

long as these currents are very small there isn't much danger from electric fields, except for

potential shocks. , Human body also has permeability almost equal to air, thus allowing a

magnetic field to easily enter the body. Unfortunately body cannot detect the presence of a

strong magnetic field, which could potentially do much more harm.

In terms of wireless technology, there are no confirmed health risks or scientific dangers

from infrared or radio frequency, with two known exceptions:

1. Point-to-point lasers which can cause burns or blindness.

2. Prolonged microwave exposure which has been linked to cancer and leukaemia.

40

Page 41: Obstacle Detection Based Robot

Therefore, most health concerns related to electromagnetic fields are due to electricity in

day-to-day use, such as computer monitors and TVs. These dangers, if any, are already in the

home and work place, and the addition of wireless technology should not be seen as an

exceptional risk. The strength of the electromagnetic field (EMF) decreases as the square of

the distance from the field source.

4.7 Security:

Electromagnetic frequencies currently have little legal status for protection and as

such, can be freely intercepted by motivated individuals. As presented earlier in the

advantages and disadvantages of infrared versus radio frequency transmission, what might be

considered an advantage to one method for transmission could turn out to be a disadvantage

for security? For example, because infrared is line-of-sight it has less transmission range but

is also more difficult to intercept when compared to radio frequency. Radio frequency can

penetrate walls, making it much easier to transmit a message, but also more susceptible to

tapping.

A possible solution to security issues will likely be some form of data encryption.

Data encryption standards (DES) are also being quickly developed for the exchange of

information over the Internet, and many of these same DES will be applied to wireless

technology.

4.8 Importance of Standards:

Several of the wireless devices demonstrated during the presentation have benefited to

some degree from standardization. For example, a universal IR remote was once priced at

roughly $100.00.The X10 devices that were demonstrated in the presentation not only rely on

but have benefited from the 60 HZ AC standard which applies to most of North America. As

a result these devices are now numerous and inexpensive. One final example demonstrating

the importance of standards is the relationship of augmentative alternative communication

(AAC) devices to the General Input Device Emulating Interface (GIDEI) standard. Any AAC

device programmed to use the GIDEI protocol can access any PC or Macintosh running the

DOS, Windows, or Macintosh version of Serial Keys.

41

Page 42: Obstacle Detection Based Robot

Chapter 6

Applications and Result

6.1 Applications:

Obstacle sensing robot can be applied at the toys where small children will play.

It can used for the army application we can add a cam to it.

We can apply number of IR pairs for the safe direction control of the robot.

6.2 Result:

The obstacle detection by the robot using IR is done according to the specifications.

To that it was verified in all directions for obstacle detection.

42

Page 43: Obstacle Detection Based Robot

Chapter 7

Future Aspects and Conclusion

7.1 Future Aspects:

We can extend this project with wireless technology by IR (or) RF (or) ZIGBEE.

We can use the DTMF receiver by using the mobile phone.

This robot can be used for pick and place the required object by giving directions to

the robot but IR pair should be replaced depending upon the application.

7.2 Conclusion:

The mini project is “obstacle detection and the avoidance robot”

• Using all the above adaptive control processes which are able to traverse a given route

autonomously negotiating difficult obstacles while protecting it from collisions.

• Our ROBOT successfully implements line tracking and range detection and obstacle avoidance.

• Hence it can be further used in Automobiles and industrial automation.

43

Page 44: Obstacle Detection Based Robot

Appendix

#define F_CPU 8000000UL //freq 8 MHz

#include <avr/io.h>

#include <avr/pgmspace.h>

#include <avr/interrupt.h>

#include <util/delay.h>

#include "UART_routines.h"

#include "adc_routines.h"

#include <stdio.h>

static int uart_putchar(char c, FILE *stream);

static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,

_FDEV_SETUP_WRITE);

static int

uart_putchar(char c, FILE *stream)

{

if (c == '\n')

uart_putchar('\r', stream);

loop_until_bit_is_set(UCSRA, UDRE);

UDR = c;

return 0;

}

void port_init(void)

{

PORTB = 0xEF;

DDRB = 0xFF; //MISO line i/p, rest o/p

PORTC = 0x00;

44

Page 45: Obstacle Detection Based Robot

DDRC = 0x00;

PORTD = 0x00;

DDRD = 0xFE;

}

//UART0 initialize

// desired baud rate: 19200

// actual: baud rate:19231 (0.2%)

// char size: 8 bit

// parity: Disabled

void uart0_init(void)

{

UCSRB = 0x00; //disable while setting baud rate

UCSRA = 0x00;

UCSRC = (1 << URSEL) | 0x06;

UBRRL = 0x33; //set baud rate lo

UBRRH = 0x00; //set baud rate hi

UCSRB = 0x18;

}

//call this routine to initialize all peripherals

void init_devices(void)

{

cli();

port_init();

uart0_init();

adc_init( );

MCUCR = 0x00;

GICR = 0x00;

TIMSK = 0x00; //timer interrupt sources

//all peripherals are now initialized

}

45

Page 46: Obstacle Detection Based Robot

int main(void)

{

//unsigned char data;

int result,a,b ;

float temp;

init_devices();

stdout = &mystdout;

printf("Hello, world!\n");

while(1)

{

result= Adc_Read(0);

temp =(result*4.50)/1024 ;

result=(temp )*100;

printf("voltage0 %d\n\r",result);

a= Adc_Read(1);

temp =(a*4.50)/1024 ;

a=(temp )*100;

printf("voltage1 %d\n\r",a);

b= Adc_Read(2);

temp =(b*4.50)/1024 ;

b=(temp )*100;

printf("voltage2 %d\n\r",b);

if(result>=250)

{

PORTB=0b00000001;

printf("result");

}

else if(a>=250)

{

PORTB=0b000000100;

printf("a");

46

Page 47: Obstacle Detection Based Robot

}

else if(b>=250)

{

PORTB=0b00001010;

printf("b");

_delay_ms(1000);

PORTB=0b00000001;

}

else

{

PORTB=0b00000101;

printf("c");

}

_delay_ms(1000);

}

}

47

Page 48: Obstacle Detection Based Robot

References

• http://www.atmel.com/avr

• http://www.seminarprojects.com/Thread- obstacle-avoider-and-

collision-control-robot#ixzz1S5rehGql

• http://www.slideshare.net/abhi230789/obstacle-avoiding-robot

48