Upload
kashinath
View
12
Download
0
Embed Size (px)
DESCRIPTION
Stepper Motor PPT
Citation preview
Stepper MotorsStepper MotorsWidely use in Robotics ---why??Widely use in Robotics ---why??• Because More precise than DC Because More precise than DC
motormotor• Measured rotation and can be held Measured rotation and can be held
at a particular position- U can rotate at a particular position- U can rotate the stepper motor with an accuracy of the stepper motor with an accuracy of 0.9 degree!!!!!!0.9 degree!!!!!!
• Alignment is much better...Alignment is much better...
Stepper Motors contd..Stepper Motors contd..
Types of Stepper MotorsTypes of Stepper Motors• Mainly 2 types:Mainly 2 types:
– Unipolar- Current can flow only in one Unipolar- Current can flow only in one direction in the coilsdirection in the coils
– Bipolar- Current can flow in both the Bipolar- Current can flow in both the directionsdirections
Comparison Comparison • UnipolarUnipolar
Current flow in one Current flow in one directiondirection
Simple drive circuitSimple drive circuit
Less torqueLess torque
• BipolarBipolar
Current flow in both Current flow in both directiondirection
Complicated drive CircuitComplicated drive Circuit
High TorqueHigh Torque
Modes of OperationModes of Operation• Single Coil Excitation: Only one out of Single Coil Excitation: Only one out of
the 4 coils is excited at a given timethe 4 coils is excited at a given time• Double Coil: Two adjacent coils are Double Coil: Two adjacent coils are
excited at a given timeexcited at a given time• Single and Double: It’s a hybrid of Single and Double: It’s a hybrid of
both..(refer diagram for details)both..(refer diagram for details)
Stepper Motor basicsStepper Motor basics• The stepper motor contains a permanent The stepper motor contains a permanent
magnet which is attached to the shaft at magnet which is attached to the shaft at centre and there are 4 coils on the 4 sidescentre and there are 4 coils on the 4 sides
• Actually the stator contains 100 teeth to Actually the stator contains 100 teeth to get a step angle of get a step angle of 360/(2*100)=1.8degrees. But here for the 360/(2*100)=1.8degrees. But here for the sake of simplicity, we are showing only one sake of simplicity, we are showing only one tooth of stator. So don’t get misled into tooth of stator. So don’t get misled into believing that it’s atep angle is 90 degreesbelieving that it’s atep angle is 90 degrees
Single Coil ModeSingle Coil Mode
Single coil ExcitationSingle coil Excitation
Note that until the next coil is switched on, the stator remains in it’s position onlyAnd 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
a. Single-Coil Excitation - Each a. Single-Coil Excitation - Each successive coil is energized in successive coil is energized in turn. turn.
Double coil ExcitationDouble coil Excitation
b. Two-Coil Excitation - Each b. Two-Coil Excitation - Each successive pair of adjacent coils is successive pair of adjacent coils is energized in turn.energized in turn.
Single and Double coil Single and Double coil ExcitationExcitation
Interleaving the two Interleaving the two sequences will cause the sequences will cause the motor to half-step motor to half-step
ComparisonComparison•Single coilSingle coil
• Low torqueLow torque
• Consume less Consume less energyenergy
• Settling time is moreSettling time is more
• Double coilDouble coil
• High torqueHigh torque
• Consume double Consume double energyenergy
• Settling time is lessSettling time is lessNote: The advantage of hybrid mode is that the step angle gets halved.. So we can control the rotation with double precision
Circuit DiagramCircuit Diagram
Controlling motors thru Controlling motors thru ComputerComputer• Parallel Ports: It’s the easiest way to Parallel Ports: It’s the easiest way to
control the motors from computer. No control the motors from computer. No complicated intermediate circuits are complicated intermediate circuits are requiredrequired
• Serial/USB portsSerial/USB ports• Bluetooth Bluetooth
* The last 2 modes are beyond the scope of this workshop
25-way Female D-Type 25-way Female D-Type Connector Connector
The pin configuration of the The pin configuration of the other end of parallel port other end of parallel port connectorconnector
Pin detailsPin details
Pin details contd.....Pin details contd.....
Pin DetailsPin Details• D0-D7 are the data pins(used for D0-D7 are the data pins(used for
output)output)• C0-C3 are control pins. Note that C1 C0-C3 are control pins. Note that C1
and C3 are hardware inverted. They and C3 are hardware inverted. They can be used for both input and outputcan be used for both input and output
• S3-S7 are status pins. They are used S3-S7 are status pins. They are used for taking input from external cktfor taking input from external ckt
PC parallel PortPC parallel Port• The PC's Parallel Printer Port had a total of The PC's Parallel Printer Port had a total of
12 digital outputs and 5 digital inputs 12 digital outputs and 5 digital inputs accessed via 3 consecutive 8-bit ports in accessed via 3 consecutive 8-bit ports in the processor's I/O space.the processor's I/O space.
• 8 output pins accessed via the 8 output pins accessed via the DATA PortDATA Port • 5 input pins (one inverted) accessed via 5 input pins (one inverted) accessed via
the the STATUS PortSTATUS Port • 4 output pins (three inverted) accessed 4 output pins (three inverted) accessed
via the via the CONTROL PortCONTROL Port • The remaining 8 pins are grounded The remaining 8 pins are grounded
Controlling pins thru Controlling pins thru programprogram• Almost every programming language Almost every programming language
has commands to control the ports. For has commands to control the ports. For example in Turbo C, we can use the example in Turbo C, we can use the ‘outportb’ function defined in dos.h ‘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 pinsi.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
Control pinsControl pins• The address for control pins can be The address for control pins can be
obtained by adding 2 to the address of obtained by adding 2 to the address of data pins. For eg, here the address of data pins. For eg, here the address of control pins will be 0x378+0x2=0x37acontrol pins will be 0x378+0x2=0x37a
• Therefore the command Therefore the command outportb(0x37a,3) will make both the 1outportb(0x37a,3) will make both the 1stst 2 2 control pins(C0,C1) control pins(C0,C1) lowlow! Because 3=0011 ! Because 3=0011 and C0 and C1 are hardware invertedand C0 and C1 are hardware inverted
Controlling DC motors by H-Controlling DC motors by H-BridgeBridge
Implementation of H bridgeImplementation of H bridge
Driving the DC motorDriving the DC motor
Connections for a stepper Connections for a stepper motormotor
DataPort1
DataPort2
Motor 1
Motor 2
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
Driving the Stepper MotorDriving the Stepper Motor• In the following slides, we discuss the In the following slides, we discuss the
code for driving the stepper motor in code for driving the stepper motor in various modesvarious modes– Single coil modeSingle coil mode– Double coil modeDouble coil mode– Hybrid modeHybrid mode
Single Coil ModeSingle Coil ModeThe order of the values to be written to The order of the values to be written to
parallel port(data pins)parallel port(data pins)00000001 – (100000001 – (1stst coil is on) = 1 coil is on) = 100000010 – (200000010 – (2ndnd coil is on) = 2 coil is on) = 200000100 – (300000100 – (3rdrd coil is on) = 4 coil is on) = 400001000 – (400001000 – (4thth coil is on) = 8 coil is on) = 8For 2For 2ndnd motor motor00010000 – (100010000 – (1stst coil is on) = 16 coil is on) = 160010000 – (20010000 – (2ndnd coil is on) = 32 coil is on) = 320100000 – (30100000 – (3rdrd coil is on) = 64 coil is on) = 641000000 – (41000000 – (4thth coil is on) = 128 coil is on) = 128
Double Coil ModeDouble Coil ModeThe order of the values to be written to The order of the values to be written to
parallel port(data pins)parallel port(data pins)00000011 – (100000011 – (1stst & 2 & 2ndnd coils are on) = 3 coils are on) = 300000110 – (200000110 – (2ndnd & 3 & 3rdrd coils are on) = 6 coils are on) = 600001100 – (300001100 – (3rdrd & 4 & 4thth coils are on) = 12 coils are on) = 1200001001 – (400001001 – (4thth & 1 & 1stst coils are on) = 9 coils are on) = 9For 2For 2ndnd motor motor00110000 – (100110000 – (1stst & 2 & 2ndnd coils are on) = 48 coils are on) = 4801100000 – (201100000 – (2ndnd & 3 & 3rdrd coils are on) = 96 coils are on) = 9611000000 – (311000000 – (3rdrd & 4 & 4thth coils are on) = 192 coils are on) = 19210010000 – (410010000 – (4thth & 1 & 1stst coils are on) = 144 coils are on) = 144
Hybrid modeHybrid modeThe order of the values to be written to The order of the values to be written to
parallel port(data pins)parallel port(data pins)00000001 – (100000001 – (1stst coil is on) = coil is on) = 1100000011 – (100000011 – (1stst & 2 & 2ndnd coil is on) = 3 coil is on) = 300000010 – (200000010 – (2rdrd coil is on) = 2 coil is on) = 200000110 – (200000110 – (2ndnd & 3 & 3rdrd coil is on) = 6 coil is on) = 600000100 – (300000100 – (3stst coil is on) = 4 coil is on) = 400001100 – (400001100 – (4thth & 3 & 3ndnd coil is on) = 12 coil is on) = 1200001000 – (400001000 – (4rdrd coil is on) = 8 coil is on) = 800001001 – (100001001 – (1stst & 4 & 4thth coil is on) = 9 coil is on) = 9
The values for the other coil can be determined by shifting the binary 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=16representation by 4 places left or multiply the decimal values by 2^4=16
Sample codes to rotate in ccw Sample codes to rotate in ccw drndrn
//single coil mode//single coil mode
#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>
main()main(){ char a[]={1,2,4,8};{ char a[]={1,2,4,8}; for (int i=0;i<=100;i+for (int i=0;i<=100;i+
+)+) { outportb(888,a[i{ outportb(888,a[i
%4]);%4]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//double coil//double coil#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>
main()main(){ char { char
a[]={3,6,12,9};a[]={3,6,12,9}; for (int for (int
i=0;i<=100;i++)i=0;i<=100;i++) {outportb(888,a[i{outportb(888,a[i
%4]);%4]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//hybrid mode//hybrid mode#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>
main()main(){ char { char
a[]={1,3,2,6,4,12,8,a[]={1,3,2,6,4,12,8,9};9};
for (int i=0;i<=100;i+for (int i=0;i<=100;i++)+)
{ outportb(888,a[i{ outportb(888,a[i%8]);%8]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
Sample codes to rotate in cw Sample codes to rotate in cw drndrn
//single coil mode//single coil mode
#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>
main()main(){ char a[]={1,2,4,8};{ char a[]={1,2,4,8}; for (int for (int
i=100;i<=0;i--)i=100;i<=0;i--) { outportb(888,a[i{ outportb(888,a[i
%4]);%4]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//double coil//double coil#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>
main()main(){ char { char
a[]={3,6,12,9};a[]={3,6,12,9}; for (int for (int
i=100;i<=0;i--)i=100;i<=0;i--) {outportb(888,a[i{outportb(888,a[i
%4]);%4]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//hybrid mode//hybrid mode#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>
main()main(){ char { char
a[]={1,3,2,6,4,12,8,a[]={1,3,2,6,4,12,8,9};9};
for (int for (int i=100;i<=0;i--)i=100;i<=0;i--)
{ outportb(888,a[i{ outportb(888,a[i%8]);%8]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
Sample codes to move the robot Sample codes to move the robot backwardbackward
//single coil mode//single coil mode
#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={1,2,4,8};{ char a[]={1,2,4,8}; char char
b[]={16,32,64,128}b[]={16,32,64,128};;
for (int for (int i=100;i<=0;i--)i=100;i<=0;i--)
{ outportb(888,a[i{ outportb(888,a[i%4]|b[i%4]);%4]|b[i%4]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//double coil//double coil#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={3,6,12,9};{ char a[]={3,6,12,9};char char
b[]={48,96,192,144};b[]={48,96,192,144}; for (int for (int
i=100;i<=0;i--)i=100;i<=0;i--) {outportb(888,a[i{outportb(888,a[i
%4]|b[i%4]);%4]|b[i%4]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//hybrid mode//hybrid mode#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char { char
a[]={1,3,2,6,4,12,8,9a[]={1,3,2,6,4,12,8,9};};
char char b[]={16,48,32,96,64,19b[]={16,48,32,96,64,192,128,144};2,128,144};
for (int i=100;i<=0;i--)for (int i=100;i<=0;i--) { outportb(888,a[i%8]|{ outportb(888,a[i%8]|
b[i%8]);b[i%8]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
Sample codes to move the robot Sample codes to move the robot forwardforward
//single coil mode//single coil mode
#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={1,2,4,8};{ char a[]={1,2,4,8}; char char
b[]={16,32,64,128}b[]={16,32,64,128};;
for (int i=0;i<=100;i+for (int i=0;i<=100;i++)+)
{ outportb(888,a[i{ outportb(888,a[i%4]|b[i%4]);%4]|b[i%4]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//double coil//double coil#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={3,6,12,9};{ char a[]={3,6,12,9};char char
b[]={48,96,192,144};b[]={48,96,192,144}; for (int for (int
i=0;i<=100;i++)i=0;i<=100;i++) {outportb(888,a[i{outportb(888,a[i
%4]|b[i%4]);%4]|b[i%4]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//hybrid mode//hybrid mode#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char { char
a[]={1,3,2,6,4,12,a[]={1,3,2,6,4,12,8,9};8,9};
char char b[]={16,48,32,96,6b[]={16,48,32,96,64,192,128,144};4,192,128,144};
for (int for (int i=0;i<=100;i++)i=0;i<=100;i++)
{ outportb(888,a[i{ outportb(888,a[i%8]|b[i%8]);%8]|b[i%8]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
Sample codes to turn the bot leftSample codes to turn the bot left//single coil mode//single coil mode
#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={1,2,4,8};{ char a[]={1,2,4,8}; char char
b[]={16,32,64,128};b[]={16,32,64,128}; for (int i=0;i<=100;i+for (int i=0;i<=100;i+
+)+)
{ outportb(888,a[(1{ outportb(888,a[(100-i)%4]|b[i%4]);00-i)%4]|b[i%4]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//double coil//double coil#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={3,6,12,9};{ char a[]={3,6,12,9};char char
b[]={48,96,192,144};b[]={48,96,192,144}; for (int for (int
i=0;i<=100;i++)i=0;i<=100;i++)
{outportb(888,a[(1{outportb(888,a[(100-i)%4]|b[i%4]);00-i)%4]|b[i%4]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//hybrid mode//hybrid mode#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char { char
a[]={1,3,2,6,4,12,a[]={1,3,2,6,4,12,8,9};8,9};
char char b[]={16,48,32,96,64,b[]={16,48,32,96,64,192,128,144};192,128,144};
for (int for (int i=0;i<=100;i++)i=0;i<=100;i++)
{ outportb(888,a[({ outportb(888,a[(100-i)%8]|b[i%8]);100-i)%8]|b[i%8]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
Sample codes to turn the bot rightSample codes to turn the bot right//single coil mode//single coil mode
#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={1,2,4,8};{ char a[]={1,2,4,8}; char char
b[]={16,32,64,128}b[]={16,32,64,128};;
for (int i=0;i<=100;i+for (int i=0;i<=100;i++)+)
{ outportb(888,a[i{ outportb(888,a[i%4]|b[(100-i)%4]);%4]|b[(100-i)%4]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//double coil//double coil#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char a[]={3,6,12,9};{ char a[]={3,6,12,9};char char
b[]={48,96,192,144};b[]={48,96,192,144}; for (int for (int
i=0;i<=100;i++)i=0;i<=100;i++){outportb(888,a[i%4]|{outportb(888,a[i%4]|
b[(100-i)%4]);b[(100-i)%4]); delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
//hybrid mode//hybrid mode#include <stdio.h>#include <stdio.h>#include <dos.h>#include <dos.h>main()main(){ char { char
a[]={1,3,2,6,4,12,a[]={1,3,2,6,4,12,8,9};8,9};
char char b[]={16,48,32,96,64b[]={16,48,32,96,64,192,128,144};,192,128,144};
for (int for (int i=0;i<=100;i++)i=0;i<=100;i++)
{ outportb(888,a[i{ outportb(888,a[i%8]|b[(100-i)%8]);%8]|b[(100-i)%8]);
delay(10);delay(10); }} outportb(888,0);outportb(888,0);}}
Cracking Techno Tennis....Cracking Techno Tennis....Here we present some vague ideas for Here we present some vague ideas for
developing your robot. Two developing your robot. Two important considerations are:important considerations are:
• Basic movable base which can be Basic movable base which can be accurately positioned and moved in accurately positioned and moved in any directionany direction
• Hitting mechanismHitting mechanism
If u use stepper motorsIf u use stepper motors• The data pins D0-D3 will be connected to The data pins D0-D3 will be connected to
the left motor and D4-D7 to the right one the left motor and D4-D7 to the right one (or vice versa)(or vice versa)
• To control the hitting mechanism u can To control the hitting mechanism u can use the 4 control pins. For example u can use the 4 control pins. For example u can switch on a control pin to trigger a flap switch on a control pin to trigger a flap mechanism. A power amplifier must be mechanism. A power amplifier must be used in between port pins and devices used in between port pins and devices involved in hitting mechanisminvolved in hitting mechanism
MATLAB CODEMATLAB CODE• dio=digitalio('parallel','LPT1');dio=digitalio('parallel','LPT1');• addline(dio,0:3,'out');addline(dio,0:3,'out');• putvalue(dio,[0 1 1 0]);putvalue(dio,[0 1 1 0]);