Sei sulla pagina 1di 86

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

CHAPTER 1
INTRODUCTION
1.1Hardware specifications:
Parallel port DSUB25M: The Parallel Port is the most commonly used port for interfacing
homemade projects. There may also be a D-Type 25 pin male connector. This will be a serial
RS-232 port and thus, is a totally incompatible port.

L298: The L298 is a Dual Full Bridge driver that can drive up to 2Amps per bridge with
supply voltage up to 46V. It can drive DC motors, stepper motors, relays, solenoids, etc. The
device is TTL compatible. Two H bridges of L298 can be connected in parallel to increase its
current capacity to 4 Amp. It can be used in conjunction with stepper motor controller for
driving one/two phase stepper motor. The device is available in 15- lead Multi watt package.
MC2TE: Optocoupler is a coupling component used commonly in feedback control loop
circuits for power supply equipment The Optocoupler is an optoelectronics component of
high failure risk. It is generally used for conveying analog info. The photo transmitter is light
emitting diode and the phototransistor can be made of different types.
AT89C2051: The AT89C2051 is a low-voltage, high-performance CMOS 8-bit
microcomputer with 2K bytes of Flash programmable and erasable read-only memory
(PEROM). The device is manufactured using Atmels high-density nonvolatile memory
technology and is compatible with the industry-standard MCS-51 instruction set. By
combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C2051 is a
powerful microcomputer which provides a highly-flexible and cost-effective solution to many
embedded control applications.
DC Motor: An electric motor uses electrical energy to produce mechanical energy, very
typically through the interaction of magnetic field and current-carrying conductors. The
reverse process, producing electrical energy from mechanical energy, is accomplished by a
generator or dynamo. Many types of electric motors can be run as generators, and vice versa.

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


For example a starter/generator for a gas turbine or Traction motors used on vehicles often
perform both tasks.
Parallel Jaw Gripper:

Limit switch: The touch sensor module is based around the limit switch. This module is able
to detect obstacles when it bumps into it. The module gives an active low output when it
detects an obstacle. The output remains low for a time interval determined by IC555 timer.

1.2 Software specifications:


Software used: MATLAB
Here we are using MATLAB image acquisition toolbox. The toolbox uses external web
camera to acquire image. It is then processed upon.
PCB designing software: DIPTRACE
Burning software: KEIL

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

CHAPTER 2.LITERATURE SURVEY


2.1EXISTING TECHNOLOGY
This project basically performs pick & place operation using artificial intelligence.
We can perform pick & place operation using following techniques
1. Manual pick & place
In this technique manual labour required is very high, hence if the number of objects
to be moved is high the cost increases as the requirement of manual labour increases
This technique fails if the number of objects to be moved is high. Hence we go for
PC controlled robot. The main disadvantage of this technique is that as the number of
the objects to be placed increases the, time required to move all the objects increases
2. PC controlled robot
In this technique a person is required to control the robot from a distant place with
the help of a PC .So this technique can be used to handle dangerous chemicals and
hazardous materials(radioactive material).Disadvantage of this technique is that a
separate PC & a separate user is required.
3. Autonomous robot
In this technique the user is required to direct/place the robot in the room where object
is to be moved. Now the autonomous robot will detect the object automatically and
will calculate the path to reach the object and after reaching to the desired distance
from the object it will pick the object and place to a desired destination.
The main advantage of autonomous robot is that no separate PC and guidance is
required. Hence it uses its artificial intelligence to detect and place the object. This
makes the robot autonomous.

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

2.2 PROPOSED TECHNOLOGY


In all above existing technologies like PC controlled robot always one person needs to be
engaged always along with the controlling unit. While we are making use of automated robot
which can decide all its current and destination coordinates all by itself without any manual
control required hence said to be having the artificial intelligence. Which has self-processing
capabilities. This can be used in industries for inventory management and material handling
efficiently without much of the manual control involved in it.
In our case we are making use of the colour of the object as the attribute for the detection.
There is continuous feedback of the images of the arena taken with the help of web cam
which keeps informing the robot about its current position and its distance from the
destination object in the designed arena

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

CHAPTER3. ADOPTED METHODOLOGY


3.1Basics of robotics
3.1.1 What is Robotic Arm?
A robotic arm is a robot manipulator, usually programmable, with similar functions to a
human arm. The links of such a manipulator are connected by joints allowing either rotational
motion (such as in an articulated robot) or translational (linear) displacement. The links of the
manipulator can be considered to form a kinematic chain. The business end of the kinematic
chain of the manipulator is called the end effectors and it is analogous to the human hand.
The end effectors can be designed to perform any desired task such as welding, gripping,
spinning etc., depending on the application. For example robot arms in automotive assembly
lines perform a variety of tasks such as welding and parts rotation and placement during
assembly.
The Project consists of a 4 wheeled Robot, a spy camera and a robotic Arm. The robot is
completely Computer controlled using GUI or Graphic User Interface which is designed
using MATLAB.
The primary objective of the Robot is to detect an object placed inside an arena (3D work
space), identify it, pick it, and place it at the place where the user requires it. The object
detection is done using Image Processing, whereby the robot identifies the required object
from among many objects placed in the room.
The robot has a camera mounted on it so as to identify the required object. The camera will
also do continuous video streaming to the user sitting at the computer.

3.1.2 Base:
A robotic manipulator is a device capable of moving in different directions (base, shoulders,
elbow, yaw, pitch, roll directions) relative to base and controlled by computer. The base is
normally bolted to floor but in our case the base we have designed base that is fixed but can
rotate about vertical axis by 360 degrees. We have constructed base from a Bakelite material,
a turn table of radius 7cm. this base is actuated by a D.C geared motor mounted beneath it.

3.1.3 Arm:
The next important member of the robot is the arm which is the link between shoulder and
elbow. The arm is made up of number of joints and links. One end of the arm is attached to
5

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


the base and the other end is free to move and is attached to an end-effector which is used to
perform a number of tasks (gripping, painting etc.).The arm manoeuvres the tool to a precise
location in the 3D space to perform a particular task.
Our pick and place robot consists of two arms. The first arm is joined or attached vertically to
the base. It can rotate about a single axis in a vertical 2D plane by 180 degrees. Both the arms
are made up of Bakelite material having lengths of 10cms each.
The second arm can rotate about any arbiter axis in the plane. The whole idea is that the robot
can be positioned using the base and these two arms. The arms are actuated by D.C geared
motors. A gripper or end effector or tool is attached to the second arm which is used to hold
objects, to pick from one place and to place it at the other as commonly observed in the
industry work floors.

3.1.4 Gripper:
Grippers are the devices which are attached to the end of the robot arm and are used to
grip/pick/grasp an object from one place to another place. There are various types of grippers
out of which we have used parallel jaw gripper. A parallel jaw gripper is one which tool tip
position is fixed and the two finger move parallel to each other. The disadvantage of this
parallel jaw gripper is that it cannot pick up the lengthy objects. It can pick up only those
objects whose sides are parallel in nature such as containers, boxes. So depending upon the
requirement of the industry work floor we can just vary the design of grippers keeping the
entire assembly same.

3.1.5 Links and joints:


The robot body consists of several links and joints. The figure below shows robot with
several links and joints. Links are defined as the rigid members which are connected between
two successive joints. Axis is defined as an imaginary straight line about which the two links
will rotate with respect to each other or an imaginary line which the two links will translate
with respect to each other. Joints are defined as the junctions which are used to connect two
successive links. There are two types of joints viz. prismatic and revolute. Each joint is driven
by actuator in our case D.C motor which gives the desired position to the robot in work
space. Our robot has no prismatic joints and 3 revolute joints which connect the links rotating
about the 3 axes described below

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

3.2 Parallel Port


3.2.1 Introduction to Parallel port
The Parallel Port is the most commonly used port for interfacing homemade projects. This port will
allow the input of up to 9 bits or the output of 12 bits at any one given time, thus requiring minimal
external circuitry to implement many simpler tasks. The port is composed of 4 control lines, 5 status
lines and 8 data lines. It's found commonly on the back of your PC as a D-Type 25 Pin female
connector. There may also be a D-Type 25 pin male connector. This will be a serial RS-232 port and
thus, is a totally incompatible port.
Newer Parallel Ports are standardized under the IEEE 1284 standard first released in 1994.This
standard defines 5 modes of operation which are as follows,

1. Compatibility Mode.
2. Nibble Mode.
3. Byte Mode.
4. EPP Mode (Enhanced Parallel Port).
5. ECP Mode (Extended Capabilities Port).

The aim was to design new drivers and devices which were compatible with each other and also
backwards compatible with the Standard Parallel Port (SPP). Compatibility, Nibble & Byte modes use
just the standard hardware available on the original Parallel Port cards while EPP & ECP modes
require additional hardware which can run at faster speeds, while still being downwards compatible
with the Standard Parallel Port. Compatibility mode or "Centroids Mode" as it is commonly known,
can only send data in the forward direction at a typical speed of 50 Kbytes per second but can be as
high as 150+ Kbytes a second. In order to receive data, you must change the mode to either Nibble or
Byte mode. Nibble mode can input a nibble (4 bits) in the reverse direction. E.g. from device to
computer. Byte mode uses the Parallel's bi-directional feature (found only on some cards) to input a
byte (8 bits) of data in the reverse direction. Extended and Enhanced Parallel Ports use additional
hardware to generate and manage handshaking. To output a byte to a printer (or anything in that
matter) using compatibility mode, the software must.
1. Write the byte to the Data Port.
2. Check to see is the printer is busy. If the printer is busy, it will not accept any data, thus any data
which is written will be lost.
3. Take the Strobe (Pin1) low. This tells the printer that there is the correct data on the datelines
(Pins2-9)

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


4. Put the strobe high again after waiting approximately 5 microseconds after putting the strobe low.
(Step 3)
This limits the speed at which the port can run at. The EPP & ECP ports get around this by letting the
hardware check to see if the printer is busy and generate a strobe and /or appropriate handshaking.
This means only one I/O instruction need to be performed, thus increasing the speed. These ports can
output at around 1-2 megabytes per second. The ECP port also has the advantage of using DMA
channels and FIFO buffers, thus data can be shifted around without using I/O instructions.

3.2.2 Hardware Properties


On the next page is a table of the "Pin Outs" of the D-Type 25 Pin connector and the Centronics 34
Pin connector. The D-Type 25 pin connector is the most common connector found on the Parallel Port
of the computer, while the Centronics Connector is commonly found on printers. The IEEE 1284
standard however specifies 3 different connectors for use with the Parallel Port. The first one, 1284
Type A is the D-Type 25 connector found on the back of most computers. The 2nd is the 1284 Type B
which is the 36 pin Centronics Connector found on most printers. IEEE 1284 Type C however, is a 36
conductor connector like the Centronics, but smaller. This connector is claimed to have a better clip
latch, better electrical properties and is easier to assemble. It also contains two more pins for signals
which can be used to see whether the other device connected, has power. 1284 Type C connectors are
recommended for new designs, so we can look forward on seeing these new connectors in the near
future

