You are on page 1of 85

EXPERT SYSTEMS AND SOLUTIONS

Email: expertsyssol@gmail.com
expertsyssol@yahoo.com
Cell: 9952749533
www.researchprojects.info
PAIYANOOR, OMR, CHENNAI
Call For Research Projects Final
year students of B.E in EEE, ECE,
EI, M.E (Power Systems), M.E
(Applied Electronics), M.E (Power
Electronics)
Ph.D Electrical and Electronics.
Students can assemble their hardware in our
Research labs. Experts will be guiding the
projects.

copyright© IIT Guwahati Roboti


cs Club
Robotics
Robotics Workshop
Workshop
II
The New Beginning
Question # 1
What is a robot??

An entity designed for some specific ‘Task’


In other words – Your imagination

copyright© IIT Guwahati Roboti


cs Club
Machines v/s Robots
Sensing Planning Acting

information action
about the on the
environment environment

copyright© IIT Guwahati Roboti


cs Club
Question # 2
What is ROBOTICS ???

The science of making a robot

But is it a Science or an Art ??

copyright© IIT Guwahati Roboti


cs Club
How Much Time do You Think A robot
Requires ???

Depends on what everyone says

copyright© IIT Guwahati Roboti


cs Club
What does a Robot consists of ??

• Mechanical Hardware
• Electronics Hardware
• Software

And the toughest part is ?? Why ?

copyright© IIT Guwahati Roboti


cs Club
Classification of Robotics
Three types:-
• Manual Robotics
• Semi-Autonomous Robotics
• Autonomous Robotics

copyright© IIT Guwahati Roboti


cs Club
Any thoughts about how tuff is making
an autonomous or semi-autonomous
robot???

Or which one is more tuff???

copyright© IIT Guwahati Roboti


cs Club
The Components of
Robot
Motor/Locomotion
system

Power Control
Management ROBOT
System

Sensors

copyright© IIT Guwahati Roboti


cs Club
Power - The Need
In any robotic system the basic need to
drive it is Power.
Can be obtained from:
• DC battery
• AC Mains
• IC Engines

Here we wont talk about IC engines for now

copyright© IIT Guwahati Roboti


cs Club
Power Management
One can use battery directly or use an
adapter/SMPS as the situation demands.

For Manual – Adapter if wired remote


– Battery if radio controlled
For Semi – Autonomous
SMPS if you can’t manage on a battery
For Autonomous
You have to manage on Battery

copyright© IIT Guwahati Roboti


cs Club
Power Management
For Battery the options available are
• Ni-Cd rechargeable batteries
providing around 700mA-hr each with
1.2V output.
• Emergency light battery 6V, 4A-hr, a
heavy option though confirms you
heavy duty.

copyright© IIT Guwahati Roboti


cs Club
Power Management
To operate the motors you will need higher
voltage supply than what is required by
general IC’s.
To derive all those voltage values from a
given voltage supply
• LM317, 7805 5V voltage regulator
• PT5048C, PT5049 12V voltage regulator

copyright© IIT Guwahati Roboti


cs Club
Moving a Robot
How will a robot move???
• Wheels
• Legs
• Wings

All these run on motors powered by battery


or IC engines.

copyright© IIT Guwahati Roboti


cs Club
Types Of Motors
• DC Motors
• AC Motors
• Stepper Motors
• Servo Motors
• IC Engines

copyright© IIT Guwahati Roboti


cs Club
DC Motors
• Run on DC power supply
• Can rotate in both directions
• To handle one has to control the
speed

copyright© IIT Guwahati Roboti


cs Club
DC Motors
• DC motors are low torque and high
speed devices
• Gear set can be used to increase
torque at the cost of speed
• The movement of the shaft is smooth
• Easiest to operate

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
• Direction of rotation of a dc motor
can be controlled by changing the
direction of voltage applied to the
motor

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
• How to drive a dc motor without using a
remote?
to drive a motor we need certain circuits
called Driver Circuits.
Driver Circuits act as an interface by
providing a link to main power supply based
on input signal
Readymade IC’s are available.

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
H-Bridge
It’s a circuit to allow the rotation of
motor in both the direction

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
Driving and Braking using H Bridge

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
H-Bridge in short

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
The Required IC – L293D (Quad Half H-Bridge)

