►Programming Full step Sequence

►C Programming
I am assuming that stepper motor is connected at Port 1.0 to Port 1.3. Adjusting the delay will increase or decrease the speed of the motor. Here just for demonstration i have taken some delay, you can change it as you want.

[Tip: Do testing.. ]




#include <REG2051.H>
.
#define stepper P1
void delay();

void main(){
	while(1){
		stepper = 0x0C;
		delay();
		stepper = 0x06;
		delay();
		stepper = 0x03;
		delay();
		stepper = 0x09;
		delay();
	}
}

void delay(){
	unsigned char i,j,k;
	for(i=0;i<6;i++)
		for(j=0;j<255;j++)
			for(k=0;k<255;k++);
}



►Assembly Programming

	org 0H

stepper equ P1

main:
	mov stepper, #0CH
	acall delay
	mov stepper, #06H
	acall delay
	mov stepper, #03H
	acall delay
	mov stepper, #09H
	acall delay
	sjmp main

delay:
	mov r7,#4
wait2:
	mov r6,#0FFH
wait1:
	mov r5,#0FFH
wait:
	djnz r5,wait
	djnz r6,wait1
	djnz r7,wait2
	ret
	end


The working of the above code can be seen in the demo animation below.

unipolar stepper motor in full step sequence


►Programming Half step Sequence

►C Programming
Just the main routine changes rest everything remains same, i mean same delay routine.


void main(){
	while(1){
		stepper = 0x08;
		delay();
		stepper = 0x0C;
		delay();
		stepper = 0x04;
		delay();
		stepper = 0x06;
		delay();
		stepper = 0x02;
		delay();
		stepper = 0x03;
		delay();
		stepper = 0x01;
		delay();
		stepper = 0x09;
		delay();
	}
}



►Assembly Programming
Here also the main routine changes rest everything remains same.


main:
	mov stepper, #08H
	acall delay
	mov stepper, #0CH
	acall delay
	mov stepper, #04H
	acall delay
	mov stepper, #06H
	acall delay
	mov stepper, #02H
	acall delay
	mov stepper, #03H
	acall delay
	mov stepper, #01H
	acall delay
	mov stepper, #09H
	acall delay
	sjmp main


The working of the above code can be seen in the demo animation below.

unipolar stepper motor in half step sequence


►Programming for 2-wire connection of Unipolar Stepper Motor

►C Programming
void main(){
	while(1){
		stepper = 0x03;
		delay();
		stepper = 0x01;
		delay();
		stepper = 0x00;
		delay();
		stepper = 0x02;
		delay();
	}
}



►Assembly Programming
main:
	mov stepper, #03H
	acall delay
	mov stepper, #01H
	acall delay
	mov stepper, #00H
	acall delay
	mov stepper, #02H
	acall delay
	sjmp main


The working of the above code can be seen in the demo animation below.

unipolar stepper motor in 2-wire connection mode


►Programming for Bipolar Stepper Motor

►C Programming
void main(){
	while(1){
		stepper = 0x08;
		delay();
		stepper = 0x02;
		delay();
		stepper = 0x04;
		delay();
		stepper = 0x01;
		delay();
	}
}



►Assembly Programming
main:
	mov stepper, #08H
	acall delay
	mov stepper, #02H
	acall delay
	mov stepper, #04H
	acall delay
	mov stepper, #01H
	acall delay
	sjmp main



Now you're ready to use stepper motors. If you have any doubts, please post in the forum.

◄ Previous Page  |  Next Page ►

Back to main


DC Motor Tutorial Index
Introduction to Stepper Motors
Stepper Motor Connections
Step Sequence of Stepper Motors
Programming for Stepper Motor
Forum Activity
pravin_35 Avatar
Posted By pravin_35
Thu Jul 31 2014, 01:49 AM
attach is the code for lcd may be need a little ch...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:45 PM
@ sermeteraythank you for sharing your experience ...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:38 PM
@ Peter_ParkerHC06 by default baud rate is 9600try...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:25 PM
attach is the code for lcd may be need a little ch...
majoka Avatar
Posted By majoka
Wed Jul 30 2014, 02:21 PM
@ pravin_35both compilers are almost sameif you ha...
pravin_35 Avatar
Posted By pravin_35
Wed Jul 30 2014, 07:38 AM
http://extremeelectronics.co.in/pic16f877a-tutoria...
NexusRevZ Avatar
Posted By NexusRevZ
Wed Jul 30 2014, 02:31 AM
Ok, I have edited the code, it's updated above wit...
NexusRevZ Avatar
Posted By NexusRevZ
Wed Jul 30 2014, 02:10 AM
Oh tahnk you so much for the reply. I will do imme...
ajay_bhargav Avatar
Posted By ajay_bhargav
Wed Jul 30 2014, 01:56 AM
You cannot move and read data from EEPROM immediat...
pravin_35 Avatar
Posted By pravin_35
Wed Jul 30 2014, 12:39 AM
Remove all power connections to the circuit at the...

Conversation

NexusRevZ
Tue Jul 29 2014, 09:32 PM
Anyone good in Asm lang?
ajay_bhargav
Mon Jul 28 2014, 12:34 AM
@ Anshu Raj sorry we do not take such requests.
Sun Jul 27 2014, 12:23 AM
Anshu Raj
sir plz send the automatic collage alram bells in 2 hrs bells ring. For microcontroller programme plz sir
ajay_bhargav
Thu Jul 24 2014, 01:06 AM
@R.ABHISHEK where? I dont see it. is it in forum?
Wed Jul 23 2014, 05:49 AM
R.ABHISHEK
sir,pls message on microcontroller 8051 assambly language new program
Wed Jul 23 2014, 05:47 AM
R.ABHISHEK
sir,pls message on 8051 microcontroller assambly language program new quastions
ajay_bhargav
Tue Jul 22 2014, 09:18 AM
@Pragya Android application is taken from google play. Only Author has its source with him. Application is only used in this project.
Tue Jul 22 2014, 04:58 AM
Pragya
plz send me 8051 code and android code for android based device controller via Bluetooth .Here in this project I am using Hc-06 Bluetooth module
Thu Jul 10 2014, 09:57 AM
Caleb
plz someone mail me the source code for that project
Thu Jul 10 2014, 09:57 AM
Caleb
http://www.8051projects.net/download-d188-control-your-pc-tv-remote.html

Downloads

Comments

ismaelfogaca
Thu Jul 31 2014, 10:50 AM
NexusRevZ
Tue Jul 29 2014, 09:29 PM
kritz22
Mon Jul 28 2014, 10:33 AM
Abbasans786
Mon Jul 28 2014, 03:15 AM
Imran.pk
Fri Jul 25 2014, 07:50 PM
PavanKh
Fri Jul 25 2014, 12:56 AM
vinosentinal
Mon Jul 21 2014, 08:28 PM
niks_here
Sun Jul 20 2014, 05:38 PM

Online

Guests: 41, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 01:37 AM

Members: 37485
Newest member: ismaelfogaca