Fig. 3.2.2

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Pin No (D-Type

Pin No

SPP Signal

Direction
In/out

Register

25

(Centronics )

nStrobe

In/Out

Control

Data 0

Out

Data

Data 1

Out

Data

Data 2

Out

Data

Data 3

Out

Data

Data 4

Out

Data

Data 5

Out

Data

Data 6

Out

Data

Data 7

Out

Data

10

10

nAck

In

Status

11

11

Busy

In

Status

12

12

Paper-Out
PaperEnd

In

Status

13

13

Select

In

Status

14

14

nAuto-Linefeed

In/Out

Control

15

15

nError / nFault

In

Status

16

16

nInitialize

In/Out

Control

17

17

nSelect-Printer
nSelect-In

In/Out

Control

18-25

18-25

Ground

Gnd

The above table uses "n" in front of the signal name to denote that the signal is active low. e.g.nError.
if the printer has occurred an error then this line is low. This line normally is high, should the printer
be functioning correctly. The "Hardware Inverted" means the signal is inverted by the Parallel card's
hardware. Such an example is the busy line. If +5v (Logic 1) was applied to this pin and the status
register read, it would return back a 0 in Bit 7 of the Status Register The output of the Parallel Port is
normally TTL logic levels. The voltage levels are the easy part. The current you can sink and source
varies from port to port. Most Parallel Ports implemented in ASIC, can sink and source around 12mA.
However these are just some of the figures taken from Data sheets, Sink/Source 6mA, Source
12mA/Sink 20mA, Sink 16mA/Source 4mA, Sink/Source 12mA. As you can see they vary quite a bit.
The best bet is to use a buffer, so the least current is drawn from the Parallel Port

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

3.2.3 Centronics
Centronics is an early standard for transferring data from a host to the printer. The majority of printers
use this handshake. This handshake is normally implemented using a Standard Parallel Portunder
software control. Below is a simplified diagram of the Centronics Protocol

Fig. 3.2.3

Data is first applied on the Parallel Port pins 2 to 7. The host then checks to see if the printer is busy.
I.e. the busy line should be low. The program then asserts the strobe, waits a minimum of 1mS, and
then de-asserts the strobe. Data is normally read by the printer/peripheral on the rising edge of the
strobe. The printer will indicate that it is busy processing data via the busy line. Once the printer has
accepted data, it will acknowledge the byte by a negative pulse about 5mS on the nAck line. Quite
often the host will ignore the nAck line to save time. Latter in the Extended Capabilities Port, you will
see a Fast Centronics Mode, which lets the hardware do all the handshaking for you. All the
programmer must do is write the byte of data to the I/O port. The hardware will check to see if the
printer is busy, generate the strobe. Note that this mode commonly doesnt check the nAck either

3.2.4 Port Addresses


The Parallel Port has three commonly used base addresses. These are listed in table 2, below. The
3BCh base address was originally introduced used for Parallel Ports on early Video Cards. This

10

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


address then disappeared for a while, when Parallel Ports were later removed from Video Cards. They
has now reappeared as an option for Parallel Ports integrated onto motherboards, upon which their
configuration can be changed using BIOS.
LPT1 is normally assigned base address 378h, while LPT2 is assigned 278h. However this may not
always be the case as explained later. 378h & 278h have always been commonly used for Parallel
Ports. The lower case h denotes that it is in hexadecimal. These addresses may change from machine
to machine

Address

Notes:
Used for Parallel Ports which were incorporated

3BCh - 3BFh

in to Video Cards and now, commonly an option


for Ports controlled by BIOS. - Doesn't support
ECP addresses

378h - 37Fh

Usual Address For LPT 1

278h - 27Fh

Usual Address For LPT 2

When the computer is first turned on, BIOS (Basic Input/output System) will determine the number of
ports you have and assign device labels LPT1, LPT2 & LPT3 to them. BIOS first looks at address
3BCh. If a Parallel Port is found here, it is assigned as LPT1, then it searches at location 378h. If a
Parallel card is found there, it is assigned the next free device label. This would be LPT1 if a card
wasn't found at 3BCh or LPT2 if a card was found at 3BCh. The last port of call, is 278h and follows
the same procedure than the other two ports. Therefore it is possible to have a LPT2 which is at 378h
and not at the expected address 278h.
What can make this even confusing, is that some manufacturers of Parallel Port Cards, have jumpers
which allow you to set your Port to LPT1, LPT2, and LPT3. Now what address is LPT1? - On the
majority of cards LPT1 is 378h, and LPT2, 278h, but some will use 3BCh as LPT1, 378h as LPT1 and
278h as LPT2. Life wasnt meant to be easy.
The assigned devices LPT1, LPT2 & LPT3 should not be a worry to people wishing to interface
devices to their PC's. Most of the time the base address is used to interface the port rather than LPT1
etc. However should you want to find the address of LPT1 or any of the Line Printer Devices, you can
use a lookup table provided by BIOS. When BIOS assigns addresses to your printer
Devices, it stores the address at specific locations in memory, so we can find them

11

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Start Address

Function

0000:0408

LPT1's Base Address


0000:040A

0000:040A

LPT2's Base Address

0000:040C

LPT3's Base Address

0000:040E

LPT4's Base Address (Note 1)

The above table, table 3, shows the address at which we can find the Printer Port's addresses in
The BIOS Data Area. Each address will take up 2 bytes

3.2.5 Bi-directional Ports


The schematic diagram below, shows a simplified view of the Parallel Port's Data Register. The
original Parallel Port cards implemented 74LS logic. These days all this is crammed into one ASIC,
but the theory of operation is still the same.

Fig 3.2.5

12

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


The non-bi-directional ports were manufactured with the 74LS374's output enable tied permanent
low, thus the data port is always output only. When you read the Parallel Port's data register, the data
comes from the 74LS374 which is also connected to the data pins. Now if you can overdrive the '374
you can effectively have a Bi-directional Port. (Or an input only port, once you blow up the latches
output!) Bi-directional ports use Control Bit 5 connected to the 374's OE so that its output drivers can
be turned off. This way you can read data present on the Parallel Port's Data Pins, without having bus
conflicts and excessive current drains. Bit 5 of the Control Port enables or disables the bi-directional
function of the Parallel Port.
This is only available on true bi-directional ports. When this bit is set to one, pins 2 to 9 go into high
impedance state. Once in this state you can enter data on these lines and retrieve it from the Data Port
(Base address). Any data which is written to the data port will be stored but will not be available at the
Data pins. To turn off bi-directional mode, set bit 5 of the Control Port to '0'. However not all ports
behave in the same way. Other ports may require setting bit 6 of the Control Port to enable Bi
directional mode and setting of Bit 5 to dis-enable Bi-directional mode, Different manufacturers
implement their bi-directional ports in different ways. If you wish to use your Bi-directional port to
input data, test it with a logic probe or multimeter first to make sure it is in bidirectional
Mode.

3.2.6 Parallel Port interfacing in the project

Fig 3.2.6

13

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


As shown in the diagram DSUB25M parallel port is interfaced with microcontroller by means of
Optocoupler .Optocoupler act as a protection circuit for the parallel port so that whenever there is an
existence of overvoltage condition due to higher current at that instant Optocoupler disables the
connection between parallel port and microcontroller this saves the parallel port from damage in turn.

3.3 Motor driver


The different motor driver ICs available in the market which can be used for
Microcontroller-Motor interfacing such as:
Hercules 30 Amp. Motor Driver 16V, 30A
Hercules 30 Amp. Motor Driver 36V, 30A
Dual L298 Motor Driver
LMD18200 DC Motor Driver
Stepper Motor Driver with Chopper
A3949 Full Bridge Motor Driver
LMD18200 3Amp. Motor Driver IC
MC33886 40v. 5Amp. Motor Driver

3.3.1 IC L293
The L293D is a quadruple half H-bridge bidirectional motor driver IC that can drive current
of up to 600mA with voltage range of 4.5 to 36 volts. It is suitable to drive small DC-Geared
motors, bipolar stepper motor etc. Rs.84.38

Fig 3.3.1

14

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Specifications
Supply Voltage Range 4.5V to 36V
600-mA Output current capability per driver
Separate Input-logic supply
It can drive small DC-geared motors, bipolar stepper motor.
Pulsed Current 1.2-A Per Driver
Thermal Shutdown
Internal ESD Protection
High-Noise-Immunity Inputs
Applications
DC and stepper motor drives
Position and velocity servomechanisms

3.3.2 IC L298
L298. Is most commonly used driver circuit in hobby robots? This can control 2 DC Motors,
their direction using control lines and their speed using PWM.
Maximum current rating per channel: 2A
Maximum Supply voltage for Motors: 50V
Maximum Logic Voltage: 7V

15

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig 3.3.2

Fig no. 3.3.2


Though we have two ICs available which are can be used in our project, but L298
comparatively has more advantages on L293 in following cases:
1. Motor current- Larger as compared to L293
2. Heat Sink- Less power dissipation
3. Compatibility with MC2TE IC (Optocoupler)

3.4 L298 Interfacing


3.4.1 L298 Interfacing with DC motors
The L298 Motor Driver IC allows the user to safely interface two DC motors to a host
microcontroller using only 4 control lines. The motor driver isolates the host and controls
continuous currents of up to 2 Amps per motor (4 Amps total). Short peaks (spikes) up to 3
Amps per motor can be tolerated without damage. While ideally suited for use with a
microcontroller, it may also be used with just about any form of 0-5 Volt signal (i.e. manual
switches, TTL logic gates, relays etc.).

16

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig 3.4.2

3.4.2 a Bit about Motor Current


Motors are inductive devices; they draw much more current at start up than when they are
running at a steady speed. Before connecting any motor to the L298 you should know a few
things about the motor:
- What voltage it is designed to work at
- How much current it draws when running (unloaded)
- How much current it draws at stall.
The stall current is the current the motor draws when you stop (stall) the output shaft (if
you can). Stalling a motor is very hard on the motor and can burn open the motor windings
and ruin the motor. If you want to test for stall current, grab the output shaft with your hand
while measuring the current drawn. As the motor approaches stall, the current will climb. The
L298N can safely handle 2 Amps of continuous current for each motor. Short surges up to 3
Amps as the motor starts can be tolerated. A heat sink would be a good idea in situations that
see the current surge above 2 Amps.

17

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

3.4.3 Connecting the Motors


A DC motor has 2 terminals on it. If you take the positive and negative leads from a power
source (battery, power supply etc.) and connect them to the terminals of the motor, the motor
will spin in one direction. If you swap the connections, the motor will spin in the opposite
direction. You will want to wire your motors to the L298 board in such a way that the motor
spins in the direction you call forward when the Fwd. line is activated and reverse when
the Back line activated. When connecting the motors to the circuit board, use as thick a wire
as is practical. The thicker the wire, the less the voltage drop and the more power is delivered
to the motor. We recommend a minimum of 18 gauge stranded wire. Solid wire is fine, but
will break if flexed too often. Solder the Positive and negative motor leads for the left motor
to Motor Left + and - solder pads. Repeat for the right motor. Connect the + and - leads
from your motor battery to the Motor Battery + and - solder pads -again, use as thick a wire
as it practical There is a 1.4V drop associated with the L298. This means that if motor runs on
12 VDC, one should use a 13.4 VDC supply in order to get full power to the motor

3.4.4 Operation
Control is accomplished by grounding the control pin(s) for the desired function/motor. This
is usually done by putting a logic LOW (i.e. 0V or ground) on an output pin of your host
microcontroller, which is in turn connected to the appropriate control connection (Fwd. Back,
Enable ). Fwd. To make a motor move forward, ground the Fwd. connection on the
appropriate connector (left / right). To stop, un-ground the connection. The photo below
shows how both motors would be made to go forward. Back (Reverse) to drive the motor in
reverse, ground the appropriate Back connection. To stop, unground the connection. Gnd is a
ground connection. The L298 Controller board and your control circuit must share the same
ground. Enable The Enable connection is an active LOW connection that is pulled HIGH for
you on the circuit board. Ground this connection to disable a motor. Note: While disabled,
commands from the host microcontroller (grounding/un-grounding the control connections)
will have no effect on
That motor. Disabling a motor shuts-down the L298s internal circuits, putting it into a low
current consumption mode (for that channel). When both channels are disabled, the motor
controller will consume approx. 10mA

18

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

3.4.5 Pulse-Width Modulation (PWM)


Pulse-Width Modulation is a method of controlling the speed of a motor by turning the power
on and off at varying speeds. If you have a 12 Volt motor and turn it on 50% of the time and
turn it off 50% of the time (switching it at several KHz) then the effective voltage you are
applying to the motor is 6 Volts. As the voltage to the motor varies, so does its speed. It
should be noted that the L298 Kit was not intended for high-speed PWM operation. The
diodes in the kits are general purpose rectifier diodes intended for 60 Hz operation. If you
want to experiment with PWM and you dont get the kind of results you want, try exchanging
the diodes for fast recovery Schottky models.

3.4.6 Heat Sinks


The L298 has internal thermal protection circuitry that shuts down the chip if it becomes too
hot (when you try to draw too much current). If you find this happening, you should add
some kind of heat sink to the L298. A simple heat sink can be made from a piece of scrap
aluminium by cutting as big a piece as you have room for and drilling a 1/8 hole into it (for a
bolt to hold it to the L298). If available, a thin smear of thermal compound (white, greasy
stuff, available at Radio Shack) on the back of the L298s metal tab (i.e. between it and the
heat sink) will maximize heat dissipation. Of course, you should always make sure that air
can circulate freely around the L298 and its heat sink. If a motor behaves erratically i.e.
turning on and off rapidly, it is likely the L298 senses that it is being overloaded. This usually
means that you are drawing too much current. Either add a heat sink to the L298 and/or
reduce the current being drawn...

3.4.7 H-Bridge Theory


Figure shows the basic schematic for a typical H-Bridge along with its truth table. In order to
make a motor turn, we need to apply a voltage to it. We do this by turning certain NPN
transistors on. By looking at the truth table, we can see that in order to make a motor go
forward (NOTE: Forward and Reverse are arbitrary directions for purposes of illustration.
In your application, forward and reverse will be determined by how the motors are mounted
with respect to each other and the polarity of the voltage) we must turn on Q1 and Q4. This
puts the Motor Battery Positive on the left side of the motor (through Q1) and grounds the
other side of the motor (through Q4). To go in the opposite direction, we must turn off these
transistors and turn on Q2 and Q3. Now, the Motor Battery Positive will be on the right side
19

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


of the motor (through Q3) and ground is on the left (through Q2). You have now reversed the
polarity of the motors supply voltage and the motor will spin in the opposite direction.

Fig. 3.4.7

You will notice that each time a motor is turned on, current passes through 2 NPN transistors.
Each transistor has (approximately) 0.7 Volt drop across it, so the motor will see about 1.4
Volts LESS than the Motor Battery Voltage across its terminals. This means that if you have
a 12 Volt motor, and you want it to receive maximum power, you should use a 13.4 Volt
battery. Also notice that if transistors Q1 and Q2 (or Q3 and Q4) were turned on, that you
would make a short circuit across the battery. For this reason, the L298N has internal logic
that prevents this from happening.

3.4.8 MOTOR DRIVER SECTION


Microcontroller receives the code for left, right, up, down of robot from PC at port 1. It
checks the code and according to that provides the data to motor on port o. We have used 4
DC motors of 30rpm to move the robot & two 10 rpm motor to move the camera in 2 axis. To
run the motor we have used L298 motor driver IC. Two motors on the left side of robot are
connected in parallel combination & other two in right side are connected in parallel
combination.

20

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig 3.4.8

The L298 Motor Driver has 4 inputs to control the motion of the motors and two enable
inputs which are used for switching the motors on and off. To control the speed of the motors
a PWM waveform with variable duty cycle is applied to the enable pins. Rapidly switching
the voltage between Vs and GND gives an effective voltage between Vs and GND whose
value depends on the duty cycle of PWM. 100% duty cycle corresponds to voltage equal to
Vs, 50 % corresponds to 0.5Vs and so on. The 1N4004 diodes are used to prevent back EMF
of the motors from disturbing the remaining circuit. Many circuits use L293D for motor
control, I chose L298 as it has current capacity of 2A per channel at 45V compared to 0.6 A
at 36 V of a L293D. L293Ds package is not suitable for attaching a good heat sink;
practically you cant use it above 16V without frying it. L298 on the other hand works
happily at 16V without a heat sink, though it is always better to use one.

3.4.9 Operation of DC motor:


In any electric motor, operation is based on simple electromagnetism. A current-carrying
conductor generates a magnetic field; when this is then placed in an external magnetic field, it
will experience a force proportional to the current in the conductor, and to the strength of the
external magnetic field. As you are well aware of from playing with magnets as a kid,
opposite (North and South) polarities attract, while like polarities (North and North, South
and South) repel. The internal configuration of a DC motor is designed to harness the
magnetic interaction between a current-carrying conductor and an external magnetic field to
generate rotational motion.
21

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig 3.4.9

In a simple 2-pole DC electric motor, as shown above (here red (right side) represents a
magnet or winding with a "North" polarization, while green (left side) represents a magnet or
winding with a "South" polarization).
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 (and all that Beamers will see), 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.
The geometry of the brushes, commutator contacts, and rotor windings are such that when
power is applied, the polarities of the energized winding and the stator magnet(s) are
misaligned, and the rotor will rotate until it is almost aligned with the stator's field magnets.
As the rotor reaches alignment, the brushes move to the next commutator contacts, and
energize the next winding. Given our example two-pole motor, the rotation reverses the
direction of current through the rotor winding, leading to a "flip" of the rotor's magnetic field,
driving it to continue rotating.
In real life, though, DC motors will always have more than two poles (three is a very
common number). In particular, this avoids "dead spots" in the commutator. You can imagine
22

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


how with our example two-pole motor, if the rotor is exactly at the middle of its rotation
(perfectly aligned with the field magnets); it will get "stuck" there. Meanwhile, with a twopole motor, there is a moment where the commutator shorts out the power supply (i.e., both
brushes touch both commutator contacts simultaneously). This would be bad for the power
supply, waste energy, and damage motor components as well. Yet another disadvantage of
such a simple motor is that it would exhibit a high amount of torque "ripple" (the amount of
torque it could produce is cyclic with the position of the rotor).

3.5 Motors
What is a motor?
An electrical machine that converts electrical energy to mechanical energy is called motor.

3.5.1 Types of motors


[A] Geared motors:
These are the motors that operate using gears. We generally use these motors for our level 1
robotics events. The advantage of these motors is that they are bidirectional viz with these
motors you can move your robot in both directions (forward and backward).

[b] Ungeared motors: These motors do not work with gears. The bidirectional rotation is not
possible with these motors. Hence they are generally not preferred for level 1 robots.
Types of geared motors
Geared motors are available in different rpms (rotations per minute)30, 75, 100, 150, 300,
500, 750 and 1000 rpms are the ones which are commonly available in the market. These
motors are rated to withstand upto 12 volts and a current of 5amp.

[c] Selection of motors: Remember that you may have to modify your car for different
events according to the track details and the tasks at hand. This may even include replacing
your motors with different rpm motors.So what are the guidelines while selecting a motor.
To decide which rpm to use for your robot you need to know the principle of torque.

23

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

3.5.2 Torque:
Torque = power/w, where w=2*pi*n

Using 500 rpm motors gives less torque. Due to this your robot may not be able to climb
inclined slopes very easily above some angle of inclination. It may give you more speed but
the power of the robot decreases. Hence selection of rpm is always a compromise between
speed and torque. Generally for obstacle courses in level 1 robotic races, 300 rpm motors are
used as they provide sufficient torque and speed.
Motors having rpm lower than 300 rpm are generally not used for racing unless there are very
high torque requirements. They are used for performing other tasks in events such as
robowars. Tasks such as picking up heavy objects, using mechanisms like cranes, carriers and
elevating heavy objects involve the use of such lower rpm motors.
In drag races to obtain more speed, higher rpm motors should be used.

3.5.3 No. of motors:


There is no restriction in the number of motors to be used for building a level 1 robot. 4, 3 or
even 2 motors can be used to build a robot. In case of 2 motors the two back wheels are
generally attached to the 2 motors and front wheels are not attached to motors. In this case the
motors used must be of superior quality and should be able to push the entire robot over the
obstacle course. Such superior quality motors are also available but at a much higher cost
than normal motors.
The advantage of using 2 motors is that it makes your robot lighter.

3.5.4 Handling and precautions:


The geared motors that you all will purchase are sturdy and reliable. But some
precautions need to be taken when using them:
The motors are rated to withstand 12 volts. However they can be used at higher voltages up to
30 volts for a small duration of time (around 90 seconds) without damaging the motor.
Running the motor for more time at high voltages will damage the motor.

While testing the motors at any point of time during construction of the robot make sure that
the positive and negative terminal of the motors are not shorted at any point. If this happens

24

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


when the power supply is switched on, it may short circuit the motor, damage it and make it
completely non-functional.

Some of the tracks may have your robot passing through water. Hence your motors should be
properly insulated. Water entering inside the motor will damage it and cause electrical
problems. Hence insulate the parts of the motor which may allow water to seep inside.
Teflon, Mseal or basic insulation tape can be used for insulation purpose.

Geared motors that you use will have several plastic gears inside them. If anyone gear cracks
or breaks your motor will not function satisfactorily. So handle the motors with care.

3.5.5 DC motors

Fig. 3.5.5

25

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


An electric motor uses electrical energy to produce mechanical energy, very typically through
the interaction of magnetic fields and current-carrying conductors. The reverse process,
producing electrical energy from mechanical energy, is accomplished by a generator or
dynamo. Many types of electric motors can be run as generators, and vice versa. For example
a starter/generator for a gas turbine or Traction motors used on vehicles often perform both
tasks.
Electric motors are found in applications as diverse as industrial fans, blowers and pumps,
machine tools, household appliances, power tools, and disk drives. They may be powered by
direct current (for example a battery powered portable device or motor vehicle), or by
alternating current from a central electrical distribution grid. The smallest motors may be
found in electric wristwatches. Medium-size motors of highly standardized dimensions and
characteristics provide convenient mechanical power for industrial uses. The very largest
electric motors are used for propulsion of large ships, and for such purposes as pipeline
compressors, with ratings in the millions of watts. Electric motors may be classified by the
source of electric power, by their internal construction, by their application, or by the type of
motion they give.
The physical principle of production of mechanical force by the interactions of an electric
current and a magnetic field was known as early as 1821. Electric motors of increasing
efficiency were constructed throughout the 19th century, but commercial exploitation of
electric motors on a large scale required efficient electrical generators and electrical
distribution networks.
Some devices, such as magnetic solenoids and loudspeakers, although they generate some
mechanical power, are not generally referred to as electric motors, and are usually termed
actuators and transducers, respectively.

3.5.6 Brushless DC motors


Some of the problems of the brushed DC motor are eliminated in the brushless design. In this
motor, the mechanical "rotating switch" or commutate or brushgear assembly is replaced by
an external electronic switch synchronised to the rotor's position. Brushless motors are
typically 85-90% efficient or more (higher efficiency for a brushless electric motor of up to

26

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


96.5% were reported by researchers at the Tokai University in Japan in 2009),[16] whereas
DC motors with brushgear are typically 75-80% efficient.
Midway between ordinary DC motors and stepper motors lies the realm of the brushless DC
motor. Built in a fashion very similar to stepper motors, these often use a permanent magnet
external rotor, three phases of driving coils, one or more Hall Effect sensors to sense the
position of the rotor, and the associated drive electronics. The coils are activated, one phase
after the other, by the drive electronics as cued by the signals from either Hall effect sensors
or from the back EMF (electromotive force) of the un-driven coils. In effect, they act as
three-phase synchronous motors containing their own variable-frequency drive electronics. A
specialized class of brushless DC motor controllers utilize EMF feedback through the main
phase connections instead of Hall Effect sensors to determine position and velocity. These
motors are used extensively in electric radio-controlled vehicles. When configured with the
magnets on the outside, these are referred to by modellers as out runner motors.
Brushless DC motors are commonly used where precise speed control is necessary, as in
computer disk drives or in video cassette recorders, the spindles within CD, CD-ROM (etc.)
drives, and mechanisms within office products such as fans, laser printers and photocopiers.
They have several advantages over conventional motors:
Compared to AC fans using shaded-pole motors, they are very efficient, running much cooler
than the equivalent AC motors. This cool operation leads to much-improved life of the fan's
bearings.
Without a commutator to wear out, the life of a DC brushless motor can be significantly
longer compared to a DC motor using brushes and a commutator. Commutation also tends to
cause a great deal of electrical and RF noise; without a commutator or brushes, a brushless
motor may be used in electrically sensitive devices like audio equipment or computers.
The same Hall Effect sensors that provide the commutation can also provide a convenient
tachometer signal for closed-loop control (servo-controlled) applications. In fans, the
tachometer signal can be used to derive a "fan OK" signal.
The motor can be easily synchronized to an internal or external clock, leading to precise
speed control.

27

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Brushless motors have no chance of sparking, unlike brushed motors, making them better
suited to environments with volatile chemicals and fuels. Also, sparking generates ozone
which can accumulate in poorly ventilated buildings risking harm to occupants' health.
Brushless motors are usually used in small equipment such as computers and are generally
used to get rid of unwanted heat.
They are also very quiet motors which is an advantage if being used in equipment that is
affected by vibrations.
Modern DC brushless motors range in power from a fraction of a watt to many kilowatts.
Larger brushless motors up to about 100 kW rating are used in electric vehicles. They also
find significant use in high-performance electric model aircraft.

3.5.7 Coreless or ironless DC motors


Nothing in the design of any of the motors described above requires that the iron (steel)
portions of the rotor actually rotate; torque is exerted only on the windings of the
electromagnets. Taking advantage of this fact is the coreless or ironless DC motor, a
specialized form of a brush or brushless DC motor. Optimized for rapid acceleration, these
motors have a rotor that is constructed without any iron core. The rotor can take the form of a
winding-filled cylinder, or a self-supporting structure comprising only the magnet wire and
the bonding material. The rotor can fit inside the stator magnets; a magnetically-soft
stationary cylinder inside the rotor provides a return path for the stator magnetic flux. A
second arrangement has the rotor winding basket surrounding the stator magnets. In that
design, the rotor fits inside a magnetically-soft cylinder that can serve as the housing for the
motor, and likewise provides a return path for the flux.
Because the rotor is much lighter in weight (mass) than a conventional rotor formed from
copper windings on steel laminations, the rotor can accelerate much more rapidly, often
achieving a mechanical time constant under 1 Ms. This is especially true if the windings use
aluminium rather than the heavier copper. But because there is no metal mass in the rotor to
act as a heat sink, even small coreless motors must often be cooled by forced air.

28

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Related limited-travel actuators have no core and a bonded coil placed between the poles of
high-flux thin permanent magnets. These are the fast head positioners for rigid-disk ("hard
disk") drives.

3.5.8 Printed Armature or Pancake DC Motors


A rather unique motor design the pancake/printed armature motor has the windings shaped as
a disc running between arrays of high-flux magnets, arranged in a circle, facing the rotor and
forming an axial air gap. This design is commonly known the pancake motor because of its
extremely flat profile, although the technology has had many brand names since its inception,
such as Servo Disc.
The printed armature (originally formed on a printed circuit board) in a printed armature
motor is made from punched copper sheets that are laminated together using advanced
composites to form a thin rigid disc. The printed armature has a unique construction, in the
brushed motor world, in that is does not have a separate ring commutator. The brushes run
directly on the armature surface making the whole design very compact.
An alternative manufacturing method is to use wound copper wire laid flat with a central
conventional commutator, in a flower and petal shape. The windings are typically stabilized
by being impregnated with electrical epoxy potting systems. These are filled epoxies that
have moderate mixed viscosity and a long gel time. They are highlighted by low shrinkage
and low exothermic, and are typically UL 1446 recognized as a potting compound for use up
to 180C (Class H) (UL File No. E 210549).
The unique advantage of ironless DC motors is that there is no cogging (vibration caused by
attraction between the iron and the magnets) and parasitic eddy currents cannot form in the
rotor as it is totally ironless. This can greatly improve efficiency, but variable-speed
controllers must use a higher switching rate (>40 kHz) or direct current because of the
decreased electromagnetic induction.
These motors were originally invented to drive the capstan(s) of magnetic tape drives, in the
burgeoning computer industry. Pancake motors are still widely used in high-performance
servo-controlled systems, humanoid robotic systems, industrial automation and medical

29

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


devices. Due to the variety of constructions now available the technology is used in
applications from high temperature military to low cost pump and basic servo applications.

3.5.9 Universal motors


A series-wound motor is referred to as a universal motor when it has been designed to operate
on either AC or DC power. The ability to operate on AC is because the current in both the
field and the armature (and hence the resultant magnetic fields) will alternate (reverse
polarity) in synchronism, and hence the resulting mechanical force will occur in a constant
direction.
Operating at normal power line frequencies, universal motors are very rarely larger than one
kilowatt (about 1.3 horsepower). Universal motors also form the basis of the traditional
railway traction motor in electric railways. In this application, to keep their electrical
efficiency high, they were operated from very low frequency AC supplies, with 25 and 16.7
hertz (Hz) operation being common. Because they are universal motors, locomotives using
this design were also commonly capable of operating from a third rail powered by DC.
An advantage of the universal motor is that AC supplies may be used on motors which have
some characteristics more common in DC motors, specifically high starting torque and very
compact design if high running speeds are used. The negative aspect is the maintenance and
short life problems caused by the commutator. As a result, such motors are usually used in
AC devices such as food mixers and power tools which are used only intermittently, and
often have high starting-torque demands. Continuous speed control of a universal motor
running on AC is easily obtained by use of a thyristor circuit, while (imprecise) stepped speed
control can be accomplished using multiple taps on the field coil. Household blenders that
advertise many speeds frequently combine a field coil with several taps and a diode that can
be inserted in series with the motor (causing the motor to run on half-wave rectified AC).
Universal motors generally run at high speeds, making them useful for appliances such as
blenders, vacuum cleaners, and hair dryers where high RPM operation is desirable. They are
also commonly used in portable power tools, such as drills, circular and jig saws, where the
motor's characteristics work well. Many vacuum cleaner and weed trimmer motors exceed
10,000 RPM, while Dremel and other similar miniature grinders will often exceed 30,000
RPM.
30

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Motor damage may occur due to over speeding (running at an RPM in excess of design
limits) if the unit is operated with no significant load. On larger motors, sudden loss of load is
to be avoided, and the possibility of such an occurrence is incorporated into the motor's
protection and control schemes. In some smaller applications, a fan blade attached to the shaft
often acts as an artificial load to limit the motor speed to a safe value, as well as a means to
circulate cooling airflow over the armature and field windings.

3.5.10 Servo motors


A servomechanism, or servo is an automatic device that uses error-sensing feedback to
correct the performance of a mechanism. The term correctly applies only to systems where
the feedback or error-correction signals help control mechanical position or other parameters.
For example, an automotive power window control is not a servomechanism, as there is no
automatic feedback that controls positionthe operator does this by observation. By contrast
the car's cruise control uses closed loop feedback, which classifies it as a servomechanism.
A servomechanism is unique among control systems in that it controls a parameter by
commanding the time-based derivative of that parameter. For example, a servomechanism
controlling position must be capable of changing the velocity of the system because the timebased derivative (rate change) of position is velocity. A hydraulic actuator controlled by a
spool valve and a position sensor is a good example because the velocity of the actuator is
proportional to the error signal of the position sensor.
A servomechanism may or may not use a servomotor. For example, a household furnace
controlled by a thermostat is a servomechanism, yet there is no motor being controlled
directly by the servomechanism.
A common type of servo provides position control. Servos are commonly electrical or
partially electronic in nature, using an electric motor as the primary means of creating
mechanical force. Other types of servos use hydraulics, pneumatics, or magnetic principles.
Usually, servos operate on the principle of negative feedback, where the control input is
compared to the actual position of the mechanical system as measured by some sort of
transducer at the output. Any difference between the actual and wanted values (an "error
signal") is amplified and used to drive the system in the direction necessary to reduce or
eliminate the error. This procedure is one widely used application of control theory.
31

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Servomechanisms were first used in military fire-control and marine navigation equipment.
Today servomechanisms are used in automatic machine tools, satellite-tracking antennas,
remote control airplanes, automatic navigation systems on boats and planes, and antiaircraftgun control systems. Other examples are fly-by-wire systems in aircraft which use servos to
actuate the aircraft's control surfaces, and radio-controlled models which use RC servos for
the same purpose. Many autofocus cameras also use a servomechanism to accurately move
the lens, and thus adjust the focus. A modern hard disk drive has a magnetic servo system
with sub-micrometer positioning accuracy.
Typical servos give a rotary (angular) output. Linear types are common as well, using a screw
thread or a linear motor to give linear motion.
Another device commonly referred to as a servo is used in automobiles to amplify the
steering or braking force applied by the driver. However, these devices are not true servos,
but rather mechanical amplifiers. (See also Power steering or Vacuum servo.)
In industrial machines, servos are used to perform complex motion.
A stepper motor (or step motor) is a brushless, synchronous electric motor that can divide a
full rotation into a large number of steps. The motor's position can be controlled precisely
without any feedback mechanism (see Open-loop controller), as long as the motor is carefully
sized to the application. Stepper motors are similar to switched reluctance motors (which are
very large stepping motors with a reduced pole count, and generally are closed-loop
commutated.)

3.5.11 Fundamentals of Operation


Stepper motors operate differently from DC brush motors, which rotate when voltage is
applied to their terminals. Stepper motors, on the other hand, effectively have multiple
"toothed" electromagnets arranged around a central gear-shaped piece of iron. The
electromagnets are energized by an external control circuit, such as a microcontroller. To
make the motor shaft turn, first one electromagnet is given power, which makes the gear's
teeth magnetically attracted to the electromagnet's teeth. When the gear's teeth are thus
aligned to the first electromagnet, they are slightly offset from the next electromagnet. So
when the next electromagnet is turned on and the first is turned off, the gear rotates slightly to
32

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


align with the next one, and from there the process is repeated. Each of those slight rotations
is called a "step," with an integer number of steps making a full rotation. In that way, the
motor can be turned by a precise angle.

3.5.12 differential steering


The steering system used here is a skid steering or to be precise differential steering as
parallel tracks are used on either side of vehicle. To generate a turn, the wheels on each side
of the vehicle are driven at different velocities. The different velocities define the turning
radius of the robot.

Fig. 3.5.12

33

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


By using a symmetrical design and driving the tracks on either side at equal velocities in
opposing directions, the units turning centre will coincide with its geometric centre as shown
in below fig.

Fig no 3.5.13

This provides high manoeuvrability as the unit is capable of turning on a fixed point. The
major disadvantage is the power required to perform a turn, especially on a stationary
position, as the wheels must move in a lateral direction as well as moving forward. This
increases power consumption, forces that the design must withstand, and the wear on the
tires/tracks. Skid steering is therefore most suitable for applications involving rough terrain,
and/or terrain with a loose or soft surface. A skid steered vehicle which is symmetric about its
axis has an advantage of equal manoeuvrability in either a forward or reverse direction

3.6 Optocoupler:
Optocoupler is a coupling component used commonly in feedback control loop circuits for
power supply equipment. Its high failure risk causes in most cases the breakdown of the
whole equipment. Different types of accelerated endurance tests samples and order to
determine the best fault signature of the components and accurate analytical model for the
aging of Optocoupler I supposed. The Optocoupler is an optoelectronics component of high
failure risk. It is generally used for conveying analogy info. Across a power supply isolation
barrier. This isolation is assured by an optical coupling between the input and the output
which is necessary for persons safety for example in medical equipment or to avoid
electromagnetic noise disturbance. For example between power electronic and control
circuits. The outer casing is a moulding compound impervious to light. The photo transmitter
is light emitting diode and the phototransistor can be made of different types (photodiode,

34

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


phototransistor, photo Darlington, phototirac) the simplest scheme of the Optocoupler is
given in fig.

Fig 3.6

The data received from the parallel port is not connected directly to the motor driver circuit to
avoid loading effect. So to avoid loading, an opt-coupler IC MCT2E is used for each bit of
data. This provides isolation between the computer and the circuit. In this IC, LED is used
with a photo transistor

3.7 LM7805 Series Voltage Regulators


Voltage Regulator: A voltage regulator is an electrical regulator designed to automatically
maintain a constant voltage level. It may use an electromechanical mechanism, or passive or
active electronic components. Depending on the design, it may be used to regulate one or
more AC or DC voltages. With the exception of shunt regulators, all voltage regulators
operate by comparing the actual output voltage to some internal fixed reference voltage. Any
difference is amplified and used to control the regulation element. This forms a negative
feedback servo control loop. If the output voltage is too low, the regulation element is
commanded to produce a higher voltage. If the output voltage is too high, the regulation
element is commanded to produce a lower voltage. In this way, the output voltage is held
roughly constant.

35

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig 3.7

3.7.1 General Description


The LM78XX series of three terminal regulators is available with several fixed output
voltages making them useful in a wide range of applications. One of these is local on card
regulation, eliminating the distribution problems associated with single point regulation. The
voltages available allow these regulators to be used in logic systems, instrumentation, HiFi,
and other solid-state electronic equipment. Although designed primarily as fixed voltage
regulators these devices can be used with external components to obtain adjustable voltages
and currents. The LM78XX series is available in an aluminumTO-3 package, which will
allow over 1.0A load current if adequate heat sinking is provided. Current limiting is included
to limit the peak output current to a safe value. Safe area protection for the output transistor is
provided to limit internal power dissipation. If internal power dissipation becomes too high
for the heat sinking provided, the thermal shutdown circuit takes over preventing the IC from
overheating. Considerable effort was expanded to make the LM78XX series of regulators
easy to use and minimize the number of external components. It is not necessary to bypass
the output, although this does improve transient response. Input bypassing is needed only if
the regulator is located far from the filter capacitor of the power supply. For output voltage
other than 5V, 12V and 15V the LM117series provides an output voltage range from 1.2V to
57V.

36

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

3.7.2 Features
Output current in excess of 1A
Internal thermal overload protection
No external components required
Output transistor safe area protection
Internal short circuit current limit
Available in the aluminium TO-3 package

Voltage Range

LM7805C 5V
LM7812C 12V
LM7815C 15V

3.7.3 Typical Application Circuit

Fig 3.7.3

In our project we require power supply of 5V. From the mains supply we get 230V, 50 Hz.
So to convert that configuration into the required configuration we need to use following
circuits with signal conditioners:

37

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


STEP DOWN TRANSFORMER
FULL WAVE BRIDGE RECTIFIER
FILTER CONDENSER
D.C. REGULATED 3 PIN I .C.

Transformer here used is the Centre tapped step down transformer. The primary winding
turns are greater than that of the secondary. Input supply to primary is 230V, 50 Hz that
produces the 0-24V at the secondary. Secondary of the transformer is connected to the full
wave bridge rectifier. It gives unipolar waveform of the transformer output. It converts the
a.c. supply into D.C. voltage.
Output at the bridge rectifier is:
Vdc=2*(Vin)/pi
V (rms) =Vm/2

But output obtained from the rectifier is not complete ripple free and contains the ac nature.
Thus it needs to be smoothened using Filter condenser. Here the capacitor assembly allows
only its rated voltage through it for one cycle. Property of capacitor to be insensitive to the
high frequency at the input side helps to have smooth output. Sometimes, due to mains power
supply fluctuation and the ageing of the circuit components the output fails to remain at
constant level. Thus we need to add the voltage regulators.

Due to the high voltage operating temperatures there may be heat generation, which leads to
the sparks or may even catch fire and damage the whole circuitry. Thus we use heat sink. All
the output is then connected to the connector to provide the supply for remaining circuit.

3.8 P.C.B. Construction


A Printed Circuit Board (P.C.B.) can be defined as an insulating base material to which is
permanently attached a flat metallic network of conducting paths whose dimension depends upon
the current that can be handled by them. The P.C.B. may be either single sided or double sided.
The P.C.B. used for this project is single sided one.
The basic material used may be resin coated papers, fiber glass, ceramic and the flat board
configuration however is most widely used and it may be of the nature of the single Mother
38

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Board into which smaller boards are plugged by the especially designed connectors which
ensures adequate and permanent low resistance coupling.

3.8.1 Board Design:


PCB designing is the most important and requires great care during work. In this case great care
must be taken while tracing the circuit or layout on the board. Because once PCB is designed, it
is virtually impossible to alter it. While designing a circuit, designer should take care to avoid
crossing of conducting paths (tracks) as possible. Crossovers are unavoidable then only of the
jumper can be used. A circuit board carrying copper on both sides can also help to solve this
problem when circuit is complicated.

3.8.2 The Master Diagram:


The next stage lies in proportion to designing i.e. to prepare Master Diagram, which is
commonly made twice as the finished circuit, since this makes the working on that much easier,
especially when circuit is complicated photography eventually reduces the size of diagram to that
of the circuit, before proceeding we must know some rules regarding the designing:1)

The space between the conductors must be strictly controlled to avoid the possibility of

electrical discharge or unwanted capacitance. The amount by which the master diagram is to
reduce in size is thus a critical design feature.
2)

The conductor must be wider in those parts of the circuits that are going to handle large

currents must be handle without undue temperature of conductors.


3)