copyright© IIT Guwahati Roboti


cs Club
H bridge using L293D

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
• Speed control can be managed by
controlling the Voltage across the
motor in other words by controlling
average power fed to the motor

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
• Voltage across a motor can be changed
using a resistor as a potential divider
But is energy inefficient as a lot of
useful power is wasted in resistor

• A better method is PWM (Pulse Width


Modulation)

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
PWM - It means to change the width
of a pulse train depending on the
control signal

copyright© IIT Guwahati Roboti


cs Club
Working of DC motor
How does PWM help in controlling
speed?
It can be understood as using a
typical average speed problem.
Technically the average power fed
to the motor is reduced thereby
decreasing the speed
copyright© IIT Guwahati Roboti
cs Club
Stepper Motors
Widely use in Robotics ---why??
• Because More precise than DC motor
• Measured rotation and can be held at
a particular position- U can rotate
the stepper motor with an accuracy
of 0.9 degree!!!!!!
• Alignment is much better...

copyright© IIT Guwahati Roboti


cs Club
Stepper Motors contd..

copyright© IIT Guwahati Roboti


cs Club
Types of Stepper Motors
• Mainly 2 types:
– Unipolar- Current can flow only in one
direction in the coils
– Bipolar- Current can flow in both the
directions

copyright© IIT Guwahati Roboti


cs Club
Comparison
• Unipolar • Bipolar

1. Current flow in 1. Current flow in both


one direction direction
2. Simple drive 2. Complicated drive
circuit Circuit
3. Less torque 3. High Torque

copyright© IIT Guwahati Roboti


cs Club
Modes of Operation
• Single Coil Excitation: Only one out of
the 4 coils is excited at a given time
• Double Coil: Two adjacent coils are
excited at a given time
• Single and Double: It’s a hybrid of
both..(refer diagram for details)

copyright© IIT Guwahati Roboti


cs Club
Stepper Motor basics
• The stepper motor contains a permanent
magnet which is attached to the shaft at
centre and there are 4 coils on the 4 sides
• Actually the stator contains 100 teeth to
get a step angle of
360/(2*100)=1.8degrees. But here for the
sake of simplicity, we are showing only one
tooth of stator. So don’t get misled into
believing that it’s step angle is 90 degrees

copyright© IIT Guwahati Roboti


cs Club
Single Coil Mode

copyright© IIT Guwahati Roboti


cs Club
Single coil Excitation
Note that until the next coil is
switched on, the stator
remains in it’s position only.
And as we can control when
to switch on a particular coil
thru software, we can rotate it
by exactly the angle we
wish.. Compare this with DC
motor where the shaft keeps
on rotating as soon as the
current is switched on

copyright© IIT Guwahati Roboti


cs Club
a. Single-Coil Excitation
Each successive coil is energized in turn.

copyright© IIT Guwahati Roboti


cs Club
Double coil Excitation

copyright© IIT Guwahati Roboti


cs Club
b. Two-Coil Excitation
Each successive pair of adjacent coils is
energized in turn.

copyright© IIT Guwahati Roboti


cs Club
Single and Double coil
Excitation

copyright© IIT Guwahati Roboti


cs Club
Interleaving the two
sequences will cause the
motor to half-step

copyright© IIT Guwahati Roboti


cs Club
Comparison
• Single coil • Double coil
1. Low torque 1. High torque
2. Consume less 2. Consume double
energy energy
3. Settling time is 3. Settling time is
more less
Note: The advantage of hybrid mode is that the step angle gets
halved.. So we can control the rotation with double precision

copyright© IIT Guwahati Roboti


cs Club
Circuit Diagram

