8051 Interfacing with stepper motor |
-------------------------------
; 4 PINS OF STEPPER MOTOR CONTROLLED BY 4 BITS OF 8051 P1.0 - P1.3
; IT IS INTERFACED USING DARLINGTON ARRAYS SUCH AS ULN2003 AS
; 8051 LACKS CURRENT TO RUN THE MOTOR. SO ULN2003 IS USED FOR ENERGIZING STATOR.
; PROGRAM BELOW SHOWS JUST ROTATING THE MOTOR STEP WISE
; BUT STEP WIDTH IS UNKNOWN
MOV A, #66H ; LOAD THE STEP SEQUENCE
BACK :
MOV P1, A ; LOAD SEQUENCE TO PORT
RR A ; CHANGE SEQUENCE ROTATE CLOCKWISE
ACALL DELAY : WAIT FOR IT
SJMP BACK ; NOW KEEP GOING
DELAY :
MOV R2, #100
H1 :
MOV R3, #255
H2 :
DJNZ R3, H2
DJNZ R2, H1
RET
END
; THIS OTHER PROGRAM CODE HOW IN SAME INTERFACING TO ROTATE A STEPPER MOTOR
; 64 DEGREES IN CLOCKWISE DIRECTION USING 4 STEP SEQUENCE
; IT TAKES SOME CALCULATIONS
; CONSIDER A MOTOR WITH STEP ANGLE 2 DEGREE
; SO STEPS PER REVOLUTION = 180
; NO OF ROTOR TEETH = 45
; MOVEMENT PER 4 STEP SEQUENCE IS 8 DEGREES
; FOR 64 DEGREE MOVEMENT WE NEED TO SEND 8 CONSECUTIVE 4 STEP SEQUENCE
; THAT IS IT WILL COVER 32 STEPS
ORG 0000H
MOV A, #66H
MOV R1, #32H ; 32 STEPS TO BE TAKEN
BACK :
RR A ; ROTATE CLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R1, BACK ;
END
-----------------
Now few question arises
q1) why did we took 66h as step value??
Ans))
A normal 4 step sequence is like below.
Step #
|
Winding A
|
Winding B
|
Winding C
|
Winding D
|
1
|
1
|
0
|
0
|
1
|
2
|
1
|
1
|
0
|
0
|
3
|
0
|
1
|
1
|
0
|
4
|
0
|
0
|
1
|
1
|
Going from step 1 to 4 we rotate motor clockwise
Going from step 4 to 1 we rotate motor counter clockwise
The stepper motor discussed here has total 6 leads. 4 leads
representing 4 windings and 2 commons for centre tapped leads. Here we have
used 2 phase 4 step sequence. It must also be noted we can start from any
step. Be it step 1,2,3 or 4. But we must
continue in proper order for proper rotation.
In programs on blog I have mostly begun from
step 3.
other step sequences are as below
Half Step 8 Step Sequence
Step #
|
Winding A
|
Winding B
|
Winding C
|
Winding D
|
1
|
1
|
0
|
0
|
1
|
2
|
1
|
0
|
0
|
0
|
3
|
1
|
1
|
0
|
0
|
4
|
0
|
1
|
0
|
0
|
5
|
0
|
1
|
1
|
0
|
6
|
0
|
0
|
1
|
0
|
7
|
0
|
0
|
1
|
1
|
8
|
0
|
0
|
0
|
1
|
Wave drive 4 step sequence
Step #
|
Winding A
|
Winding B
|
Winding C
|
Winding D
|
1
|
1
|
0
|
0
|
0
|
2
|
0
|
1
|
0
|
0
|
3
|
0
|
0
|
1
|
0
|
4
|
0
|
0
|
0
|
1
|
q2) how much movement is associated with a step angle??
Step angle
|
Steps per revolution
|
.72
|
500
|
1.8
|
200
|
2
|
180
|
2.5
|
144
|
5
|
72
|
7.5
|
48
|
15
|
24
|
------------------
Edit - 1: Changed the Line DJNZ R0 to R1 as it was a mistake in typing.
confusinggggggggggggggggggg
ReplyDeleteokay..
Deletewhats confusing you??
i dont undrstnd the step angle??
DeleteStep angle is the angle covered in a single step of stepper motor.
DeleteSo if we say step angle of a stepper motor is 0.72 it means one step of stepper motor will cover 0.72 degree.
So if a stepper motor needs to rotate a full circle it requires to rotate 0.72 angle 500 times.
You need to give 500 pulses to a stepper motor to make it cover one complete cycle.
i want to rotate stepper motor only one step the how can i write program for that please give some guidence
ReplyDeleteLets looks at the same program given above.
Delete; THIS OTHER PROGRAM CODE HOW IN SAME INTERFACING TO ROTATE A STEPPER MOTOR
; 64 DEGREES IN CLOCKWISE DIRECTION USING 4 STEP SEQUENCE
; IT TAKES SOME CALCULATIONS
; CONSIDER A MOTOR WITH STEP ANGLE 2 DEGREE
; SO STEPS PER REVOLUTION = 180
; NO OF ROTOR TEETH = 45
; MOVEMENT PER 4 STEP SEQUENCE IS 8 DEGREES
; FOR 64 DEGREE MOVEMENT WE NEED TO SEND 8 CONSECUTIVE 4 STEP SEQUENCE
; THAT IS IT WILL COVER 32 STEPS
; Now we need to cover 1 step only that is only 2 degrees so here is the program for it.
ORG 0000H
MOV A, #66H
MOV R1, #01H ; 01 STEPS TO BE TAKEN
BACK :
RR A ; ROTATE CLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R0, BACK ;
END
-----------------
i have one program on that one diculty is occure so can u handle that problem plzzz.....
DeleteSure why not..
Deletei need a assembly language code for stepper motor -120 degree clock wise & 35 degree anti clock wise...
ReplyDeleteThis comment has been removed by the author.
ReplyDeletemy qstn is here why we are taking MOV R2, #100 and MOV R3, #255 for DJNZ instrucion Simultaneously whats the need? one more is why the MOV A, #66h or 48h used for step sequence what exact statement means
ReplyDeleteis it you have facebook ,easy to me to contact you
ReplyDeleteIts not CLR how this is decided that we have to rotate right for clockwise direction
ReplyDeleteIts not CLR how this is decided that we have to rotate right for clockwise direction
ReplyDeletePlzz tell me the "assembly language program for 8051 to rotate stepper motor in clockwise and anticlockwise direction with step angle 1.8 degree"
ReplyDeleteHi Saurabh following is the program that you can use to rotate clockwise or anticlockwise with step angle 1.8 degree.
Delete; 120 DEGREES IN CLOCKWISE DIRECTION USING 4 STEP SEQUENCE
; CONSIDER A MOTOR AS IN YOUR CASE WITH STEP ANGLE 1.8 DEGREE
; SO STEPS PER REVOLUTION = 200
; NO OF ROTOR TEETH = 45
; MOVEMENT PER 4 STEP SEQUENCE IS 4*1.8 = 7.2 DEGREES
; FOR 120 DEGREE MOVEMENT WE NEED TO SEND 16 CONSECUTIVE 4 STEP SEQUENCE
; THAT IS IT WILL COVER 66 STEPS
ORG 0000H
MOV A, #66H
MOV R1, #66H
; Rest of the program remains the same.
Write an Alp to run the stepper motor continuosly...
Deletesir wht if we wnt to do it by using bipolar motor..any major changes required?
ReplyDeleteYes there will be major changes. This program has been made kept in mind that the poles in the motor are all the same. If you are using bipolar then the whole pulsing sequence will change accordingly.
Deletewhy 66 to port 1 why we use it? what is it?
ReplyDeleteif possible could u plz give me the explanation regarding using of 66
ReplyDeletewhy use DJNZ R0
ReplyDeleteIt is DJNZ R1 not R0 the value has been stored in R1 not in R0.
Deletewhy use DJNZ R0
ReplyDeleteIt is DJNZ R1 not R0 the value has been stored in R1 not in R0.
DeleteWrite an ALp to rotate a four coil stepper motor by 10 steps in forward direction and 2 steps in backward direction
ReplyDeleteTry the following section of code.
DeleteYou can test out the following section of code...
ORG 0000H
MOV A, #66H
MOV R1, #10H ; 10 STEPS TO BE TAKEN
BACK :
RR A ; ROTATE CLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R1, BACK ;
MOV R1, #02H ; 06 STEPS TO BE TAKEN
BACK :
RL A ; ROTATE ANTICLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R1, BACK ;
END
kindly-
ReplyDeletewrite an ALP to rotate it 75 degree
kindly revert asap
Write an ALp to rotate a four coil stepper motor by 16 steps in backward direction and then 2 steps in forward direction
ReplyDeletetomorrow is my exam ..kindly help me out
ReplyDeleteKindly tell me how to programm stepper motor for analog clock....PlZ
ReplyDeleteThere are multiple ways of doing this. One of the easiest way is to setup a counter of 1 sec in the microcontroller and then give fixed pulse to stepper motor to just make it go one step. So you need to keep the motor energized then give one pulse to make it move one step. This will give a second clock. Further you need to see and make sure that it only takes 60 steps so based on the motor you purchase have equivalent step angle.
DeleteIf you cant find the motor with equivalent step angle then you need to have a check logic that will make motor rotate according for the complete cycle.
Kindly tell me how to programm stepper motor for analog clock....PlZ
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteKindly tell me how to programm stepper motor for analog clock....PlZ
ReplyDeleteWe have not loaded register ro and hw come we are decrementing it????? I think it should be DJNZR1
ReplyDeleteYes it is DJNZ R1. Thanks for noticing... I have updated the post with the same..
DeleteWhat will be a program to drive motor in clockwise 6 rotations and anti clockwise 6 rotations consecutively??
ReplyDeleteYou can test out the following section of code...
DeleteORG 0000H
MOV A, #66H
MOV R1, #06H ; 06 STEPS TO BE TAKEN
BACK :
RR A ; ROTATE CLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R1, BACK ;
MOV R1, #06H ; 06 STEPS TO BE TAKEN
BACK :
RL A ; ROTATE ANTICLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R1, BACK ;
END
i want to know program to drive stepper motor in clockwise direction for 6 rotation and anticlockwise direction 6 locations continuously
ReplyDeleteYou can test out the following section of code...
DeleteORG 0000H
MOV A, #66H
MOV R1, #06H ; 06 STEPS TO BE TAKEN
BACK :
RR A ; ROTATE CLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R1, BACK ;
MOV R1, #06H ; 06 STEPS TO BE TAKEN
BACK :
RL A ; ROTATE ANTICLOCKWISE
MOV P1, A ;
ACALL DELAY ;
DJNZ R1, BACK ;
END
Sir write program in timer 1 mode to generate delay of 5 ms
ReplyDeleteSir I want a stepper motor program for sun tracking solar panel with delay
ReplyDeleteExplain the stepper motor interfacing to ARM microcontroller LPC-1768. Write an embedded C program to rotate the motor in clockwise/anticlockwise direction with 8 different speeds using a 4x4 matrix keyboard. i.e. First two rows for clockwise and the next two rows for the anti clockwise rotation.
ReplyDeletePlease, can anyone tell me the code for this ,that runs on keil.4
Explain the stepper motor interfacing to ARM microcontroller LPC-1768. Write an embedded C program to rotate the motor in clockwise/anticlockwise direction with 8 different speeds using a 4x4 matrix keyboard. i.e. First two rows for clockwise and the next two rows for the anti clockwise rotation.
ReplyDeletePlease, can anyone tell me the code for this ,that runs on keil.4
i wanna rotate stepper motor clockwise and counterclock wise in one program can it be done?
ReplyDeleteULN2003 is used for sinking the current, and not to energizing the coil as it is already powered up by the voltage source connected to the central tapped winding. Correct it please!!!
ReplyDeleteULN2003 is a darlington pair used to drive loads that cannot be driven directly via outputs of a microcontroller. There is nothing to be corrected here.
DeleteBTW all of your code and content is copied from the book The 8051 Microcontroller and Embedded Systems by Ali Mazidi.
ReplyDeleteWhy 66H and not 6H 3rd step is 0110.
ReplyDeleteHELP ME
ReplyDeleteChoose one type of stepper motor .
i. Design a small apparatus to rotate the stepper motor clockwise, anticlockwise and to measure the RPM after pressing correspondent switches and draw the connection diagram of your apparatus.
ii. Explain about the interfacing devices that you have used in your design.
iii. Write an ALP of your desin
Write an Alp to run stepper motor continuosly.update the answer as fast as possible....
ReplyDeleteWrite an ALP for half stepping of stepper motor in clockwise and anticlock direction considering water sensor input.please sir give early reply.
ReplyDeleteFor rotating stepper motor in anticlockwise direction through 180 degrees if step angle is 1.8 degrees what will be an ALP?
ReplyDeleteOnly count for 4 steps will change and RL a instruction is used instead of RR A for anticlockwise direction
DeleteMOV A, #66H
MOV R0,#25
UP : MOV P1,A
AGAIN : RL A
ACALL DELAY
DJNZ R0,AGAIN
SMJP UP
remain same
Why Mov A,#66H used
ReplyDeleteAlp for clockwise rotation at 200rpm please? ????
ReplyDeletePlease,
ReplyDeleteWriter anALP to run a stepper motor with step angle 1.8 interfaced to 8051 alternatively in slow & high speeds in anti clock direction
Writer anALP to run a stepper motor with step angle 1.8 interfaced to 8051 alternatively in slow & high speeds in anti clock direction?
ReplyDeletePlease give me the answer. Please...
Rotate stepper motor 90 degree in clockwise direction, stop there for 1 sec and again rotate 45 degree it the opposite direction. Consider Half Drive Mode.
ReplyDeletehi
ReplyDeletecolud you tell me how to Contact betwen the 8051 microcontrolar and matlab?
hello sir,
ReplyDeletei want to draw a 70 mm diameter circle using two stepper motor with the help of AT89C51 controller but i unable to write code
and i use port 2 for 1 motor and port 3 for other motor
sir can you code for me in assembly or c..??
Design a system to rotate the stepper motor five degree in clockwise and twenty five degree anticlockwise for 10 times and stop
ReplyDeletePlease help me urgently solve this
develop an assembly language program to rotate stepper motor by 90° in anticlockwise direction assume 1.8 step angle.
ReplyDeletedevelop an assembly language program to rotate stepper motor by 90° in anticlockwise direction assume 1.8 step angle
ReplyDeletePlease give me the answer please
ReplyDelete