The minimum width of copper should not generally be less than

About 1.5mm. This is related to mechanical strength rather than electrical properties and it also
ensures that strips remains securely bounded to the base material.
4)

The points where the component holes for component lead wire occurs must be sited to

suit the dimensions of the component and dimensions between lead-out wires, so that, the
components can be situated correctly on finished board. The conductor is also men large at the
point of holes.

3.8.3 P.C.B.Making:
When the master diagram probable twice the size of real PCB has been evolved, the text major
step consists of etching or dissolving the unwanted metal from copper cladded board to create the
circuit as depicted by master diagram. It must be stressed that very accurate checking of master is
39

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


essential at this stage. Then, the master point is mounted on a special frame on easy facing of a
larger camera and with the aid of the very powerful illumination a master diagram is clearly
photographed on a glass sensitive plate. This is developed to give photographic negative. Next
so called step and repeat camera. Is brought into operation. This comprises the camera body
mounted so that sideways after each exposure. In this way number of copies of the original
master diagram is set out exactly to cover standard sheet of copper clad laminate laboratory
method of making PCB.

3.8.4 In case of simple and need of number of less PCB, economic and
advisable to use the following lab method of PCB making.
1. Planning the circuit:Although this is not particularly difficult. There are several important factors that need not be
taken into account, if the finished device is to work properly we must consider gain factor and
ensure that the input and output parts are sufficiently well isolated to avoid the possibility. We
must also ensure that conductors and components carrying high frequency current are well
separated from these parts of the circuits. We are also to make sure that all components need to
return to earth are properly connected and that possibility of common impedance arising in earth
returned. Circuit is totally eliminated by making all earth as substantial as possible consistent
with nature of design. Other factors that have to successfully studied include availability of
adequate return points on board and its mounting from accessibility of switch connections made
for mechanical fixing ventilation effect of vibration.
2. Cleaning the Board:The copper side of the board must be thoroughly cleaned before Circuit plan is transferred to it.
This is very important because even slightest trace of graze (from figure of instance) will impure
the etching process and when the circuit plan has been neatly transferred to copper in this manner
the board is held under, running tap and the allowed to dry before resist is applied.