copyright© IIT Guwahati Roboti


cs Club
Controlling motors thru
Computer
• Parallel Ports: It’s the easiest way to
control the motors from computer. No
complicated intermediate circuits are
required
• Serial/USB ports
• Bluetooth

* The last 2 modes are beyond the scope of this workshop

copyright© IIT Guwahati Roboti


cs Club
25-way Female D-Type
Connector

copyright© IIT Guwahati Roboti


cs Club
The pin configuration of the
other end of parallel port
connector

copyright© IIT Guwahati Roboti


cs Club
Pin details

copyright© IIT Guwahati Roboti


cs Club
Pin details contd.....

copyright© IIT Guwahati Roboti


cs Club
Pin Details
• D0-D7 are the data pins(used for
output)
• C0-C3 are control pins. Note that C1
and C3 are hardware inverted. They
can be used for both input and output
• S3-S7 are status pins. They are used
for taking input from external circuit

copyright© IIT Guwahati Roboti


cs Club
PC parallel Port
• The PC's Parallel Printer Port had a total of
12 digital outputs and 5 digital inputs
accessed via 3 consecutive 8-bit ports in the
processor's I/O space.
• 8 output pins accessed via the DATA Port
• 5 input pins (one inverted) accessed via the
STATUS Port
• 4 output pins (three inverted) accessed via
the CONTROL Port
• The remaining 8 pins are grounded
copyright© IIT Guwahati Roboti
cs Club
Controlling pins thru
program
• Almost every programming language has
commands to control the ports. For
example in Turbo C, we can use the
‘outportb’ function defined in dos.h
outportb(0x378,5)
0x378 is the address of the data pins of the parallel port.
The binary form of 5 will appear as an output in the data
pins
i.e the binary of 5 is 00000101. Therefore D0 and D2 are on
and rest pins are off. The ouput can be upto 2^8-1=255

copyright© IIT Guwahati Roboti


cs Club
Control pins
• The address for control pins can be
obtained by adding 2 to the address of
data pins. For eg, here the address of
control pins will be 0x378+0x2=0x37a
• Therefore the command
outportb(0x37a,3) will make both the 1st 2
control pins(C0,C1) low! Because 3=0011
and C0 and C1 are hardware inverted

copyright© IIT Guwahati Roboti


cs Club
Controlling DC motors by
H-Bridge

copyright© IIT Guwahati Roboti


cs Club
Implementation of H
bridge

copyright© IIT Guwahati Roboti


cs Club
Driving the DC motor

copyright© IIT Guwahati Roboti


cs Club
Connections for a
stepper motor

Data
Motor 1
Port1

Data Motor 2
Port2

Note –connect a 15v zener diode to pin 10 of IC as shown to prevent damage


to the IC due to "back emf" when loads such as motors switch on and off
copyright© IIT Guwahati Roboti
cs Club
Driving the Stepper
Motor
• In the following slides, we discuss
the code for driving the stepper
motor in various modes
– Single coil mode
– Double coil mode
– Hybrid mode

copyright© IIT Guwahati Roboti


cs Club
Single Coil Mode
The order of the values to be written to
parallel port(data pins)
00000001 – (1st coil is on) = 1
00000010 – (2nd coil is on) = 2
00000100 – (3rd coil is on) = 4
00001000 – (4th coil is on) = 8
For 2nd motor
00010000 – (1st coil is on) = 16
0010000 – (2nd coil is on) = 32
0100000 – (3rd coil is on) = 64
1000000 – (4th coil is on) = 128

copyright© IIT Guwahati Roboti


cs Club
Double Coil Mode
The order of the values to be written to
parallel port(data pins)
00000011 – (1st & 2nd coils are on) = 3
00000110 – (2nd & 3rd coils are on) = 6
00001100 – (3rd & 4th coils are on) = 12
00001001 – (4th & 1st coils are on) = 9
For 2nd motor
00110000 – (1st & 2nd coils are on) = 48
01100000 – (2nd & 3rd coils are on) = 96
11000000 – (3rd & 4th coils are on) = 192
10010000 – (4th & 1st coils are on) = 144

