►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
Anup Teke Avatar
Posted By Anup Teke
Wed Jul 23 2014, 03:28 AM
Sir,I was doing like thisMCP3901_CS = 0;WriteSPI1(0x01);TempData = ReadSPI1( );TempData <<= 8;TempData |= ReadSPI1( );TempData <<= 8;TempData |= ReadSPI1( );MCP3901_CS = 1;and my problem solved by doing like thisMCP3901_CS = 0; WriteSPI1(0x01); TempData = ReadSPI1( ); TempData <<= 8; MCP3901_CS = 1; MCP3901_CS = 0; WriteSPI1(0x03); TempData |= ReadSPI1( ); TempData <<= 8; MCP3901_CS = 1; MCP3901_CS = 0; WriteSPI1(0x05); TempData |= ReadSPI1( ); MCP3901_CS = 1;
pravin_35 Avatar
Posted By pravin_35
Wed Jul 23 2014, 12:57 AM
Can the Pickit3 read the Pics signature bytes and ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jul 22 2014, 04:24 PM
Can the Pickit3 read the Pics signature bytes and ...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jul 22 2014, 04:16 PM
Does the DS1307 keep time ?That is, if you set it ...
pravin_35 Avatar
Posted By pravin_35
Tue Jul 22 2014, 01:05 PM
hi... i have done with a simple blinky program wi...
pravin_35 Avatar
Posted By pravin_35
Tue Jul 22 2014, 07:23 AM
Autoscale does not know what settings you keep on ...
ajay_bhargav Avatar
Posted By ajay_bhargav
Tue Jul 22 2014, 02:19 AM
[Topic moved to PIC Microcontroller Discussion For...
ajay_bhargav Avatar
Posted By ajay_bhargav
Tue Jul 22 2014, 02:18 AM
[Topic moved to electronics discussion forum]
ajay_bhargav Avatar
Posted By ajay_bhargav
Tue Jul 22 2014, 02:17 AM
This type of problem comes in gcc based softwares....
ajay_bhargav Avatar
Posted By ajay_bhargav
Tue Jul 22 2014, 01:54 AM
are you sure your read is working properly? I mean...

Conversation

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
ExperimenterUK
Tue Jul 08 2014, 03:25 PM
Post questions in the forum.. this area is for chat
Tue Jul 08 2014, 08:15 AM
P.Panchanyam
Sir i want some new ideas for my final year projects ,which would help for our soceity in future
Tue Jul 08 2014, 01:39 AM
jasvinder
Dear Sir Ref. to the discussion held with under sign, the detail is as under--- We are in weighing scale field since 1986. We are assembling the scales by purchasing the material from out source ( From India and other countries). Now we decide to make our own Card in our decided shape. So we want to develop a universal card , which we can make all types of scales of up 100000 counts with 7 segment LED Display . Also with other features like Printing, Counting, RS232 Etc. And Three Pass words at different levels. And we can edit the Softwear. What else you can provide in this field, also mention. We will pay you the development , softwear and testing charges. And up-gradation charges at time to time. Our web site is modern-scales.com Kindly revert.
Mon Jul 07 2014, 09:20 AM
tadashige matuda
Please tell me about pic instruction ADDWF fileName,f ; fileName=fileName+W. Why twice memory access (1)fileName+W,(2)fileName=fileName+W, be able in one instruction cycle. For MOVWF fileName ; memory access once in an one instruction cycle.
Mon Jul 07 2014, 09:08 AM
tadashige matuda
pic instruction
vshal
Thu Jul 03 2014, 11:09 AM
Can somebody tell me, RLP434A 418MHz RF receiver module , this module Where get in pune ?

Downloads

Comments

vinosentinal
Mon Jul 21 2014, 08:28 PM
niks_here
Sun Jul 20 2014, 05:38 PM
athiramsankar
Sun Jul 20 2014, 12:00 PM
salemalqahtani
Sun Jul 20 2014, 12:55 AM
nagarajan.electro
Sat Jul 19 2014, 12:49 AM
praru
Sat Jul 12 2014, 07:51 AM
nmcleod1993
Thu Jul 10 2014, 09:02 AM
abdulmannan39
Thu Jul 10 2014, 05:50 AM

Online

Guests: 41, Members: 0 ...

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

Members: 37479
Newest member: vinosentinal