3. Transforming the Plan:Now, once cleaning is done plan has to transfer on copper surface of PCB material. A convenient
way to do this is simply put a carbon paper between a copper surface of the board and working
plan and carefully trace the lines of original plan with a ball pen.

40

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


4. Resist:Resist is nothing more than a substrate that is unaffected by presence etching chemicals. It is
usually colored so that, it can be easily seen the copper surface. When plan is clearly worked on
clean copper the a that are to be left in fact as the copper conductors must be covered when resists
the leaguer type of paints possess good resist properties but disadvantages of relatively long time
taken for drying. It is essential to resist through hardening before etching is started. Nail polished
are better as they quickly and are less difficult to remove.
To overcome this drying effect and to achieve the sharp edges of the trace on PCB. Now a-days
etching taps along with IC pads are commonly used. To this, chances of short circulating due to
paints are completely the avoid etching tapes and pads are available in different sizes.
5. Correcting errors:When a result has been thoroughly hardened any errors that have been made can usually be
corrected by gently scratching away with knife. To ensure clear out lines round edges of copper
conductors on board the resist must be applied with steady band.
6. Etching:Next comes etching of unwanted copper and whether a small single is all that is required as
quantity of board to be produce certain precautions must be taken before operation is commenced
the most used etch ant I ferric chloride and to this is added small quantity of HCL to accelerate.
But not critical as lab construction is concerned. Mixing 10 grams of ferric chloride and 25 grams
of HCL with 15 grams of water can produce a good etchant.