copyright© IIT Guwahati Roboti


cs Club
Hybrid mode
The order of the values to be written to parallel
port(data pins)
00000001 – (1st coil is on) = 1
00000011 – (1st & 2nd coil is on) = 3
00000010 – (2rd coil is on) = 2
00000110 – (2nd & 3rd coil is on) = 6
00000100 – (3st coil is on) = 4
00001100 – (4th & 3nd coil is on) = 12
00001000 – (4rd coil is on) = 8
00001001 – (1st & 4th coil is on) = 9

The values for the other coil can be determined by shifting the binary
representation by 4 places left or multiply the decimal values by 2^4=16

copyright© IIT Guwahati Roboti


cs Club
Sample codes to rotate in ccw
drn
//single coil mode //double coil //hybrid mode
#include <stdio.h> #include <stdio.h>
#include <stdio.h> #include <dos.h> #include <dos.h>
#include <dos.h>
main() main()
main()
{ char a[]={3,6,12,9}; { char
{ char a[]={1,2,4,8}; a[]={1,3,2,6,4,12,8,9};
for (int i=0;i<=100;i++) for (int i=0;i<=100;i+
+) for (int i=0;i<=100;i++)
{ outportb(888,a[i%4]);
delay(10); {outportb(888,a[i { outportb(888,a[i
%4]); %8]);
}
outportb(888,0); delay(10); delay(10);
} } }
outportb(888,0); outportb(888,0);
} }

copyright© IIT Guwahati Roboti


cs Club
Sample codes to rotate in cw drn
//single coil mode //double coil //hybrid mode
#include <stdio.h> #include <stdio.h>
#include <stdio.h> #include <dos.h> #include <dos.h>
#include <dos.h>
main() main()
main() { char a[]={3,6,12,9}; { char
{ char a[]={1,2,4,8}; a[]={1,3,2,6,4,12,8,9};
for (int
for (int i=100;i<=0;i--) i=100;i<=0;i--) for (int i=100;i<=0;i--)
{ outportb(888,a[i%4]);
{outportb(888,a[i { outportb(888,a[i
delay(10); %4]); %8]);
}
delay(10); delay(10);
outportb(888,0);
}
} }
outportb(888,0); outportb(888,0);
} }

copyright© IIT Guwahati Roboti


cs Club
Sample codes to move the robot
backward
//single coil mode //double coil //hybrid mode
#include <stdio.h> #include <stdio.h>
#include <stdio.h> #include <dos.h> #include <dos.h>
#include <dos.h> main() main()
main() { char a[]={3,6,12,9}; { char
{ char a[]={1,2,4,8}; a[]={1,3,2,6,4,12,8,9};
char
char char
b[]={16,32,64,128}; b[]={48,96,192,144};
b[]={16,48,32,96,64,192,
for (int i=100;i<=0;i--) for (int 128,144};
{ outportb(888,a[i%4]| i=100;i<=0;i--)
for (int i=100;i<=0;i--)
b[i%4]); {outportb(888,a[i { outportb(888,a[i%8]|
delay(10); %4]|b[i%4]); b[i%8]);
} delay(10); delay(10);
outportb(888,0); } }
} outportb(888,0); outportb(888,0);
} }

copyright© IIT Guwahati Roboti


