CONNECTION :
There are actually many ways you can interface a stepper motor to your controller, out of them the most used interfaces are:- Interface using L293D - H-Bridge Motor Driver
- Interface using ULN2003/2004 - Darlington Arrays
We will dicuss both connection techniques one by one. The above mentioned methods need 4 controller pins for interface.
Connecting Unipolar stepper using L293D
As you see in the circuit above the four pins "Controller pin 1",2,3 and 4 will control the motion and direction of the stepper motor according to the step sequece programmed in the controller.Connecting Unipolar stepper using ULN2003/2004
As already discussed in case of L293D, Here in this circuit too the four pins "Controller pin 1",2,3 and 4 will control the motion and direction of the stepper motor according to the step sequece sent by the controller.
Connecting Bipolar Stepper Motor
As we have studied that, Bi-polar stepper motors has 2 different coils. The step sequence for Bipolar stepper motor is same as that of unipolar stepper motors. The driving circuit for this require an H-Bridge as it allows the polarity of the power applied to be controlled independently. This can be done as shown in the figure below:
Now we have seen the methods for connecting stepper motors with your microcontroller. So keeping these circuits in mind,we will now look at the programming of microcontroller to control stepper motors.PROGRAMMING :
►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.
►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.
CODE:
#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++);
}
#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
CODE:
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
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.
►Programming Half step Sequence
►C Programming
Just the main routine changes rest everything remains same, i mean same delay routine.
►C Programming
Just the main routine changes rest everything remains same, i mean same delay routine.
CODE:
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();
}
}
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.
CODE:
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
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.
►Programming for Bipolar Stepper Motor
►C Programming
CODE:
void main(){
while(1){
stepper = 0x08;
delay();
stepper = 0x02;
delay();
stepper = 0x04;
delay();
stepper = 0x01;
delay();
}
}
while(1){
stepper = 0x08;
delay();
stepper = 0x02;
delay();
stepper = 0x04;
delay();
stepper = 0x01;
delay();
}
}
►Assembly Programming
CODE:
main:
mov stepper, #08H
acall delay
mov stepper, #02H
acall delay
mov stepper, #04H
acall delay
mov stepper, #01H
acall delay
sjmp main
mov stepper, #08H
acall delay
mov stepper, #02H
acall delay
mov stepper, #04H
acall delay
mov stepper, #01H
acall delay
sjmp main
Stepper Motor Interface To Microcontroller ~ Software Movie And Information >>>>> Download Now
BalasHapus>>>>> Download Full
Stepper Motor Interface To Microcontroller ~ Software Movie And Information >>>>> Download LINK
>>>>> Download Now
Stepper Motor Interface To Microcontroller ~ Software Movie And Information >>>>> Download Full
>>>>> Download LINK wk