7. Agitation:Small plastic bath is ideal for storing the etchant process. The Depth of liquid must be sufficient
to completely cover laminate, the laminated board carrying the resist pattern circuit is then
dropped into etchant bath and the gentle agitation takes 5 to 20 minutes to complete depending on
the strength of the enchant temperature and thickness of copper foil.
8. Finishing Off:When all unwanted copper is dissolved from areas between conductors, board should be taken
from an etchant and washed in water. The resist must be removed using proper solvent. After
this the copper surface must be polished with any kind of cleaner. It should be seen that there is
41

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


no slight incomplete etching between the conducting paths of the PCB. The PCBs are coated
coating material for protection in lab coating material itself is a soldier. This process is called
Tinning. This process of coating involves tracks with soldier. Advantage of tinning the effect of
environment of conductors, then PCB is drilled i.e. holes for filling and mounting the components
on PCB are drilled with suitable drill bit.
9. Assembling Of PCB:After the holes are drilled, the components have to be assembled On PCB before assembling the
components it is necessary to clean soldering iron in order to get easy and accurate soldering.
Removing impurity particles that are gathered on iron bit due to repetitive use cleans soldering
iron.

3.9 Touch Sensor


The touch sensor module is based around the limit switch. This module is able to detect
obstacles when it bumps into it. The module gives an active low output when it detects an
obstacle. The output remains low for a time interval determined by IC555 timer.

Fig 3.9

42

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Explanation
When the limit switch is pressed it provides negative pulse to pin 2 of IC1, triggering the IC.
IC1, commonly used as a timer, is wired here as a monostable multivibrator. Trigging of IC1
causes pin 3 to go high and it remains high for a certain time period depending on the
selected values of R7 and C3. This on time (T) of IC1 can be calculated using the following
relationship:
T=1.1R7.C3 seconds where R7 is in ohms and C3 in microfarads. On first clap, output pin 3
of IC1 goes high and remains in this standby position for the pre-set time. Also, LED1 glows
for this period. The output of IC1 provides supply voltage to micro controller.

43

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

CHAPTER 4.ANALYSIS/ SYNTHESIS AND RESULTS


4.1 Color model
A color model is an abstract mathematical model describing the way colors can be
represented as tuples of numbers, typically as three or four values or color components. When
this model is associated with a precise description of how the components are to be
interpreted (viewing conditions, etc.), the resulting set of colors is called color space. This
section describes ways in which human color vision can be modeled

4.1.1 RGB color model


The RGB color model is an additive color model in which red, green, and blue light are
added together in various ways to reproduce a broad array of colors. The name of the model
comes from the initials of the three additive primary colors, red, green, and blue.
The main purpose of the RGB color model is for the sensing, representation, and display of
images in electronic systems, such as televisions and computers, though it has also been used
in conventional photography. Before the electronic age, the RGB color model already had a
solid theory behind it, based in human perception of colors.
RGB is a device-dependent color space: different devices detect or reproduce a given RGB
value differently, since the color elements (such as phosphors or dyes) and their response to
the individual R, G, and B levels vary from manufacturer to manufacturer, or even in the
same device over time. Thus an RGB value does not define the same color across devices
without some kind of color management.
Typical RGB input devices are color TV and video cameras, image scanners, and digital
cameras. Typical RGB output devices are TV sets of various technologies (CRT, LCD,
plasma, etc.), computer and mobile phone displays, video projectors, multicolor LED
displays, and large screens as JumboTron, etc. Color printers, on the other hand, are not RGB
devices, but subtractive color devices (typically CMYK color model).

44

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig .4.1.1

A representation of additive color mixing.


RGB COLOR SPACE
An RGB color space can be easily understood by thinking of it as "all possible colors" that
can be made from three colorants for red, green and blue. Imagine, for example, shining three
lights together onto a white wall: one red light, one green light, and one blue light, each with
dimmer switches. If only the red light is on, the wall will look red. If only the green light is
on, the wall will look green. If the red and green lights are on together, the wall will look
yellow. Dim the red light some and the wall will become more of a yellow-green. Dim the
green light instead, and the wall will become more orange. Bringing up the blue light a bit
will cause the orange to become less saturated and more whitish. In all, each setting of the
three dimmer switches will produce a different result, either in color or in brightness or both.
The set of all possible results is the gamut defined by those particular color light bulbs. Swap
out the red light bulb for one of a different brand that is slightly more orange, and there will
be slightly different gamut, since the set of all colors that can be produced with the three
lights will be changed.

45

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


An LCD display can be thought of as a grid of thousands of little red, green, and blue light
bulbs, each with their own dimmer switch. The gamut of the display will depend on the three
colors used for the red, green and blue lights. A wide-gamut display will have very saturated
"pure" light colors, and thus be able to display very saturated, deep color.

