stepper motor description
TRANSCRIPT
-
8/7/2019 stepper motor description
1/19
This project is actually an educational kit. One can study the full operation of unipolar typestepper motor using this board. As it is micro controller based it can be programmable also and
one can learn micro controller interfacing with LEDs, key board and stepper motor. Thus singleboard serves the purpose of learning stepper motor control as well as learning micro controller
programming.
General description and system block diagram:-
The complete board consists of transformer, control circuit, keypad and stepper motor as shownin snap. The given figure shows the block diagram of project.
System block diagram
The circuit has inbuilt 5 V power supply so when it is connected with transformer it will give thesupply to circuit and motor both. The 8 Key keypad is connected with circuit through which user
can give the command to control stepper motor. The control circuit includes micro controller89C51, indicating LEDs, and current driver chip ULN2003A. One can program the controller to
control the operation of stepper motor. He can give different commands through keypad like, runclockwise, run anticlockwise, increase/decrease RPM, increase/decrease revolutions, stop motor,
change the mode, etc. before we start with project it is must that we first understood theoperation of unipolar stepper motor.
Unipolar stepper motor:-
In the construction of unipolar stepper motor there are four coils. One end of each coil is tidetogether and it gives common terminal which is always connected with positive terminal of
supply. The other ends of each coil are given for interface. Specific color code may also begiven. Like in my motor orange is first coil (L1), brown is second (L2), yellow is third (L3),
black is fourth (L4) and red for common terminal.
By means of controlling a stepper motor operation we can
1. Increase or decrease the RPM (speed) of it2. Increase or decrease number of revolutions of it3. Change its direction means rotate it clockwise or anticlockwise
-
8/7/2019 stepper motor description
2/19
To vary the RPM of motor we have to vary the PRF (Pulse Repetition Frequency). Number ofapplied pulses will vary number of rotations and last to change direction we have to change pulse
sequence.
So all these three things just depends on applied pulses. Now there are three different modes to
rotate this motor
1. Single coil excitation2. Double coil excitation3. Half step excitation
The table given below will give you the complete idea that how to give pulses in each mode
Pulses for stepper motor module
Note:- In half step excitation mode motor will rotate at half the specified given step resolution.
Means if step resolution is 1.8 degree then in this mode it will be 0.9 degree. Step resolutionmeans on receiving on 1 pulse motor will rotate that much degree. If step resolution is 1.8 degree
then it will take 200 pulses for motor to compete 1 revolution (360 degree).
Now let me give you the specification of the stepper motor that I have used.
Max rated voltage: - 5 V
Max rated current per coil: 0.5 AmpStep resolution: - 1.8 degree / pulse
Max RPM: - 20 in single/double coil excitation mode and 60 in half step modeTorque: 1.5 Kg/cm2
RPM calculation:-
-
8/7/2019 stepper motor description
3/19
One can calculate the exact RPM at which motor will run. We know that motor needs 200 pulsesto complete 1 revolution. Means if 200 pulses applied in 1 second motor will complete 1
revolution in 1 second. Now 1 rev. in 1 sec means 60 rev. in 1 minute. That will give us 60 RPM.Now 200 pulses in 1 sec means the PRF is 200 Hz. And delay will be 5 millisecond (ms). Now
lets see it reverse.
* If delay is 10 ms then PRF will be 100 Hz.* So 100 pulses will be given in 1 sec
* Motor will complete 1 revolution in 2 second* So the RPM will be 30.
In same manner as you change delay the PRF will be changed and it will change RPM
Stepper motor control board circuit:-
-
8/7/2019 stepper motor description
4/19
Stepper motor control board circuit
The circuit consists of very few components. The major components are 7805, 89C51 andULN2003A.
Connections:-
1. The transformer terminals are given to bridge rectifier to generate rectified DC.2. It is filtered and given to regulator IC 7805 to generate 5 V pure DC. LED indicates
supply is ON.3. All the push button micro switches J1 to J8 are connected with port P1 as shown to form
serial keyboard.4. 12 MHz crystal is connected to oscillator terminals of 89C51 with two biasing capacitors.5. All the LEDs are connected to port P0 as shown6. Port P2 drives stepper motor through current driver chip ULN2003A.7. The common terminal of motor is connected to Vcc and rest all four terminals are
connected to port P2 pins in sequence through ULN chip.
Now by downloading different programs in to 89C51 we can control the operation of stepper
motor. Let us see all different kind of program.
Program 1:-It is advisable to begin with easy program. So in this program we shall see minimal functionality.
Only first two switches and first three LEDs will be used. When you press one switch the motorwill start rotating in clockwise direction and stops when completes one revolution. Pressing
second switch will do the same job but in anticlockwise direction. The speed will be 10 RPMfixed. Motor runs in single coil excitation mode. First LED indicates key press event. Second
blinks when motor rotates clockwise and third blinks when motor rotates anticlockwise.
Org 00h
mov r0,#01h ; initileze key countmov p1,#0ffh ; P1 as input port
lop: mov a,p1cjne a,#0ffh,jmp
ajmp lop ; loop until any key; is pressed
jmp: clr p0.0 ; indicates keypressloop: rrc a
jnc num ; get key no.inc r0
sjmp loopnum: acall dely ; key debounce delay
setb p0.0
cjne r0,#01h,nxt ; for 1st keyacall clkwise ; rotate motor
-
8/7/2019 stepper motor description
5/19
sjmp over ; clock wisenxt: cjne r0,#02h,over ; for 2nd key
acall aclkwise ; rotate anticlock
over: mov p2,#00h ; restore initial
mov p1,#0ffh ; data andmov r0,#01hsjmp lop ; jump to loop again
clkwise:
mov r1,#32h ; load count 50dgo: clr p0.1
mov p2,#01h ;give 4 pulses in loopacall delay ; total 200 pulses
mov p2,#02h ; each coil energizedacall delay ; one by on in single
setb p0.1mov p2,#04h ; coil excitation
acall delay ; 30 ms delay in betwnmov p2,#08h ; means speed is
acall delay ; 10 RPMdjnz r1,go
retaclkwise:
mov r1,#32hgo1:clr p0.2
mov p2,#01hacall delay
mov p2,#08h ; revert the pulseacall delay ; sequence for
setb p0.2mov p2,#04h ; anticlockwise
acall delaymov p2,#02h
acall delaydjnz r1,go1
ret
delay:
mov r5,#1Eh ; load count 30lop2: mov r6,#FAh ; give 1 ms delay
lop1:nop ; so it gives fullnop ; 30 ms delay
djnz r6,lop1djnz r5,lop2
ret
-
8/7/2019 stepper motor description
6/19
dely:mov r5,#0C8h ; load count 200
lop2: mov r6,#0FAh ; for 200ms delaylop1: nop
nop
djnz r6,lop1djnz r5,lop2ret
end
Program 2:-Here in this program we shall limit the motor to rotate only 7.2o in either direction when the keyis pressed. When first key is pressed motor rotates in clockwise direction and when second is
pressed anticlockwise direction. LED1 and LED2 indicate the clockwise and anticlockwiserotation.
Note: In industries this is also known as jogging (jog control). This is done to check in whichdirection motor will start running.
Org 00h
mov r0,#01h ; initileze key countmov p1,#0ffh ; P1 as input port
lop: mov a,p1cjne a,#0ffh,jmp
ajmp lop ; loop until any key is pressedjmp: clr p0.0 ; indicates keypress
loop: rrc ajnc num ; get key no.
inc r0sjmp loop
num: acall dely ; key debounce delaysetb p0.0
cjne r0,#01h,nxt ; for 1st key
acall clkwise ; rotate motorsjmp over ; clock wise
nxt: cjne r0,#02h,over ; for 2nd keyacall aclkwise ; rotate anticlock
over: mov p2,#00h ; restore initialmov p1,#0ffh ; data and
mov r0,#01hsjmp lop ; jump to loop again
clkwise:
clr p0.1mov p2,#01h ;give 4 pulses in loop
acall delay ; as 1.8o step resolution
-
8/7/2019 stepper motor description
7/19
mov p2,#02h ; total 7.2o rotationacall delay ; in single coil
setb p0.1mov p2,#04h ; excitation
acall delay ; 30 ms delay in betwn
mov p2,#08h ; means speed isacall delay ; 10 RPMret
aclkwise:clr p0.1
mov p2,#01hacall delay
mov p2,#08h ; revert the pulseacall delay ; sequence for
setb p0.1mov p2,#04h ; anticlockwise
acall delaymov p2,#02h
acall delayret
delay:
mov r5,#1Eh ; load count 30lop2: mov r6,#FAh ; give 1 ms delay
lop1:nop ; so it gives fullnop ; 30 ms delay
djnz r6,lop1djnz r5,lop2
ret
dely:mov r5,#0C8h ; load count 200
lop2: mov r6,#0FAh ; for 200ms delaylop1:nop
nopdjnz r6,lop1
djnz r5,lop2retend
Program 3:-
This is also easy program. Now three keys are used and three LEDs are used. Please refer table.
The speed of motor is again fixed at 20 RPM. The mode is double coil excitation.
-
8/7/2019 stepper motor description
8/19
Org 00h
mov r0,#01h ; initileze key count
mov p1,#0ffh ; P1 as input portlop: mov a,p1
cjne a,#0ffh,jmpajmp lop ; loop until any key is pressed
jmp: clr p0.0 ; indicates keypress
loop: rrc ajnc num ; get key no.
inc r0sjmp loop
num: acall dely ; key debounce delaysetb p0.0
cjne r0,#01h,nxt ; for 1st key rotate motoracall clkwise ; clock wise
sjmp overnxt: cjne r0,#02h,nxt2 ; for 2nd key
acall aclkwise ; rotate anticlocknxt2: cjne r0,#03h,over ; for 3rd key
mov p2,#00h ; stop motorover: mov r0,#01h
sjmp lop ; jump to loop again
clkwise:lop: clr p0.1
mov p2,#03h ; at a time two coilsacall delay ; energized in double
mov p2,#06h ; coil excitation modeacall delay
setb p0.1
mov p2,#0Chacall delaymov p2,#09h
acall delaymov p1, #0FFh ; continue loop
mov a,p1 ; until any key iscjne a,#0FFh,out ; not pressed
sjmp lop
-
8/7/2019 stepper motor description
9/19
out: retaclkwise:
lop1: clr p0.1mov p2,#03h
acall delay
mov p2,#09h ; revert the pulseacall delay ; sequence forsetb p0.1
mov p2,#0Ch ; anticlockwiseacall delay
mov p2,#06hacall delay
mov p1, #0FFhmov a,p1
cjne a,#0FFh,out1sjmp lop1
out1: ret
delay:mov r5,#0Fh ; load count 15
lop2: mov r6,#FAh ; give 1 ms delaylop1:nop ; so it gives full
nop ; 15 ms delaydjnz r6,lop1 ; to give speed
djnz r5,lop2 ; of 20 RPMret
dely:
mov r5,#0C8h ; load count 200lop2: mov r6,#0FAh ; for 200ms delay
lop1:nopnop
djnz r6,lop1djnz r5,lop2
retend
Program 4:-This program is same as above but now the mode is changed to half step and RPM is now 30.
Org 00h
mov r0,#01h ; initileze key countmov p1,#0ffh ; P1 as input port
lop: mov a,p1cjne a,#0ffh,jmp
ajmp lop ; loop until any key is pressed
-
8/7/2019 stepper motor description
10/19
jmp: clr p0.0 ; indicates keypressloop: rrc a
jnc num ; get key no.inc r0
sjmp loop
num: acall dely ; key debounce delaysetb p0.0
cjne r0,#01h,nxt ; for 1st keyacall clkwise ; rotate motor
sjmp over ; clock wisenxt: cjne r0,#02h,nxt2 ; for 2nd key
acall aclkwise ; rotate anticlocknxt2: cjne r0,#03h,over ; for 3rd key
mov p2,#00h ; stop motorover: mov r0,#01h
sjmp lop ; jump to loop again
clkwise:lop: clr p0.1
mov p2,#01h ; alternate pulsesacall delay ; given one from
mov p2,#03h ; single coil secondacall delay ; from double coil
mov p2,#02h ; in half step modacall delay
mov p2,#06hacall delay
setb p0.1mov p2,#04h
acall delaymov p2,#0Ch
acall delaymov p2,#08h
acall delaymov p2,#09h
acall delaymov p1, #0FFh ; continue loopmov a,p1 ; until any key is
cjne a,#0FFh,out ; not pressedsjmp lop
out: retaclkwise:
lop1: clr p0.1mov p2,#01h
acall delay
-
8/7/2019 stepper motor description
11/19
mov p2,#03h ; revert the pulseacall delay ; sequence for
mov p2,#08h ; anticlockwiseacall delay
mov p2,#09h
acall delaysetb p0.1mov p2,#04h
acall delaymov p2,#0Ch
acall delaymov p2,#02h
acall delaymov p2,#06h
acall delaymov p1, #0FFh
mov a,p1cjne a,#0FFh,out1
sjmp lop1out1: ret
delay:mov r5,#0Ah ; load count 10
lop2: mov r6,#FAh ; give 1 ms delaylop1: nop ; so it gives full
nop ; 10 ms delaydjnz r6,lop1 ; to give speed
djnz r5,lop2 ; of 30 RPMret
dely:mov r5,#0C8h ; load count 200
lop2: mov r6,#0FAh ; for 200ms delaylop1: nop
nopdjnz r6,lop1
djnz r5,lop2ret
end
Program 5:-
Now its time to start with harder programs. In this program all above facilities are there and two
more are included increasing and decreasing RPM. Five switches and four LEDs are used. Seethe table for key functions and LED indications.
-
8/7/2019 stepper motor description
12/19
f equ 0fh ; direction flagOrg 00h
mov 30h, #3Ch ; make a table ofmov 31h, #1Eh ; four load values
mov 32h, #14h ; for variable delaymov 33h, #0Fh
mov r1, #30h ;initial location in r1mov r0,#01h ; initialize key count
mov p1,#0ffh ; P1 as input portlop: mov a,p1
cjne a,#0ffh,jmpajmp lop ; loop until any key
; is pressedjmp: clr p0.0 ; indicates keypress
loop: rrc ajnc num ; get key no.
inc r0
sjmp loopnum: acall dely ; key debounce delaysetb p0.0
cjne r0,#01h,nxt ; for 1st key
acall clkwise ; rotate motorsjmp over ; clock wise
nxt: cjne r0,#02h,nxt2 ; for 2nd keyacall aclkwise ; rotate anticlock
nxt2: cjne r0,#03h,nxt3 ; for 3rd keymov p2,#00h ; stop motor
nxt3: cjne r0,#04h,nxt4 ; for 4th keyacall incrpm ; increase RPM
jnb f, aclk ; and continue to rotateacall clkwise ; motor in same
sjmp over ; direction as it wasaclk: acall aclkwise ; running by
sjmp over ; checking flag fnxt3: cjne r0,#05h,over ; for 5th key
-
8/7/2019 stepper motor description
13/19
acall decrpm ; decrease RPM andjnb f, aclkw ; again continue to
acall clkwise ; rotate motorsjmp over
aclks: acall aclkwise
sjmp over
over: mov r0,#01h
sjmp lop ; jump to loop againclkwise:
setb f ; for clkwise set directionallop: clr p0.1 ; flag
mov p2,#03h ; at a time two coilsacall delay ; energized in double
mov p2,#06h ; coil excitation modeacall delay
setb p0.1mov p2,#0Ch
acall delaymov p2,#09h
acall delaymov p1, #0FFh ; continue loop
mov a,p1 ; until any key iscjne a,#0FFh,out ; not pressed
sjmp lopout: ret
aclkwise:clr f ; for aclkwise clear
lop1: clr p0.1 ; directional flagmov p2,#03h
acall delaymov p2,#09h ; revert the pulse
acall delay ; sequence forsetb p0.1
mov p2,#0Ch ; anticlockwiseacall delay
mov p2,#06hacall delay
mov p1, #0FFhmov a,p1
cjne a,#0FFh,out1sjmp lop1
out1: ret
incrpm:
clr p0.3 ; indication
-
8/7/2019 stepper motor description
14/19
cjne r1,#33h,incr ; if max limit isajmp noin ; reached no increase
incr: inc r1 ; increase otherwiseacall dely
setb p0.3
noin: ret ; led stays on for max limit
decrpm:
clr p0.3 ; indicationcjne r1,#30h,incr ; if min limit is
ajmp noin ; reached no decreaseincr: dec r1 ; decrease otherwise
acall delysetb p0.3
noin: ret ; led stays on for min limit
delay:mov 10h,@r1 ; load content of
lop2: mov r6,#FAh ; address in r1lop1:nop ; so it gives variable
nop ; delay every timedjnz 10h,lop1 ; to give variable
djnz r5,lop2 ; speed of motorret
dely:mov r5,#0C8h ; load count 200
lop2: mov r6,#0FAh ; for 200ms delaylop1:nop
nopdjnz r6,lop1
djnz r5,lop2ret
end
Program 6:-
Now I am adding one more functionality in the program. Now instead of continuously runningmotor, motor will run till desired no. of revolutions entered. Means motor will automatically
stops when it completes desired revolutions. One can increase or decrease revolutions in step ofone (1, 2, 3 ). I have used 6 keys and 5 LEDs.
-
8/7/2019 stepper motor description
15/19
In the first program we have limit the number of applied pulses to 200. Now again we shall load
the number every time that will change number of applied pulses. There is no maximum limit but
sure there is minimum limit that is 1 revolution.
Org 00hmov 30h, #3Ch ; make a table of
mov 31h, #1Eh ; four load valuesmov 32h, #14h ; for variable delay
mov 33h, #0Fhmov r1, #30h ; initial location in r1
mov 2fh,#32h ; initial load valuemov 2eh,#01h ; for no. of rev.
mov r0,#01h ; initialize key countmov p1,#0ffh ; P1 as input port
lop: mov a,p1cjne a,#0ffh,jmp
ajmp lop ; loop until any key is pressed
jmp: clr p0.0 ; indicates keypress
loop: rrc ajnc num ; get key no.
inc r0sjmp loop
num: acall dely ; key debounce delaysetb p0.0
cjne r0,#01h,nxtacall clkwise
sjmp overnxt: cjne r0,#02h,nxt2
acall aclkwisesjmp over
nxt2: cjne r0,#03h,nxt3
-
8/7/2019 stepper motor description
16/19
acall incrpmsjmp over
nxt3: cjne r0,#04h,nxt4acall decrpm
sjmp over
nxt4: cjne r0,#05h,nxt5acall increvsjmp over
nxt5:cjne r0,#06h,overacall decrev
over: mov p2,#00h
mov p1,#0ffhmov r0,#01h
sjmp lopclkwise:
mov r1,2Fh ; load variable countgo: clr p0.1
mov p2,#01h ; single coilacall delay ; excitation
mov p2,#02hacall delay ; variable delay
setb p0.1mov p2,#04h
acall delaymov p2,#08h;
acall delaydjnz r1,go
retaclkwise:
mov r1,2Fhgo1:clr p0.2
mov p2,#01hacall delay
mov p2,#08hacall delay
setb p0.2mov p2,#04h
acall delaymov p2,#02h
acall delaydjnz r1,go1
retincrpm:
clr p0.3 ; indicationcjne r1,#33h,incr ; if max limit is
-
8/7/2019 stepper motor description
17/19
ajmp noin ; reached no increaseincr: inc r1 ; increase otherwise
acall delysetb p0.3
noin: ret ; led stays on for max limit
decrpm:clr p0.3 ; indication
cjne r1,#30h,decr ; if min limit isajmp noin ; reached no decrease
decr: dec r1 ; decrease otherwiseacall dely
setb p0.3noin: ret ; led stays on for min limit
increv:clr p0.4 ; indication
inc 2Eh ; increment multiplying factormov a,#32h
mov b,2Ehmul ab ; multiply it by load value
mov 2Fh,a ; stores the new load valueacall dely
setb p0.4ret
decrev:clr p0.4
mov r4,2Ehcjne r4,#01h,decn ; check for min
ajmp out2 ; limit of multiplyingdecn: dec 2Eh ; factor. If not reached
mov a,#32h ; decrease itmov b,2Eh
mul ab ; multiply it with loadmov 2Fh,a ; value and store the
acall dely ; new load valuesetb p0.4
out2: ret
delay:
mov 10h,@r1 ; load the countlop2: mov r6,#FAh ; from table
lop1: nopnop
djnz 10h,lop1djnz r5,lop2
ret
-
8/7/2019 stepper motor description
18/19
dely:mov r5,#0C8h ; load count 200
lop2: mov r6,#0FAh ; for 200ms delaylop1: nop
nop
djnz r6,lop1djnz r5,lop2ret
end
Program 7:-This program adds two more things to above program. It changes the mode of operation of
stepper motor also it adds jog control. It changes three different modes on pressing one key. Alleight keys and eight LEDs are now used.
When J7 key is pressed first time the mode will change from single coil to double coil. When
pressed second time mode will change from double coil to half step. And on pressing third timeagain the same mode will repeat. When J8 key is pressed the motor will rotate in previously
selected direction. Means if motor was running in clockwise direction then the jog will be insame direction.
Program 8:-
In above program motor doesnt rotate continuously. In this program motor rotates continuously
and one can change the RPM and operating mode while running. 6 keys and 8 LEDs are used.
-
8/7/2019 stepper motor description
19/19
by
Ashutosh M Bhattwww.multyremotes.com