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 }

Replies

  • Harshad Italiya
    Harshad Italiya
    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
    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
    can you change your pin from p0.0 to p3.2 it is interrupt pin?
  • Prakash Parmar
    Prakash Parmar
    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..
    #-Link-Snipped-#
  • Harshad Italiya
    Harshad Italiya
    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
    #-Link-Snipped-# , Are you working on code or not?
  • Harshad Italiya
    Harshad Italiya
    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
    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
    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
    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
    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 #-Link-Snipped-#
    .
  • Harshad Italiya
    Harshad Italiya
    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 #-Link-Snipped-#
    .
    Right now we are using Full Stepping you have to use Half stepping and give it a try.

You are reading an archived discussion.

Related Posts

I am searching for books on agricultural entrepreneurs and agriculture in general. I want them in Indian context. Those I found were American and I guess not much work is...
Just a few minutes ago, I wrote a brief email to an influential personality who's trying to drive development in central India. I was asked for my ideas and while...
Why is it necessary to use iron core in the LVDT (Linear Varibale Different Transformer)?
Hi, My name is Franck. I am trying to use the RFM70 -D via PIC18F4610 but my knowledge in this area is a bit weak. Basically I do not completely...
I hope this isn't the wrong place to post this kind of question. I'm building a home made "long tail" outboard motor. I'm trying to take a 9HP Hatz diesel...