sass
Fig.4.1.2
RGB COLOR SPACE

RGB Cube
Physical principles for the choice of red, green, and blue
The choice of primary colors is related to the physiology of the human eye; good primaries
are stimuli that maximize the difference between the responses of the cone cells of the human
retina to light of different wavelengths, and that thereby make a large color triangle.

46

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


The normal three kinds of light-sensitive photoreceptor cells in the human eye (cone cells)
respond most to yellow (long wavelength or L), green (medium or M), and violet (short or S)
light (peak wavelengths near 570 nm, 540 nm and 440 nm, respectively). The difference in
the signals received from the three kinds allows the brain to differentiate a wide gamut of
different colors, while being most sensitive (overall) to yellowish-green light and to
differences between hues in the green-to-orange region.
As an example, suppose that light in the orange range of wavelengths (approximately 577 nm
to 597 nm) enters the eye and strikes the retina. Light of these wavelengths would activate
both the medium and long wavelength cones of the retina, but not equally the longwavelength cells will respond more. The difference in the response can be detected by the
brain and associated with the concept that the light is orange. In this sense, the orange
appearance of objects is simply the result of light from the object entering our eye and
stimulating the relevant kinds of cones simultaneously but to different degrees.
Use of the three primary colors is not sufficient to reproduce all colors; only colors within the
color triangle defined by the chromaticities of the primaries can be reproduced by additive
mixing of non-negative amounts of those colors of light

Fig no 4.1.3
Color triangle feasible with primary color

47

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Set of primary colors, such as the RGB primaries, define a color triangle; only colors within
this triangle can be reproduced by mixing the primary colors. Colors outside the color
triangle are therefore shown here as gray. The primaries and the D65 white point of RGB are
shown in fig.
Subtractive Colors
Subtractive colors are seen when pigments in an object absorb certain wavelengths of white
light while reflecting the rest. We see examples of this all around us. Any colored object,
whether natural or man-made, absorbs some wavelengths of light and reflects or transmits
others; the wavelengths left in the reflected/transmitted light make up the color we see.
This is the nature of color print production and cyan, magenta, and yellow, as used in fourcolor process printing, are considered to be the subtractive primaries. The subtractive color
model in printing operates not only with CMY (K), but also with spot colors, that is, premixed inks.

4.2 CMYK color model


The CMYK color model (process color, four color) is a subtractive color model, used in color
printing, and is also used to describe the printing process itself. CMYK refers to the four inks
used in some color printing: cyan, magenta, yellow, and key black. Though it varies by print
house, press operator, press manufacturer and press run, ink is typically applied in the order
of the abbreviation.

Fig.4.2
48

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


The K in CMYK stands for key since in four-color printing cyan, magenta, and yellow
printing plates are carefully keyed or aligned with the key of the black key plate. Some
sources suggest that the K in CMYK comes from the last letter in "black" and was chosen
because B already means blue. However, this explanation, though plausible and useful as a
mnemonic, is incorrect.
The CMYK model works by partially or entirely masking colors on a lighter, usually white,
background. The ink reduces the light that would otherwise be reflected. Such a model is
called subtractive because inks subtract brightness from white.
In additive color models such as RGB, white is the additive combination of all primary
colored lights, while black is the absence of light. In the CMYK model, it is the opposite:
white is the natural color of the paper or other background, while black results from a full
combination of colored inks. To save money on ink, and to produce deeper black tones,
unsaturated and dark colors are produced by using black ink instead of the combination of
cyan, magenta and yellow.

Fig no.4.2
Cyan, magenta, yellow, and key (black).

4.3 Conversion
Since RGB and CMYK spaces are both device-dependent spaces, there is no simple or
general conversion formula that converts between them.

4.4 PIXEL CONNECTIVITY


49

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


In image processing and image recognition, pixel connectivity is the way in which pixels in
2- or 3-dimensional images relate to their neighbors.
Types of connectivity
2-dimensional connectivity
4-connected
4-Connected pixels are neighbours to every pixel that touches one of their edges. These
pixels are connected horizontally and vertically. In terms of pixel coordinates, every pixel
that has the coordinates
Or

is connected to the pixel at

6-connected
6-connected pixels are neighbours to every pixel that touches one of their corners (which
includes pixels that touch one of their edges) in a hexagonal grid or stretcher bond
rectangular grid.
There are several ways to map hexagonal tiles to integer pixel coordinates. With one method,
in addition to the 4-connected pixels, the two pixels at coordinates
are connected to the pixel at

and

8-connected
8-connected pixels are neighbours to every pixel that touches one of their edges or corners.
These pixels are connected horizontally, vertically, and diagonally. In addition to 4Connected pixels, each pixel with coordinates
connected to the pixel at

50

or

is

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

3-dimensional connectivity
6-connected
6-connected pixels are neighbours to every pixel that touches one of their faces. These pixels
are

connected

along

coordinates
at

one

of

the

primary

or

axes.

Each

pixel

with

is connected to the pixel

18-connected
18-connected pixels are neighbours to every pixel that touches one of their faces or edges.
These pixels are connected along either one or two of the primary axes. In addition to 6Connected

pixels,

each

pixel

coordinates
,
at

, or

with

is connected to the pixel

26-connected
26-connected pixels are neighbours to every pixel that touches one of their faces, edges, or
corners. These pixels are connected along either one, two, or all three of the primary axes. In
addition

to

18-Connected

coordinates

pixels,

each

pixel

, or

,
,

is connected to the pixel at

51

with

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

4.5 THRESHOLDING
Thresholding is the simplest method of image segmentation. From a grayscale image,
thresholding can be used to create binary images

Original image.

Thresholded image

Fig 4.5
During the thresholding process, individual pixels in an image are marked as object pixels
if their value is greater than some threshold value (assuming an object to be brighter than the
background) and as background pixels otherwise. This convention is known as threshold
above. Variants include threshold below, which is opposite of threshold above; threshold
inside, where a pixel is labeled "object" if its value is between two thresholds; and threshold
52

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


outside, which is the opposite of threshold inside. Typically, an object pixel is given a value
of 1 while a background pixel is given a value of 0. Finally, a binary image is created by
coloring each pixel white or black, depending on a pixel's label.

4.5.1 Threshold selection


The key parameter in the thresholding process is the choice of the threshold value (or values,
as mentioned earlier). Several different methods for choosing a threshold exist; users can
manually choose a threshold value, or a thresholding algorithm can compute a value
automatically, which is known as automatic thresholding. A simple method would be to
choose the mean or median value, the rationale being that if the object pixels are brighter than
the background, they should also be brighter than the average. In a noiseless image with
uniform background and object values, the mean or median will work well as the threshold,
however, this will generally not be the case. A more sophisticated approach might be to
create a histogram of the image pixel intensities and use the valley point as the threshold. The
histogram approach assumes that there is some average value for the background and object
pixels, but that the actual pixel values have some variation around these average values.
However, this may be computationally expensive, and image histograms may not have
clearly defined valley points, often making the selection of an accurate threshold difficult.
One method that is relatively simple, does not require much specific knowledge of the image,
and is robust against image noise, is the following iterative method:
1. An initial threshold (T) is chosen, this can be done randomly or according to any other
method desired.
2. The image is segmented into object and background pixels as described above,
creating two sets:
1.

G1 = {f(m,n):f(m,n)>T} (object pixels)

2.

G2 = {f(m,n):f(m,n)

T} (background pixels) (note, f(m,n) is the value of the

pixel located in the mth column, nth row)


3. The average of each set is computed.
1.

m1 = average value of G1

2.

m2 = average value of G2

4. A new threshold is created that is the average of m1 and m2


53

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


1. T = (m1 + m2)/2
5. Go back to step two, now using the new threshold computed in step four, keep
repeating until the new threshold matches the one before it (i.e. until convergence has
been reached).
This iterative algorithm is a special one-dimensional case of the k-means clustering
algorithm, which has been proven to converge at a local minimummeaning that a different
initial threshold may give a different final result.

4.5.2 Categorizing thresholding Methods


Thresholding methods can be classifieds into the following six groups based on the
information the algorithm manipulates "histogram shape-based methods, where, for example,
the peaks, valleys and curvatures of the smoothed histogram are analyzed

clustering-based methods, where the gray-level samples are clustered in two parts as
background and foreground (object), or alternately are modeled as a mixture of two
Gaussians

entropy-based methods result in algorithms that use the entropy of the foreground and
background regions, the cross-entropy between the original and binarized image, etc.

Object attribute-based methods search a measure of similarity between the gray-level


and the binarized images, such as fuzzy shape similarity, edge coincidence, etc.

spatial methods that use higher-order probability distribution and/or correlation


between pixels

Local-methods adapt the threshold value on each pixel to the local image
characteristics."

4.5.3 Multiband thresholding


Color images can also be thresholded. One approach is to designate a separate threshold for
each of the RGB components of the image and then combine them with an AND operation.
This reflects the way the camera works and how the data is stored in the computer, but it does
not correspond to the way that people recognize color. Therefore, the HSL and HSV color
models are more often used. An interesting new method uses the CMYK color model to
threshold color images.
54

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

4.5.4 Common Applications


Thresholding is the most common method of segmenting images into particle regions and
background regions. A typical processing procedure would start with filtering or other
enhancements to sharpen the boundaries between objects and their background. Then, the
objects are separated from the background using thresholding.

4.6 Autonomous Object Tracking System


Vision is the most important of all senses. It became imperative that autonomous
robot masters the skill of vision. The object tracking system is a device that tracks the object
continuously.
It forms a base for various applications such as missile detection and tracking, enemy
detection and tracking and random object tracking.

Basic Block Diagram of Image Processing


Fig.4.6
Image acquisition setup: It consists of a web camera with suitable interface for
connecting it to PC.
Processor: It consists of personal computer or a dedicated image processing unit.
Image analysis: Certain tools are used to analyse the content in the image captured and
derive conclusions e.g. Matlab 7.0
Machine control: After making the conclusion, mechanical action is to be taken e.g. using
parallel port of a PC to control the robot.

55

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

4.7 Flowchart:

Fig .4.7

4.8

ALGORITHM
Step 1: Firstly it initialize the webcam

Step 2: It captures frame from webcam i.e. it takes a snapshot.

56

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Step 3: Select green matrix from the acquired RGB image
I.e. to convert 4D image to 2D image

Step 4: Color threshold image as per requirement i.e. Threshold so as to select the target.

Step 5: After color threshold there are various blobs including the target blob which is large is
size. Thus to select the target blob we run the largest blob selection routine.

Step 6: Find the centroid of the target, so as to find the Middle mass.

Step 7: The image is divided into nine sectors. Thus we have to find in which sector the
Centroid lies. If it is centre then no need to track the target but if it is not in centre
Then we have to drive motors so as to bring centroid in centre.

The image is divided into nine sectors as shown in figure:

Fig.4.8.1

The frame captured by webcam is as shown in figure:

57

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig.4.8.2

The green matrix of RGB image is as show in figure:

Fig.4.8.3

The threshold image is as shown in figure:

58

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig.4.8.4

The Largest blob selected is as shown in figure:

Fig.4.8.5

The centroid (149,175) is as shown in figure:

Fig.4.8.6
59

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


The location of centroid on south sector:

Fig.4.8.7

Thus the Matlab will send the data to the parallel port so as to drive the motor to bring the
centroid into centre sector. In this case motor will be driven to move camera UP.

Fig.4.8.8

As our project is PC controlled there is a 25 Pin Parallel PC port, which is the output
from PC, to which the device is connected.
BUFFER FOR ISSOLATION: - This block is used to isolate micro controller with PC
in order to minimize the loading effect which will take place on the motherboard of
computer and might damage it.
MOTOR DRIVER: - This block takes various commands from the Micro controller
and gives commands to the different motors that will run the device. Basically this
block will drive the whole assembly of motors
60

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


D C MOTORS:-These motors will receive commands from the PC through motor
driver and will drive the two axes of camera.
MECHANICAL ASSEMBLIES: - There are two axes to provide two motions
UP/Down and LEFT/Right of the camera.