cs Club
Sample codes to move the robot
forward
//hybrid mode
//single coil mode //double coil
#include <stdio.h>
#include <stdio.h>
#include <dos.h>
#include <stdio.h> #include <dos.h>
#include <dos.h>
main()
main()
main() { char
{ char a[]={3,6,12,9}; a[]={1,3,2,6,4,12,8,9
{ char a[]={1,2,4,8};
char };
char
b[]={16,32,64,128}; b[]={48,96,192,144}; char
for (int i=0;i<=100;i++) for (int i=0;i<=100;i+ b[]={16,48,32,96,64,1
{ outportb(888,a[i%4]| +) 92,128,144};
b[i%4]); {outportb(888,a[i for (int i=0;i<=100;i+
delay(10); %4]|b[i%4]); +)
} delay(10); { outportb(888,a[i
outportb(888,0); } %8]|b[i%8]);
} outportb(888,0); delay(10);
} }
outportb(888,0);
}
copyright© IIT Guwahati Roboti
cs Club
Sample codes to turn the bot left
//hybrid mode
//single coil mode //double coil #include <stdio.h>
#include <stdio.h> #include <dos.h>
#include <stdio.h> #include <dos.h> main()
#include <dos.h> main() { char
main() { char a[]={3,6,12,9}; a[]={1,3,2,6,4,12,8,9
{ char a[]={1,2,4,8}; char b[]={48,96,192,144}; };
char for (int i=0;i<=100;i+ char
b[]={16,32,64,128}; +) b[]={16,48,32,96,64,1
for (int i=0;i<=100;i++)
92,128,144};
{ outportb(888,a[(100- {outportb(888,a[(10
i)%4]|b[i%4]); for (int i=0;i<=100;i++)
0-i)%4]|b[i%4]);
delay(10);
delay(10); { outportb(888,a[(1
}
} 00-i)%8]|b[i%8]);
outportb(888,0);
} outportb(888,0); delay(10);
} }
outportb(888,0);
}
copyright© IIT Guwahati Roboti
cs Club
Sample codes to turn the bot right
//hybrid mode
//single coil mode //double coil #include <stdio.h>
#include <stdio.h> #include <dos.h>
#include <stdio.h> #include <dos.h> main()
#include <dos.h> main() { char
main() { char a[]={3,6,12,9}; a[]={1,3,2,6,4,12,8,9
{ char a[]={1,2,4,8}; };
char
char char
b[]={16,32,64,128}; b[]={48,96,192,144};
for (int i=0;i<=100;i++) for (int i=0;i<=100;i+ b[]={16,48,32,96,64,1
{ outportb(888,a[i%4]| +) 92,128,144};
b[(100-i)%4]); {outportb(888,a[i%4]| for (int i=0;i<=100;i+
delay(10); b[(100-i)%4]); +)
} delay(10); { outportb(888,a[i
outportb(888,0); } %8]|b[(100-i)%8]);
} outportb(888,0); delay(10);
} }
outportb(888,0);
}
copyright© IIT Guwahati Roboti
cs Club
Cracking Techno
Tennis....
Here we present some vague ideas for
developing your robot. Two important
considerations are:
• Basic movable base which can be
accurately positioned and moved in any
direction
• Hitting mechanism

copyright© IIT Guwahati Roboti


cs Club
If u use stepper motors
• The data pins D0-D3 will be connected to the
left motor and D4-D7 to the right one (or vice
versa)
• To control the hitting mechanism u can use
the 4 control pins. For example u can switch on
a control pin to trigger a flap mechanism. A
power amplifier must be used in between port
pins and devices involved in hitting mechanism

copyright© IIT Guwahati Roboti


cs Club
Please note....
Windows XP doesn’t allow to directly access the
parallel port so we have to use third party
drivers which opens the specific ports.One
such software is Userport.
http://www.embeddedtronics.com/public/Ele
Generally the address of the parallel port is
0x378-0x37F.If not the check its address in
the specific port properties in device manager.

copyright© IIT Guwahati Roboti


cs Club
PROGRAMMING
PROGRAMMING IN
IN MATLAB
MATLAB
• Basics of Matlab
• Image Capturing.
• Image Processing..
• Object Identification…
• Movement Algorithm….

copyright© IIT Guwahati Roboti


cs Club
Basics Of
Matlab
• Pre-declaration of variable is not necessary, you can use variable
whenever required.
• FOR loop
for i=1:n
body
end
• IF condition
if(condn)
statement
end
• Image is treated as an array in Matlab which can be in any
format like RGB,Grayscale,BW,Intensity.
• Function[output variables]=name(input variables).Function should
be written in an M-file.
• For calling function say ‘add’ type add(4,5) in the prompt.

