CrazyEngineers
  • stepper motor controll with AT89C51

    Prakash Parmar

    Prakash Parmar

    @prakash-parmar-fN6I9f
    Updated: Oct 22, 2024
    Views: 937
    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<at89x51.h>
    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<itime;i++);
    }
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Harshad Italiya

    MemberMar 24, 2012

    Try this code . . You forgot to add the infinite loop in this code.

     
    #include<at89x51.h>
    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<itime;i++);
    }
    Are you sure? This action cannot be undone.
    Cancel
  • Prakash Parmar

    MemberMar 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....
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberMar 24, 2012

    can you change your pin from p0.0 to p3.2 it is interrupt pin?
    Are you sure? This action cannot be undone.
    Cancel
  • Prakash Parmar

    MemberMar 24, 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..
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberMar 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?
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberMar 26, 2012

    #-Link-Snipped-# , Are you working on code or not?
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberMar 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.
    Are you sure? This action cannot be undone.
    Cancel
  • Prakash Parmar

    MemberMar 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<reg.h>
    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<value;y++);
    }
    
    .
    .
    .
    .
    my english is so poor......😔 , so can we communicate in HINDI or GUjarati????
    Are you sure? This action cannot be undone.
    Cancel
  • Prakash Parmar

    MemberMar 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???
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberMar 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<reg.h>
    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<value;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.
    Are you sure? This action cannot be undone.
    Cancel
  • Prakash Parmar

    MemberMar 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 #-Link-Snipped-#
    .
    Are you sure? This action cannot be undone.
    Cancel
  • Harshad Italiya

    MemberApr 9, 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 #-Link-Snipped-#
    .
    Right now we are using Full Stepping you have to use Half stepping and give it a try.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register