Assembly code for Stepper Motor


Sample code for Stepper Motor
Following code can be using for 8051 and 8052 ICs like: 89c51, 89c52, 89s51, 89s52, 89c2051.

 

;========================================================== ; Pin Definations ;========================================================== motor1 equ a2h ;Motor P2.2 - P2.5 motor2 equ a3h motor3 equ a4h motor4 equ a5h ;========================================================== ; Main Program starts from here ;========================================================== stepper: clr motor1 clr motor2 clr motor3 clr motor4 mov 51h,#03h stepper_loop: setb motor1 call delhalf clr motor1 call delhalf setb motor2 call delhalf clr motor2 call delhalf setb motor3 call delhalf clr motor3 call delhalf setb motor4 call delhalf clr motor4 call delhalf djnz 51h,stepper_loop ret ;========================================================== stepper_reverse: clr motor1 clr motor2 clr motor3 clr motor4 mov 51h,#03h stepper_rev_loop: setb motor4 call delhalf clr motor4 call delhalf setb motor3 call delhalf clr motor3 call delhalf setb motor2 call delhalf clr motor2 call delhalf setb motor1 call delhalf clr motor1 call delhalf djnz 51h,stepper_rev_loop ret ;===================================================== ; Program ENDS here ;=====================================================