View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12793 Members
Join this group to post and comment.
Prakash Parmar
Prakash Parmar • Mar 24, 2012

stepper motor controll with AT89C51

Hey....
I want to controll Stepper motor with At89c51..
and i made simulation in proteus.. and program made in keil
.
.
.
but i cant make loop for it.... it will rotate only one rotation

so, can Anybudy help me for making loop...???😔.. for full rotation....

this is the fig. [​IMG]

and this is code for it...

#include
void delay(unsigned int);
void main (void)
{

P2_4=0;
delay(30000000000);
P2_4=1;
delay(30000000000);
P2_2=0;
delay(30000000000);
P2_2=1;
delay(30000000000);
P2_3=0;
delay(30000000000);
P2_3=1;
delay(30000000000);
P2_1=0;
delay(30000000000);
P2_1=1;
delay(30000000000);


}
void delay(unsigned int itime)
{
int i;
for(i=0;i }
Harshad Italiya
Harshad Italiya • Mar 24, 2012
Try this code . . You forgot to add the infinite loop in this code.

 
#include
void delay(unsigned int);
void main (void)
{
for(;;)
{
P2_4=0;
delay(30000000000);
P2_4=1;
delay(30000000000);
P2_2=0;
delay(30000000000);
P2_2=1;
delay(30000000000);
P2_3=0;
delay(30000000000);
P2_3=1;
delay(30000000000);
P2_1=0;
delay(30000000000);
P2_1=1;
delay(30000000000);
}

}
void delay(unsigned int itime)
{
int i;
for(i=0;i
 
Prakash Parmar
Prakash Parmar • Mar 24, 2012
thanx a lot sir.....
.
.
can you tell me how can i set "ON" or "OFF" logic for port 0.0..
so, if i gave logic to port 0.0 "1" then it start... & logic to port 0.0 "0" then it stop... for below image....[​IMG].
.
.
thank you....
Harshad Italiya
Harshad Italiya • Mar 24, 2012
can you change your pin from p0.0 to p3.2 it is interrupt pin?
Prakash Parmar
Prakash Parmar • Mar 25, 2012
instead of p3.2(intrupt pin) it will be possible with pin p3.4, p3.5, p3.6, p3.7...????
.
.
bcause my project diagram is look like below....

[​IMG]
so, how can i controll stepper motor...???.. if you have any simple program then also tell me.... because i am new to microcontroller or say "0" in microcontroller....
.
.
and my main referance is..
https://multyremotes.com/wireless-stepper-motor-control.htm
Harshad Italiya
Harshad Italiya • Mar 25, 2012
well it's possible but as you see there is delay in between port pin change. Ok how if i guide you that how to write code instead of giving you code directly. First you try then i'll point out your fault. Is it fine?
Harshad Italiya
Harshad Italiya • Mar 26, 2012
Prakash Parmar , Are you working on code or not?
Harshad Italiya
Harshad Italiya • Mar 26, 2012
With reference of this design. . . .
[​IMG]

You are going to tranfer data on Port pin P3.4/P3.5/P3.6/P3.7 to Stepper motor Right? and P3.3 Decides to Turn Motor ON and OFF.
Prakash Parmar
Prakash Parmar • Mar 26, 2012
yes.... the port pin connection is right....
.
.
but i cant understand its logic ...
because our project title is "RF BASED WIRELESS STEPPER MOTOR USING PARALLEL PORT"
so we made vb form. In that form there are "ON" , "OFF", "clockwise" and "anticlockwise" button... and so there are 4 logic and 4 dataout pin of HT12D, so by that datout pin we have to contorll the motor...
and the above code work for loop which is uncontrollabe... so I have to control it...
.
.
.
I found a Program in Mazidi(book) which rotate the motor clockwise and anticlockwise with the help of switch(but it not works)...

#include
sbit SW=P2^7;
void main()
{
SW=1;
while(1)
{
if(SW==0)
{
P1=0x66;
MSDelay(100);
P1=0xCC;
MSDelay(100);
P1=0x99;
MSDelay(100);
P1=0x33;
MSDelay(100);
}
else
{
P1=0x66;
MSDelay(100);
P1=0x33;
MSDelay(100);
P1=0x99;
MSDelay(100);
P1=0xCC;
MSDelay(100);
}
}
}
void MSDelay(unsigned int value)
{
unsigned int x,y;
for(x=0;x<1275;x++)
for(y=0;y.
.
.
.
my english is so poor......😔 , so can we communicate in HINDI or GUjarati????
Prakash Parmar
Prakash Parmar • Mar 26, 2012
godfather
well it's possible but as you see there is delay in between port pin change. Ok how if i guide you that how to write code instead of giving you code directly. First you try then i'll point out your fault. Is it fine?
ok... guide me ... there are any other comand for delay or port change???
Harshad Italiya
Harshad Italiya • Mar 26, 2012
Prakash Parmar
yes.... the port pin connection is right....
.
.
but i cant understand its logic ...
because our project title is "RF BASED WIRELESS STEPPER MOTOR USING PARALLEL PORT"
so we made vb form. In that form there are "ON" , "OFF", "clockwise" and "anticlockwise" button... and so there are 4 logic and 4 dataout pin of HT12D, so by that datout pin we have to contorll the motor...
and the above code work for loop which is uncontrollabe... so I have to control it...
.
.
.
I found a Program in Mazidi(book) which rotate the motor clockwise and anticlockwise with the help of switch(but it not works)...

#include
sbit SW=P2^7;
void main()
{
SW=1;
while(1)
{
if(SW==0)
{
P1=0x66;
MSDelay(100);
P1=0xCC;
MSDelay(100);
P1=0x99;
MSDelay(100);
P1=0x33;
MSDelay(100);
}
else
{
P1=0x66;
MSDelay(100);
P1=0x33;
MSDelay(100);
P1=0x99;
MSDelay(100);
P1=0xCC;
MSDelay(100);
}
}
}
void MSDelay(unsigned int value)
{
unsigned int x,y;
for(x=0;x<1275;x++)
for(y=0;y.
.
.
.
my english is so poor......😔 , so can we communicate in HINDI or GUjarati????
CE is Global forum and we follow English only. Well Now let me know The code you have Posted in first post and I have corrected it in second post. Have you tested that code on Hardware?

We will go step by step. So, First complete this step and let me know.
Prakash Parmar
Prakash Parmar • Mar 26, 2012
I dont have tested on hardware but tested this code in proteus... and it wors... but first step it rotate in anticlockwise then constatnly rotate in clockwise.... and the stepangle is "90". but when i changed it to "1.8"{because i have 1.8 degree stepper motor} the 360 rotation takes more time..
.
.
my simulation and program is here https://www.datafilehost.com/download-fea12335.html
.
Harshad Italiya
Harshad Italiya • Apr 10, 2012
Prakash Parmar
I dont have tested on hardware but tested this code in proteus... and it wors... but first step it rotate in anticlockwise then constatnly rotate in clockwise.... and the stepangle is "90". but when i changed it to "1.8"{because i have 1.8 degree stepper motor} the 360 rotation takes more time..
.
.
my simulation and program is here https://www.datafilehost.com/download-fea12335.html
.
Right now we are using Full Stepping you have to use Half stepping and give it a try.

Share this content on your social channels -