4.9 Overview
Image Acquisition Toolbox implements an object-oriented approach to image acquisition.
Using toolbox functions, you create an object that represents the connection between
MATLAB and specific image acquisition devices. Using properties of the object you can
control various aspects of the acquisition process, such as the amount of video data you want
to capture. Connecting to Hardware describes how to create objects. Once you establish a
connection to a device, you can acquire image data by executing a trigger.
In the toolbox, all image acquisition is initiated by a trigger. The toolbox supports several
types of triggers that let you control when an acquisition takes place. For example, using
hardware triggers you can synchronize an acquisition with an external device.
Acquiring Image Data describes how to trigger the acquisition of image data. To work with
the data you acquire, you must bring it into the MATLAB workspace. When the frames are
acquired, the toolbox stores them in a memory buffer. The toolbox provides several ways to
bring one or more frames of data into the workspace where you can manipulate it as you
would any other multidimensional numeric array.
Working with Acquired Image Data describes this process. Finally, you can enhance your
image acquisition application by using event call-backs. The toolbox has defined certain
occurrences, such as the triggering of an acquisition, as events. You can associate the
execution of a particular function with a particular event. Using Events and Call-backs
describes this process. Toolbox Components The toolbox uses components called hardware
device adaptors to connect to devices through their drivers. The toolbox includes adaptors
that support devices produced by several vendors of image acquisition equipment. In
addition, the toolbox includes an adaptor for generic Windows video acquisition devices. The
following figure shows these components and their relationship. Image Overview When a
trigger occurs, the toolbox sets the object's Logging property to 'on' and starts storing the
acquired frames in a buffer in memory, a disk file, or both. When the acquisition stops, the
toolbox sets the object's Logging property to 'off'.

61

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Image Acquisition Toolbox lets you acquire images and video directly into MATLAB and
Simulink from PC-compatible imaging hardware. You can detect hardware automatically,
configure hardware properties, preview an acquisition, and acquire images and video. With
support for multiple hardware vendors, you can use a range of imaging devices, from
inexpensive Web cameras or industrial frame grabbers to high-end scientific cameras that
meet low-light, high-speed, and other challenging requirements.
Together, MATLAB, Image Acquisition Toolbox, and Image Processing Toolbox provide
a complete environment for developing customized imaging applications. You can acquire
images and video, visualize data, develop processing algorithms and analysis techniques, and
create graphical user interfaces.
You can use Image Acquisition Toolbox with Simulink and Video and Image Processing
Block set to simulate and model real-time embedded imaging systems.

4.9.1 Key Features

Automatically detects image and video acquisition devices

Manages device configurations

Provides live video previewing

Acquires static images and continuous video

Enables in-the-loop image processing and analysis

Provides graphical user interface for working with devices

Supports devices for use with MATLAB and Simulink

Supports multiple hardware vendors

4.9.2 Working with Image Acquisition Toolbox


Image Acquisition Toolbox helps you connect to and configure your hardware, preview the
acquisition, and acquire and visualize image data. You can use the toolbox from the Image
Acquisition Tool, the MATLAB command line, or the From Video Device block within
Simulink. This lets you control your image acquisition parameters and incorporate them into
MATLAB scripts, applications built within MATLAB, or Simulink models.

62

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Within the toolbox, the Image Acquisition Tool is a graphical user interface for working with
image and video acquisition devices in MATLAB. With this tool, you can see all hardware
available on your PC, change device settings, preview an acquisition, control acquisition
parameters, and acquire image or video data. You can also record data directly to an AVI file
or export hardware configuration settings to an M-file so that you can incorporate them into
other MATLAB scripts.

4.9.3 Connecting to Hardware


Image Acquisition Toolbox automatically detects compatible image and video acquisition
devices. The connection to your devices is encapsulated as an object, providing an interface
for configuration and acquisition. You can create multiple connection objects for
simultaneous acquisition from as many devices as your PC and imaging hardware support.

4.9.4 Configuring Hardware


The toolbox provides a consistent interface across multiple hardware devices and vendors,
simplifying the configuration process. You configure your hardware by using the Image
Acquisition Tool or by modifying the properties of the object associated with the hardware on
the MATLAB command line. The toolbox also supports camera files from hardware vendors.
You can set base properties that are common to all supported hardware. These properties can
include video format, resolution, region of interest (ROI), and returned color space. You can
also set device-specific properties, such as hue, saturation, brightness, frame rate, contrast,
and video sync, if your device supports these properties.

4.9.5 Previewing the Acquisition


The Image Acquisition Toolbox video preview window helps you verify and optimize your
acquisition parameters. It instantly reflects any adjustments that you make to acquisition
properties. The Image Acquisition Tool has a built-in preview window, and you can add one
to any application built with MATLAB.

63

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

4.9.6 Acquiring Image Data


Image Acquisition Toolbox can continuously acquire image data while you are processing the
acquired data in MATLAB or Simulink. The toolbox automatically buffers acquired data into
memory, handles memory and buffer management, and enables acquisition from an ROI.
Data can be acquired in a wide range of data types, including signed or unsigned 8-, 16-, and
32-bit integers and single- or double-precision floating point. The toolbox supports any color
space provided by the image acquisition device, such as RGB, YUV, or grayscale. Raw
sensor data in a Bayer pattern can be automatically converted into RGB data. The toolbox
supports any frame rate and video resolution supported by your PC and imaging hardware.

4.9.7Image Acquisition Example


This example illustrates how you can perform complex image acquisition operations using
only a few lines of MATLAB code. We first acquire a single video frame from a scientific
video camera. Next, using standard MATLAB functions, we perform an edge enhancement
on the acquired video frame and visualize the result as a three-dimensional surface plot.
A typical image acquisition session consists of the following four steps:
1.

Creationcreating a video input object

2.

Configurationcontrolling acquisition behaviour by setting object properties and

previewing the results


3.

Acquisitionstarting the video input object and acquiring and processing data

4.

Clean-updeleting the video input object

The following sample script maps to these steps.


Step 1: Creation
First, we create a video input object named vid using the video input function. We
associate the video input object with a particular hardware device by passing the device's
identification number to the function. For our example, the scientific video cameras device
identification number is 1. For information on how to scan for devices and determine their
identification number, see the tutorial, Accessing Devices and Video Sources.

64

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


vid = videoinput(winvideo, 1);

Step 2: Configuration
Next, we open a preview window and adjust the cameras brightness setting. To obtain a
listing of all the configurable properties of a video object, see the tutorial, working with
Properties.
preview(vid);
set(vid.source,Brightness,100);

Fig.4.9.7
Step 3: Acquisition
We use the getsnapshot command to acquire a single video frame from the camera. For
information on how to perform a multiframe acquisition, see the tutorial, Logging Data to
Memory.
data = getsnapshot(vid);

Now, we extract the red color band from the acquired frame and apply a Sobel edge
enhancement filter. The toolbox acquires video frames in RGB format by default, and
represents RGB data as a three-dimensional array consisting of height x width x color band.
For more information on advanced image processing functions, refer to Image Processing
Toolbox Web pages.

65

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


red = data(:, : ,1);
filtered = filter2(fspecial('sobel'), red);

Here, we visualize the filtered data as a three-dimensional surface and apply various
formatting. For more information on advanced visualization methods, see the documentation
on the MATLAB Web pages.
surf(filtered);
shading(interp);colormap(hot);colorbar;

Fig.4.9.7
Step 4: Clean up
We delete and clear the video input object from the MATLAB workspace to free up memory.
delete(vid);
clear vid;

4.9.8 General-Purpose Objects


Video input objects have one or more video source objects associated with them. In this table,
functions that work on both types of objects use the phrase "image acquisition object" to refer
to both types of objects.

66

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


Clear

Clear image acquisition object from MATLAB workspace

Delete

Remove image acquisition object from memory

disp

Display method for image acquisition objects

get

Return image acquisition object properties

getselectedsource

Return currently selected video source object

imaqfind

Find image acquisition objects

islogging

Determine whether video input object is logging

isrunning

Determine whether video input object is running

isvalid

Determine whether image acquisition object is associated with image


acquisition device

load

Load image acquisition object into MATLAB workspace

obj2mfile

Convert video input objects to MATLAB code

save

Save image acquisition objects to MAT-file

set

Configure or display image acquisition object properties

start

Obtain exclusive use of image acquisition device

stop

Stop video input object

videoinput

Create video input object

wait

Wait until image acquisition object stops running or logging

Triggering
trigger

Initiate data logging

triggerconfig

Configure video input object trigger properties

triggerinfo

Provide information about available trigger configurations

Data
flushdata

Remove data from memory buffer used to store acquired image

67

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


frames
getdata

Acquired image frames to MATLAB workspace

getsnapshot

Immediately return single image frame

peekdata

Most recently acquired image data

Tools
closepreview

Close Video Preview window

imaqhelp

Image acquisition object function and property help

Imaqhwinfo

Information about available image acquisition hardware

imaqmem

Limit memory or display memory usage for Image Acquisition


Toolbox software

imaqmontage

Sequence of image frames as montage

imaqreset

Disconnect and delete all image acquisition objects

imaqtool

Launch Image Acquisition Tool

preview

Preview of live video data

Propinfo

Property characteristics for image acquisition objects

Stoppreview

Stop previewing video data

4.9.9 Getting Command-Line Function Help


To get command-line function help, you can use the MATLAB help function. For example,
to get help for the getsnapshot function, type the following:
help getsnapshot
However, the Image Acquisition Toolbox software provides "overloaded" versions of several
MATLAB functions. That is, it provides toolbox-specific implementations of these functions
using the same function name.

68

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


For example, the Image Acquisition Toolbox software provides an overloaded version of the
delete

function. You get help for the MATLAB version of this function if you type the

following:
help delete
You can determine if a function is overloaded by examining the last section of the help. For
delete,

the help contains the following overloaded versions (not all are shown):

Overloaded methods
help char/delete.m
help scribehandle/delete.m
help scribehgobj/delete.m
.
.
.

help imaqdevice/delete.m
To obtain help on the Image Acquisition Toolbox version of this function, type the following:
help imaqdevice/delete
To avoid having to specify which overloaded version you want to view, use the imaqhelp
function:
imaqhelp delete

Getting hardware information


[1] Determining device adaptor name
An adaptor is the software the toolbox uses to communicate with an image acquisition device
via its device driver. The toolbox includes adaptors for some vendors of image acquisition
equipment and for particular classes of image acquisition devices. For the latest information
about supported hardware, visit the Image Acquisition Toolbox product page at the Math
Works Web site (www.mathworks.com/products/imaq).To determine which adaptors are
available on your system, call the imaqhwinfo function. The imaqhwinfo function returns

69

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


information about the toolbox software and lists the adaptors available on the system in the
InstalledAdaptors field. In this example, there are two adaptors available on the system.

imaqhwinfo
ans =

InstalledAdaptors: {'matrox' 'winvideo'}


MATLABVersion: '7.4 (R2007a)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '2.1 (R2007a)'

[2] Determining device ID

The adaptor assigns a unique number to each device with which it can communicate. The
adaptor assigns the first device it detects the device ID 1, the second it detects the device ID
2, and so on. To find the device ID of a particular image acquisition device, call the
imaqhwinfo function, specifying the name of the adaptor as the only argument. When called
with this syntax, imaqhwinfo returns a structure containing information about all the devices
available through the specified adaptor.

info = imaqhwinfo('matrox');
info =

AdaptorDllName: [1x73 char]


AdaptorDllVersion: '2.1 (R2007a)'
AdaptorName: 'matrox'
DeviceIDs: {[1]}
DeviceInfo: [1x1 struct]

[3] Getting more information about a particular device


If an adaptor provides access to multiple devices, you might need to find out more
information about the devices before you can select a device ID. The DeviceInfo field is an
70

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


array of device information structures. Each device information structure contains detailed
information about a particular device available through the adaptor.To view the information
for a particular device, you can use the device ID as a reference into the DeviceInfo structure
array. Call imaqhwinfo again, this time specifying a device ID as an argument.

dev_info = imaqhwinfo('matrox',1)

dev_info =

DefaultFormat: 'M_RS170'
DeviceFileSupported: 1
DeviceName: 'Orion'
DeviceID: 1
ObjectConstructor: 'videoinput('matrox', 1)'
SupportedFormats: {1x10 cell}

