robotics 4
TRANSCRIPT
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 1/85
copyright© IIT GuwahatiRobotics Club
EXPERT SYSTEMS AND SOLUTIONS
Email: [email protected]@yahoo.com
Cell: 9952749533www.r esea rchproj e ct s .infoPAIYANOOR, OMR, CHENNAI
Call For Research Projects Final year students of B.E in EEE, ECE, EI,
M.E (Power Systems), M.E (AppliedElectronics), M.E (Power Electronics)
Ph.D Electrical and Electronics.Students can assemble their hardware in our
Research labs. Experts will be guiding the projects .
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 2/85
Robotics WorkshopRobotics WorkshopIIRobotics WorkshopRobotics WorkshopII
The New BeginningThe New Beginning
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 3/85
copyright© IIT GuwahatiRobotics Club
Question # 1What is a robot??
An entity designed for some specific µTask¶
In other words ± Your imagination
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 4/85
copyright© IIT GuwahatiRobotics Club
Machines v/s RobotsSensing Planning Acting
informationabout theenvironment
actionon the
environment
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 5/85
copyright© IIT GuwahatiRobotics Club
Question # 2What is ROBOTICS ???
The science of making a robot
But is it a Science or an Art ??
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 6/85
copyright© IIT GuwahatiRobotics Club
How Much Time do You Think A robotRequires ???
Depends on what everyone says
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 7/85
copyright© IIT GuwahatiRobotics Club
What does a Robot consists of ??
Mechanical HardwareElectronics HardwareSoftware
And the toughest part is ?? Why ?
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 8/85
copyright© IIT GuwahatiRobotics Club
Classification of RoboticsThree types:-
Manual RoboticsSemi-Autonomous RoboticsAutonomous Robotics
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 9/85
copyright© IIT GuwahatiRobotics Club
Any thoughts about how tuff is makingan autonomous or semi-autonomousrobot???
Or which one is more tuff???
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 10/85
copyright© IIT GuwahatiRobotics Club
The Components ofRobot
ROBOTP ow r
M m t
Motor/Lo omotioy t m
or
Co troly t m
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 11/85
copyright© IIT GuwahatiRobotics Club
Power - The NeedIn any robotic system the basic need todrive it is Power.
Can be obtained from:DC batteryAC MainsIC Engines
Here we wont talk about IC engines for now
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 12/85
copyright© IIT GuwahatiRobotics Club
Power ManagementOne can use battery directly or use anadapter/SMPS as the situation demands.
For Manual ² Adapter if wired remote² Battery if radio controlled
For Semi ² AutonomousSMPS if you can·t manage on a battery
For AutonomousYou have to manage on Battery
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 13/85
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 14/85
copyright© IIT GuwahatiRobotics Club
Power ManagementTo operate the motors you will need higher
voltage supply than what is required by
general IC·s.To derive all those voltage values from agiven voltage supplyLM317, 7805 5V voltage regulatorPT5048C, PT5049 12V voltage regulator
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 15/85
copyright© IIT GuwahatiRobotics Club
Moving a RobotHow will a robot move???
WheelsLegsWings
All these run on motors powered bybattery or IC engines.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 16/85
copyright© IIT GuwahatiRobotics Club
Types Of MotorsDC MotorsAC MotorsStepper MotorsServo MotorsIC Engines
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 17/85
copyright© IIT GuwahatiRobotics Club
DC MotorsRun on DC power supplyCan rotate in both directionsTo handle one has to control the
speed
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 18/85
copyright© IIT GuwahatiRobotics Club
DC MotorsDC motors are low torque and high
speed devicesGear set can be used to increase
torque at the cost of speedThe movement of the shaft is smooth
Easiest to operate
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 19/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorDirection of rotation of a dc motor
can be controlled by changing thedirection of voltage applied to themotor
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 20/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorHow 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 supplybased on input signalReadymade IC·s are available.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 21/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorH-BridgeIt·s a c ircuit to allow the rotation ofmotor in both the direction
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 22/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorDriving and Braking using H Bridge
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 23/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorH-Bridge in short
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 24/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorThe Required IC ² L293D (Quad Half H-Bridge)
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 25/85
copyright© IIT GuwahatiRobotics Club
H bridge using L293D
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 26/85
copyright© IIT GuwahatiRobotics Club
Working of DC motor
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 27/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorSpeed control can be managed by
controlling the Voltage across themotor in other words by controllingaverage power fed to the motor
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 28/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorVoltage across a motor can be
changed using a resistor as apotential dividerBut is energy inefficient as a lot ofuseful power is wasted in resistor
A better method is PWM (PulseWidth Modulation)
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 29/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorPWM - It means to change the width
of a pulse train depending on thecontrol signal
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 30/85
copyright© IIT GuwahatiRobotics Club
Working of DC motorHow does PWM help in controlling
speed?
It can be understood as using atypical average speed problem.
Technically the average power fedto the motor is reduced therebydecreasing the speed
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 31/85
copyright© IIT GuwahatiRobotics Club
Stepper MotorsWidely use in Robotics ---why??Because More precise than DC motor
Measured rotation and can be held ata particular position- U can rotatethe stepper motor with an accuracyof 0.9 degree!!!!!!Alignment is much better...
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 32/85
copyright© IIT GuwahatiRobotics Club
Stepper Motors contd..
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 33/85
copyright© IIT GuwahatiRobotics Club
Types of Stepper MotorsMainly 2 types:² Unipolar- Current can flow only in one
direction in the coils² Bipolar- Current can flow in both the
directions
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 34/85
copyright© IIT GuwahatiRobotics Club
ComparisonUnipolar
1. Current flow inone direction
2. Simple drivecircuit
3. Less torque
Bipolar
1. Current flow inboth direction
2. Complicated driveCircuit
3. High Torque
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 35/85
copyright© IIT GuwahatiRobotics Club
Modes of OperationSingle Coil Excitation: Only one outof the 4 coils is excited at a given
timeDouble Coil: Two adjacent coils are
excited at a given time
Single and Double: It·s a hybrid ofboth..(refer diagram for details)
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 36/85
copyright© IIT GuwahatiRobotics Club
Stepper Motor basicsThe stepper motor contains a permanentmagnet which is attached to the shaft atcentre and there are 4 coils on the 4 sidesActually the stator contains 100 teeth to
get a step angle of360/(2*100)=1.8degrees. But here for thesake of simplicity, we are showing only onetooth of stator. So don·t get misled intobelieving that it·s step angle is 90 degrees
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 37/85
copyright© IIT GuwahatiRobotics Club
Single Coil Mode
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 38/85
copyright© IIT GuwahatiRobotics Club
Single coil ExcitationN ote that until the next coil isswitched on, the stator remains in it¶s position only.
And as we can control when
to switch on a particular coilthru software, we can rotate itby exactly the angle wewish.. Compare this with DCmotor where the shaft keepson rotating as soon as thecurrent is switched on
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 39/85
copyright© IIT GuwahatiRobotics Club
a. Single-Coil ExcitationEach successive coil is energized in turn.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 40/85
copyright© IIT GuwahatiRobotics Club
Double coil Excitation
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 41/85
copyright© IIT GuwahatiRobotics Club
b. Two-Coil Excitation
Each successive pair of adjacent coils isenergized in turn.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 42/85
copyright© IIT GuwahatiRobotics Club
Single and Double coil
Excitation
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 43/85
copyright© IIT GuwahatiRobotics Club
Interleaving the twosequences will cause the
motor to half-step
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 44/85
copyright© IIT GuwahatiRobotics Club
ComparisonS ingle coil
1. Low torque
2. Consume lessenergy
3. Settling time ismore
Double coil1. High torque
2. Consume doubleenergy
3. Settling time isless
N ote : The advantage of hybrid mode is that the step angle getshalved.. So we can control the rotation with double precision
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 45/85
copyright© IIT GuwahatiRobotics Club
Circuit Diagram
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 46/85
copyright© IIT GuwahatiRobotics Club
Controlling motors thru
ComputerParallel Ports: It·s the easiest way to
control the motors from computer. Nocomplicated intermediate circuits arerequiredSerial/USB portsBluetooth
* The last 2 modes are beyond the scope of this workshop
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 47/85
copyright© IIT GuwahatiRobotics Club
25-way Female D-Type
Connector
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 48/85
copyright© IIT GuwahatiRobotics Club
The pin configuration ofthe other end of parallel
port connector
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 49/85
copyright© IIT GuwahatiRobotics Club
Pin details
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 50/85
copyright© IIT GuwahatiRobotics Club
Pin details contd.....
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 51/85
copyright© IIT GuwahatiRobotics Club
Pin DetailsD0-D7 are the data pins(used foroutput)
C0-C3 are control pins. Note that C1and C3 are hardware inverted. Theycan be used for both input and output
S3-S7 are status pins. They are usedfor taking input from external circuit
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 52/85
copyright© IIT GuwahatiRobotics Club
PC parallel PortThe PC's Parallel Printer Port had a total of
12 digital outputs and 5 digital inputsaccessed via 3 consecutive 8-bit ports in the
processor's I/O space.8 output pins accessed via the DATA Port5 input pins (one inverted) accessed via the
STATUS Port4 output pins (three inverted) accessed via
the CONTROL PortThe remaining 8 pins are grounded
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 53/85
copyright© IIT GuwahatiRobotics Club
Controlling pins thru
programAlmost every programming language hascommands to control the ports. For
example in Turbo C, we can use the¶outportb· function defined in dos.houtportb(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
pinsi.e the binary of 5 is 00000101. Therefore D0 and D2 are onand rest pins are off. The ouput can be upto 2^8-1=255
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 54/85
copyright© IIT GuwahatiRobotics Club
Control pinsThe address for control pins can be
obtained by adding 2 to the address ofdata pins. For eg, here the address of
control pins will be 0x378+0x2=0x37aTherefore the commandoutportb(0x37a,3) will make both the 1 st 2control pins(C0,C1)low ! Because 3=0011
and C0 and C1 are hardware inverted
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 55/85
copyright© IIT GuwahatiRobotics Club
Controlling DC motors by H-
Bridge
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 56/85
copyright© IIT GuwahatiRobotics Club
Implementation of H
bridge
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 57/85
copyright© IIT GuwahatiRobotics Club
Driving the DC motor
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 58/85
copyright© IIT GuwahatiRobotics Club
Connections for a
stepper motor
DataPort1
DataPort2
Motor 1
Motor 2
N ote ²connect a 15v zener diode to pin 10 of IC as shown to prevent damageto the IC due to "back emf" when loads such as motors switch on and off
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 59/85
copyright© IIT GuwahatiRobotics Club
Driving the Stepper
MotorIn the following slides, we discussthe code for driving the stepper
motor in various modes² Single coil mode² Double coil mode² Hybrid mode
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 60/85
copyright© IIT GuwahatiRobotics Club
Single Coil ModeThe order of the values to be written to
parallel port(data pins)00000001 ² (1 st coil is on) = 1
00000010 ² (2nd
coil is on) = 200000100 ² (3 rd coil is on) = 400001000 ² (4 th coil is on) = 8For 2nd motor00010000 ² (1 st coil is on) = 16
0010000 ² (2nd
coil is on) = 320100000 ² (3 rd coil is on) = 641000000 ² (4 th coil is on) = 128
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 61/85
copyright© IIT GuwahatiRobotics Club
Double Coil ModeThe 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) = 600001100 ² (3 rd & 4th coils are on) = 1200001001 ² (4 th & 1st coils are on) = 9For 2nd motor00110000 ² (1st & 2nd coils are on) = 48
01100000 ² (2nd
& 3rd
coils are on) = 9611000000 ² (3 rd & 4th coils are on) = 19210010000 ² (4 th & 1st coils are on) = 144
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 62/85
copyright© IIT GuwahatiRobotics Club
Hybrid modeThe order of the values to be written to parallel
port(data pins)00000001 ² (1 st coil is on) =100000011 ² (1st & 2nd coil is on) = 300000010 ² (2 rd coil is on) = 200000110 ² (2 nd & 3rd coil is on) = 600000100 ² (3 st coil is on) = 400001100 ² (4 th & 3nd coil is on) = 1200001000 ² (4 rd coil is on) = 800001001 ² (1st & 4th coil is on) = 9
The values for the other coil can be determined by shifting the binaryrepresentation by 4 places left or multiply the decimal values by 2^4=16
Samp e co es to rotate in ccw
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 63/85
copyright© IIT GuwahatiRobotics Club
Samp e co es to rotate in ccwdrn
//single coil mode
#include <stdio.h>#include <dos.h>
main(){ char a[]={1,2,4,8};for (int i=0;i<=100;i++){ outportb(888,a[i%4]);
delay(10);}
outportb(888,0);}
//double coil#include <stdio.h>#include <dos.h>
main(){ char a[]={3,6,12,9};
for (inti=0;i<=100;i++)
{outportb(888,a[i%4]);delay(10);
}outportb(888,0);
}
//hybrid mode#include <stdio.h>#include <dos.h>
main(){ chara[]={1,3,2,6,4,12,8,9};
for (int i=0;i<=100;i++){outportb(888,a[i%8]);delay(10);}
outportb(888,0);}
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 64/85
copyright© IIT GuwahatiRobotics Club
Sample codes to rotate in cw drn//single coil mode
#include <stdio.h>#include <dos.h>
main(){ char a[]={1,2,4,8};for (int i=100;i<=0;i--){ outportb(888,a[i%4]);
delay(10);}
outportb(888,0);}
//double coil#include <stdio.h>#include <dos.h>
main(){ char a[]={3,6,12,9};for (int i=100;i<=0;i--
)
{outportb(888,a[i%4]);
delay(10);}outportb(888,0);
}
//hybrid mode#include <stdio.h>#include <dos.h>
main(){ chara[]={1,3,2,6,4,12,8,9};
for (int i=100;i<=0;i--){outportb(888,a[i%8]);delay(10);}
outportb(888,0);}
Sample codes to move the robot
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 65/85
copyright© IIT GuwahatiRobotics Club
Sample codes to move the robotbackward
//single coil mode
#include <stdio.h>#include <dos.h>main()
{ char a[]={1,2,4,8};charb[]={16,32,64,128};
for (int i=100;i<=0;i--){
outportb(888,a[i%4]|b[i%4]);
delay(10);}outportb(888,0);
}
//double coil#include <stdio.h>#include <dos.h>main(){ char a[]={3,6,12,9};char
b[]={48,96,192,144};for (int i=100;i<=0;i--
)
{outportb(888,a[i%4]|b[i%4]);delay(10);
}outportb(888,0);
}
//hybrid mode#include <stdio.h>#include <dos.h>main(){ char
a[]={1,3,2,6,4,12,8,9};charb[]={16,48,32,96,64,192,128,144};
for (int i=100;i<=0;i--){outportb(888,a[i%8]|b[i%8]);delay(10);
}outportb(888,0);
}
Sample codes to move the robot
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 66/85
copyright© IIT GuwahatiRobotics Club
Sample codes to move the robotforward
//single coil mode
#include <stdio.h>#include <dos.h>main()
{ char a[]={1,2,4,8};charb[]={16,32,64,128};
for (int i=0;i<=100;i++){
outportb(888,a[i%4]|b[i%4]);
delay(10);}outportb(888,0);
}
//double coil#include <stdio.h>#include <dos.h>main(){ char a[]={3,6,12,9};char
b[]={48,96,192,144};for (int
i=0;i<=100;i++)
{outportb(888,a[i%4]|b[i%4]);delay(10);
}outportb(888,0);
}
//hybrid mode#include <stdio.h>#include <dos.h>main(){ char
a[]={1,3,2,6,4,12,8,9};
charb[]={16,48,32,96,64,192,128,144};
for (inti=0;i<=100;i++)
{outportb(888,a[i%8]|b[i%8]);delay(10);
}outportb(888,0);
}
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 67/85
copyright© IIT GuwahatiRobotics Club
Sample codes to turn the bot left//single coil mode
#include <stdio.h>#include <dos.h>main()
{ char a[]={1,2,4,8};charb[]={16,32,64,128};
for (int i=0;i<=100;i++){ outportb(888,a[(100-
i)%4]|b[i%4]);delay(10);
}outportb(888,0);}
//double coil#include <stdio.h>#include <dos.h>main(){ char a[]={3,6,12,9};char
b[]={48,96,192,144};for (int
i=0;i<=100;i++)
{outportb(888,a[(100-i)%4]|b[i%4]);delay(10);
}outportb(888,0);
}
//hybrid mode#include <stdio.h>#include <dos.h>main(){ char
a[]={1,3,2,6,4,12,8,9};charb[]={16,48,32,96,64,192,128,144};
for (inti=0;i<=100;i++)
{outportb(888,a[(100-i)%8]|b[i%8]);delay(10);
}outportb(888,0);
}
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 68/85
copyright© IIT GuwahatiRobotics Club
Sample codes to turn the bot right//single coil mode
#include <stdio.h>#include <dos.h>main()
{ char a[]={1,2,4,8};charb[]={16,32,64,128};
for (int i=0;i<=100;i++){
outportb(888,a[i%4]|b[(100-i)%4]);
delay(10);}outportb(888,0);
}
//double coil#include <stdio.h>#include <dos.h>main(){ char a[]={3,6,12,9};char
b[]={48,96,192,144};for (int
i=0;i<=100;i++){outportb(888,a[i%4]|
b[(100-i)%4]);delay(10);}
outportb(888,0);}
//hybrid mode#include <stdio.h>#include <dos.h>main(){ char
a[]={1,3,2,6,4,12,8,9};charb[]={16,48,32,96,64,192,128,144};
for (inti=0;i<=100;i++)
{outportb(888,a[i%8]|b[(100-i)%8]);delay(10);
}outportb(888,0);
}
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 69/85
copyright© IIT GuwahatiRobotics Club
Cracking Techno
Tennis....Here we present some vague ideas fordeveloping your robot. Two important
considerations are:Basic movable base which can beaccurately positioned and moved inany directionHitting mechanism
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 70/85
copyright© IIT GuwahatiRobotics Club
If u use stepper motorsThe data pins D0-D3 will be connected tothe 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 canswitch on a control pin to trigger a flap
mechanism. A power amplifier must beused in between port pins and devicesinvolved in hitting mechanism
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 71/85
copyright© IIT GuwahatiRobotics Club
Please note....Windows XP doesn·t allow to directly accessthe parallel port so we have to use thirdparty drivers which opens the specificports.One such software is Userport.http://www.embeddedtronics.com/public/Ele
Generally the address of the parallel port is0x378-0x37F.If not the check its addressin the specific port properties in devicemanager.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 72/85
copyright© IIT GuwahatiRobotics Club
PROGRAMMING IN MATLABPROGRAMMING IN MATLABPROGRAMMING IN MATLABPROGRAMMING IN MATLABBasics of MatlabBasics of Matlab
Image Capturing.Image Capturing.Image Processing..Image Processing..
Object Identification«Object Identification«
Movement Algorithm«.Movement Algorithm«.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 73/85
B i Of M l b
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 74/85
copyright© IIT GuwahatiRobotics Club
Basics Of MatlabPre-declaration of variable is not necessary, you can use variable
whenever required.FOR loop
for i=1:nbody
end
IF conditionif(condn)statement
endImage 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 shouldbe written in an M-file.For calling function say ¶add· type add(4,5) in the prompt.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 75/85
copyright© IIT GuwahatiRobotics Club
Image Capturing.Make a video input object.
Set various attributes of the object.Take Snap Shots.Save images in an array.
Image Capturing
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 76/85
copyright© IIT GuwahatiRobotics Club
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 portsaddline(dio,0:1,'out');
Image Capturing.
««.continued
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 77/85
copyright© IIT GuwahatiRobotics Club
for ui=1:10f=getsnapshot(vid);flushdata(vid);
enddisp('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}endstop(vid);
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 78/85
copyright© IIT GuwahatiRobotics 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);
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 79/85
Image Processing
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 80/85
copyright© IIT GuwahatiRobotics Club
Image Processing..
RGB componentsFor example, the red, green, and blue
color components of the pixel (10,5) are
stored in RGB(10,5,1), RGB(10,5,2), andRGB(10,5,3), respectively.eg
a=imread(¶name.jpg·);r=a(:,:,1);g=a(:,:,2);b=a(:,:,3);
Object identification
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 81/85
copyright© IIT GuwahatiRobotics Club
Object identificationimcrop(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 befixed number for a circular object.
k [ ] f
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 82/85
copyright© IIT GuwahatiRobotics 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 theorientation & position of robot.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 83/85
copyright© IIT GuwahatiRobotics Club
Movement AlgorithmUse of only 90 degrees turns formotion using DC motor.Use of stepper motor to move along
shortest path.Implementation
At each step find the angle betweenball and direction of bot ¶ ·.
If I I < 45 deg. Then move botRepeat till bot hits ball.
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 84/85
copyright© IIT GuwahatiRobotics Club
MATLAB CODEdio=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
8/8/2019 Robotics 4
http://slidepdf.com/reader/full/robotics-4 85/85
For any help contactNiraj Murarka(B2,329,Kameng)[email protected] ; 9864167497Suhas Mishra(B4-206,Kameng)
[email protected] ; 9954248915Ashwin Chander(B4-211, Kameng)
[email protected] ; 9954249118Abhishek Anand(B2-020,Kameng)
[email protected] Khaddar (132,Dihing)