copyright© IIT Guwahati Roboti


cs Club
Image Capturing.

• Make a video input object.


• Set various attributes of the object.
• Take Snap Shots.
• Save images in an array.

copyright© IIT Guwahati Roboti


cs Club
Image Capturing.
x=0;
T=0;
data=.2;
imaqreset;
imaqmem(inf);
vid=videoinput('winvideo',1,'RGB24_640x480');
set(vid,'FramesPerTrigger',Inf);
triggerconfig(vid, 'Immediate');
start(vid);
dio=digitalio('parallel','LPT1');% for enabling parallel ports
addline(dio,0:1,'out');

copyright© IIT Guwahati Roboti


cs Club
…….continued
for ui=1:10
f=getsnapshot(vid);
flushdata(vid);
end

disp('START');tic;
f=getsnapshot(vid);flushdata(vid);
prev_cen=0;
flag=0;
end_y=400;
start_y=40;
while x==0
T=T+1;
f=getsnapshot(vid);
{insert your code}
end
stop(vid);

copyright© IIT Guwahati Roboti


cs Club
Image Capturing.
• Preview a stream of image frames.
• preview(obj);

• Acquire and display a single image frame.

• frame = getsnapshot(obj);

• Remove video input object from memory.

• delete(obj);

copyright© IIT Guwahati Roboti


cs Club
Image Processing..
• imread : to read an image
eg i=imread(‘name.jpg’);

• imview : to view the image


eg imview(i);

• im2bw : converts a coloured image to black and


white
eg b=im2bw(i);
or b=im2bw(i,.4);

copyright© IIT Guwahati Roboti


cs Club
Image Processing..

RGB components
• For example, the red, green, and blue
color components of the pixel (10,5) are
stored in RGB(10,5,1), RGB(10,5,2), and
RGB(10,5,3), respectively.
eg
a=imread(‘name.jpg’);
r=a(:,:,1);
g=a(:,:,2);
b=a(:,:,3); copyright© IIT Guwahati Roboti
cs Club
Object identification
• imcrop(image)
• Im2bw(image)
• medfilt2(image)
• bwlabel(image)
Distinguishing the ball, robot, red square.
• regionprops – area,centroid,perimeter
• Ratio of area to sqr of perimeter will be
fixed number for a circular object.

copyright© IIT Guwahati Roboti


cs Club
• Take [R,G,B] components of image.
• Check for area where R >threshold &
G,B<threshold to identify red block.
• Use of rectangles of different shapes
or use different colors to identify the
orientation & position of robot.

copyright© IIT Guwahati Roboti


cs Club
Movement Algorithm
• Use of only 90 degrees turns for motion using
DC motor.
• Use of stepper motor to move along shortest
path.
• Implementation
At each step find the angle between ball and
direction of bot ‘α’.
If IαI < 45 deg. Then move bot
Repeat till bot hits ball.

copyright© IIT Guwahati Roboti


cs Club
MATLAB CODE
• dio=digitalio('parallel','LPT1');
• addline(dio,0:3,'out');
• putvalue(dio,[0 1 1 0]);
• Keep all the operating tactics of
steps same as shown in C

copyright© IIT Guwahati Roboti


cs Club
For any help contact
• Niraj Murarka(B2,329,Kameng)
niraj@iitg.ernet.in ; 9864167497
• Suhas Mishra(B4-206,Kameng)
m.suhas@iitg.ernet.in ; 9954248915
• Ashwin Chander(B4-211, Kameng)
m.venkata@iitg.ernet.in ; 9954249118     
• Abhishek Anand(B2-020,Kameng)
a.abhishek@iitg.ernet.in
• Romesh Khaddar (132,Dihing)
romesh@iitg.ernet.in

copyright© IIT Guwahati Roboti


cs Club

You might also like