Most trigger properties can be set using the same methods you use to set any other image
acquisition object property: using the set function or referencing the property as you would a
field in a structure. For example, you can use the set function to specify the value of the
TriggerRepeat property, where vid is a video input object created using the videoinput
function.set(vid,'TriggerRepeat',Inf). Some trigger properties, however, are interrelated and
require the use of the triggerconfig function to set their values. These properties are the
TriggerType, TriggerCondition, and TriggerSource properties. For example, some
TriggerCondition values are only valid when the value of the TriggerType property
Is'hardware'.
Specifying the trigger type
Trigger type value

Trigger source and trigger Description


condition values

immediate

Always none

The

trigger

automatically,

occurs
immediately

after the start function is


issued. This is the default
trigger type

71

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


manual

Always none

The trigger occurs when you


issue the trigger function.
A manual trigger can provide
more control over image
acquisition. For example,
you can monitor the video
stream being acquired, using
the preview function,
and manually execute the
trigger when you observe a
particular condition in
the scene

hardware

Device-specific

Hardware
external

triggers
signals

are

that

are

processed directly
by the hardware. This type of
trigger

is

used

when

synchronization with another


device is part of the image
acquisition setup or when
speed is required. A
hardware device can process
an input signal much faster
than software

4.10 ARENA
Our project comprises of an arena which will be black in colour of dimensions by .
It will have white coloured markings at distances from each other to denote the coordinates at that point. The robot uses these markings to navigate itself on the arena. The coordinates of the destination are pre-fed in the robot memory using a program and the coordinates of the location of the object are calculated by the robot itself on the basis of the coordinates of the centroid of object it gets from image processing.

72

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


The arena has different objects of different colours kept at different co-ordinates. The robot
identifies the object possessing Green colour and performs the relevant calculations to find its
co-ordinates. Once that is done, it will decide the path to be followed to reach those coordinates without any hindrance.
The arena and the robot vision are affected by the current illumination conditions prevailing
in the room. Care must be taken that the place is considerably lit.
The arena can be shown as follows-

Fig 4.10
The co-ordinates of the object location i.e. the blue block square, is identified by the robotic
arm on its own by image processing depending on the colour of the object.
The co-ordinates of the location are to be fed to the robotic arm by programming. The coordinates of the location are shown by the black square in the above arena.

73

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Fig.4.10(a)

Objective

There can be three different shapes of objects: Circle, Square and Equilateral Triangle

The shape of the hoops will be circular annular rings of different colours whose RGB
values will be provided. The RGB values for the single colour used for objects will
also be provided.

The robot has to start from a START point and place the objects in the respective
hoops as per the rules provided below. After completion of task, it has to move
towards the nearest END point corner to exit the arena.
74

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

START point can be at any of the four corners.

END point is any other corner except the START point.

The figures in the end indicate the sample arena details the dimensions of the
elements used within the arena.

The background of the arena will be black in colour.

The arena will be completely plain without hindrance to the movement of the robot

The objects will be of optimum weight so that it can be easily carried away by a robot.

Robot details

The computer provided by us will have MATLAB v7.6+ on windows platform.

The computer will have USB, parallel ports or serial ports for communication.
Preferably, it is advised to use Parallel Port for communication.

Few of the resolutions that the camera will support for image acquisition are 640x480,
800x600 and 1600x1200.

The camera will have USB connectivity to a computer.

Fig.4.11

75

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

CHAPTER 5.CONCLUSION AND FUTURE SCOPE


5.1FUTURE SCOPE
Object detecting robotic arm is the epithet of Autonomous ROBOT .It can be modified in
different ways to be employed in many applications which are as follows

5.1.1 Military Robots


Military Robots are autonomous robots or remote-controlled devices designed for military
applications. Such systems are currently being researched by a number of militaries. Already
remarkable success has been achieved with unmanned aerial vehicles like the Predator drone,
which are capable of taking surveillance photographs, and even accurately launching missiles
at ground targets, without a pilot. A subclass of these are Unmanned Combat Air Vehicles,
which are designed to carry out strike missions in combat.US Mechatronics has produced a
working automated sentry gun and is currently developing it further for commercial and
military use

MIDARS, a four-wheeled robot outfitted with several cameras, radar, and possibly a firearm,
that automatically performs random or preprogramed patrols around a military base or other
government installation. It alerts a human overseer when it detects movement in unauthorized
areas, or other programmed conditions. The operator can then instruct the robot to ignore the
event, or take over remote control to deal with an intruder, or to get better camera views of an
emergency. The robot would also regularly scan radio frequency identification tags (RFID)
placed on stored inventory as it passed and report any missing items.
The Defense Advanced Research Projects Agency (DARPA) is the central research and
development organization for the Dept. of Defense. The DARPA "Distributed Robotics
Program" seeks to work with qualified companies to develop tiny, biologically-inspired robot
designs and new methods of robot control for military applications. DARPA is particularly
interested in micro-miniature robots because they can be produced at relatively low unit cost and
offer unique mission advantages. They can be carried and deployed by individuals and small
teams to augment human capability, perform hazardous missions, and accomplish tasks that
previously could not be the goal is to develop tiny, nimble devices that can, for example,

76

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


surreptitiously spy on enemy troops, explore the surface of Mars or safely monitor dangerous
chemical spills.

5.1.2 Unmanned Aerial Vehicle


NASA's Mars

Exploration

Rover

Mission (MER),

is

an

ongoing robotic

space

mission involving two rovers, Spirit and Opportunity, exploring the planet Mars. It began in
2003 with the sending of the two rovers MER-A Spirit and MER-B Opportunity to
explore the Martian surface and geology.
The mission's scientific objective was to search for and characterize a wide range of
rocks and soils that hold clues to past water activity on Mars. The mission was part of
NASA's Mars Exploration Program which includes three previous successful landers: the
two Viking program landers in 1976 and Mars Pathfinder probe in 1997.

5.1.3 Robot with Sensors


Solar-powered autonomous robot with sensors able to detect microorganisms and map the
distribution of life in the Atacama Desert of northern Chile, duplicating tasks that could be
used in future exploration of Mars.
A Robot for Search and Rescue (SAR) operations, designed to operate in outdoors hazardous
environments, such as debris resulting from structure collapses. At this stage, the robot is
equipped for search operations only, defined as the tele-operated detection of victims, using
specific sensors, whose information is transmitted to the remote operator. The robot
equipment (sensors) may be adapted to the specific needs. At the moment it includes 3
conventional cameras, one thermal camera, several explosive and toxic gas sensors,
temperature and humidity sensors, inclinometers, artificial lights, microphone and speakers.

5.1.4 Industrial Robots


Industrial Robots with Image Processing in the Industry for example Photovoltaic Industry
The photovoltaic industry already has a potential that not only warrants but encourages the
use of automation technology. Using industrial robots brings shorter processing times, lower
wage costs, less fracture and therefore higher cost effectiveness. In recent years most
manufacturers who have invested in this technology have done so with great success. The
use of robotics in the solar industry is becoming increasingly important as manufacturers
strive to lower their costs by creating solutions for the efficient production of solar cells and

77

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


modules. As they adopt automation it is vital for manufacturers to choose reliable partners
and efficient products right from the start

5.1.5 Food and chemical industry


Biological and chemical samples, in either liquid or solid state, are stored in vials, plates or
tubes. Often, they need to be frozen and/or sealed to avoid contamination or to retain their
biological and/or chemical properties. Specifically, the life science industry has standardized
on a plate format, known as the microtiter plate, to store such samples.
A number of companies have developed robots to specifically handle SBS microplates. Such
robots may be liquid handlers which aspirates or dispenses liquid samples from and to these
plates, or "plate movers" which transport them between instruments.
Instrument companies have designed plate readers which can carry out detect specific
biological, chemical or physical events in samples stored in these plates. These readers
typically use optical and/or computer vision techniques to evaluate the contents of the
microtiter plate wells.

78

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

5.2 CONCLUSION
The existing method available for Pick and place is either manually or by using a computer
controlled robot. The setup implemented provides a hassle free method for the job by making
use of image processing implemented using colour detection.
When a computer controlled robot is used it will always have a human engaged to manoeuvre
it. This automation limits the flexibility of Robotics. The flexibility of the robot can be
further increased by inculcating artificial intelligence in it with the help of image processing.
While utilizing this setup in a chemical and fertilizer manufacturing factory, which regularly
deals with various hazardous chemicals, the robot is of great help in managing these and also
in waste management of toxic waste. This can be done without putting human life to risk and
human intervention to control it.
The image processing capability of the robot helps the robot to identify the chemical of
interest as it has been pre-programmed to identify liquid or hazardous materials of a
particular colour.
The project can be further modified by using proper materials for making the body of the
robot so that it does not react with the chemicals to be handled. Also we could mount
appropriate gas sensors on the robot to detect any gas leakage.

79

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Appendices
Object detection program based upon colour
a=imread('a.jpg')
g=a(:,:,2);
imview(g);
log=roicolor(g,120,220);
imview(log);
[lab,num]=bwlabel(log,8);
sizeBlob = zeros(1,num);
for i=1:num,
sizeblob(i) = length(find(lab==i));
end
[maxno largestBlobNo] = max(sizeblob);
outim = zeros(size(log),'uint8');
outim(find(lab==largestBlobNo)) = 1;
last=255*outim;
last_bw=bwlabel(last,8);
%%%% largest blob stop %%%%%%%
%imview(log);
imshow(last);
s=sum(sum(last));
cen=regionprops(last_bw,'centroid');
%to find centriod
cent=cen.Centroid;
% to find centriod
cent=round(cent);
%to round the centriod value

80

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Microcontroller program
org 0000h
mov p1,#00h
mov p3,#0ffh
mov sp,#50h
ljmp main

main:
lcall bot
lcall motor
sjmp main

bot:

lk1:

lk2:

mov a,p3
anl a,#07h
cjne a,#01h, lk1
setb p1.7
clr p1.6
ret
cjne a,#02h, lk2
setb p1.6
clr p1.7
ret
clr p1.7
clr p1.6
ret

motor:
mov a,p3
anl a,#07h
cjne a,#04h, lk3
lcall down
lcall delay0_5
lcall stop
lcall delay0_5
lcall close
lcall delay0_5
81

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall stop
lcall delay0_5
lcall up
lcall delay0_5
lcall delay0_5
lcall stop
lcall delay0_5
lcall open
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall delay0_5
lcall stop
lcall delay0_5
lcall down
lcall delay0_5
lcall delay0_5
lcall stop
lcall delay0_5
ret
lk3:

clr p1.3
clr p1.2
clr p1.1
clr p1.0
ret

up:
setb p1.1
clr p1.0
82

Akshit Shetty/BE Inst/ImageProcessing and Object Detection


ret
down:
setb p1.0
clr p1.1
ret
open:
setb p1.3
clr p1.2
ret
close: setb p1.2
clr p1.3
ret
stop:

clr p1.3
clr p1.2
clr p1.1
clr p1.0
ret

delay0_5:
mov tmod,#01
mov r1,#7
back2: mov tl0,#00h
mov th0,#00h
setb tr0
again2:jnb tf0,again2
clr tr0
clr tf0
djnz r1,back2
ret

end

83

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Power supply

84

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

Optocoupler

L298

References:
85

Akshit Shetty/BE Inst/ImageProcessing and Object Detection

[1] Gonzalez, Rafael C. & Woods, Richard E. (2002). Thresholding. In Digital Image
Processing, pp. 595611. Pearson Education
[2] Introduction to Parallel Ports:
http://www.beyondlogic.org/spp/parallel.html
[3] Parallel port interfacing:
http://logix4u.net/Legacy_Ports/Parallel_Port/A_tutorial_on_Parallel_port_Interfacing.html
[4] Opto isolater:
http://www1.jaycar.com.au/images_uploaded/optocoup.pdf
[5] IC L298:
http://www.st.com/stonline/products/literature/ds/1773.pdf
[6] Voltage regulator:
http://www.national.com/mpf/LM/LM2825.html
[7] Robotic axes:
http://www.societyofrobots.com/robot_arm_tutorial.shtml#DOF
[8] Wikipedia.org

86

Potrebbero piacerti anche