This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Servo controlling program

I've written this program for AT89S52 to control a servo.The signal pin of the servo is connected to the P1_0 of the chips and a LED is connected to the P2_7 of the chip.When I turned the circuit on the servo had no response and only the LED have lit up.Please help me to check if there is any mistake in my program.

#include<AT89X52.h>
unsigned int PWMHIGH;
sbit PWM=P1^0;
void timer0 () interrupt 1
{
   TL0 = (65536- 20000) & 0xFF;                                       //20ms
   TH0 = ((65536-20000) & 0xFF00) >> 8;
   TL1 = (65536-PWMHIGH) & 0xFF;                              //1.5ms
   TH1 = ((65536-PWMHIGH) & 0xFF00)>>8;
   PWM = 1;
   TR1 = 1;
}
void timer1 () interrupt 3
{
   PWM = 0;  TR1 = 0;
}

void main()
{
P2_7=0;
   IE = 0x8A; // EA, Timer0, Timer 1
   // Timer0 , Timer1 Mode1
   TMOD= 0x11;
   PWMHIGH = 1000; // on time
   //timer turn on
   TR0 = 1;
   TF0 = 1;
   while(1);
}

Parents
  • Thanks my friend ....and I am sorry for late in replay ( it's my week end ) .
    anyway I couldn't stop my self from laugh ..
    I have tested ur Project1 file and it work very fine ...and I got the right value .
    very good at this point . I start the program load the source code and run it inside ,and Ooops i got the wrong value again ...what happen here !!!???
    is there a good logical reason for that pls

    My friend the best command in basic was GoTo ....
    I used it in many ways ...I like this command ,it is the best .

Reply
  • Thanks my friend ....and I am sorry for late in replay ( it's my week end ) .
    anyway I couldn't stop my self from laugh ..
    I have tested ur Project1 file and it work very fine ...and I got the right value .
    very good at this point . I start the program load the source code and run it inside ,and Ooops i got the wrong value again ...what happen here !!!???
    is there a good logical reason for that pls

    My friend the best command in basic was GoTo ....
    I used it in many ways ...I like this command ,it is the best .

Children