Connect with us

futaba servos with 8051

Discussion in 'Microcontrollers, Programming and IoT' started by burassu, Mar 18, 2012.

Scroll to continue with content
  1. burassu

    burassu

    36
    0
    Jul 1, 2011
    hi I am using this code to drive servos with 8051 but my problem is that they are giving a kick and back to there place , below is my code . As one could see they suppose to turn to 78 degrees , but it is not working . Can someone pls help me figure out the problem ?


    void timer(int msec) // Function to produce pulse as defined by user
    {
    int i;
    TR1=1;
    for(i=0;i<msec;i++)
    {
    if (TF1==0);
    TF1=0;
    }
    TR1=0;
    }

    void servo()

    {
    {
    int H;

    TMOD=0x20; // MODE2
    TH1= -23; // 50 usec timer

    output=0;


    msdelay(100);

    count=0;

    check=0;
    digit[0]=8;
    digit[1]=7;
    digit[2]=0;


    time=(digit[0]+(digit[1]*10)+(digit[2]*100));

    time=time%180;


    time= time*0.5; // (110-14)/180=0.53
    for(H=0;H<200;H++)
    {
    output=1;
    timer(14);
    output=0;
    timer(360);
    }
    msdelay(100);
    for(H=0;H<200;H++)
    {
    output=1;
    timer(time+14);
    output=0;
    timer(360);
    }
    timer(3000000);
    }
    }
     
  2. gorgon

    gorgon

    603
    24
    Jun 6, 2011
    I suppose you send the pulse every 12-20ms? You need to transmit a continous train of pulses, each pulse in the range between 1-2ms to reflect the position.

    TOK ;)
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-