??? 07/06/05 16:00 Read: times |
#96701 - Follow Up to the original post Responding to: ???'s previous message |
Hello again,
Just wanted to follow up on my original post. I am now using the code below to generate a 1.5ms pulse at 55Hz. I now have an oscilloscope and I verified this with it. I put the probe on P1.2 and there it was a nice square wave...1.5ms pulses. So I am not crazy, my math is right, my logic is right, the code is right. However, I am still pulling my hair out. I have connected the yellow wire of my servo directly to P1.2. The Red wire to a 6V source and the Black wire to ground. The microcontroller itself is hooked up to a 5v source so the output of P1.2 pulses at 5v. What I expect to happen when I turn it on is for the servo to center itself. However it just turns to its maximum rotation in one direction and sits and buzzes as if it is trying to go even further. I am using the Hobbico CS-60 and I have tried several of them, all with the same result. I know this is not an 8051 question per se, but the whole point of this exercise was servo control. If anyone has any wisdom to impart or any troubleshooting ideas I would greatly appreciate it. Here is the latest code: #include <at89x51.h> #define ON 1 #define OFF 0 #define HIGH 1 #define LOW 0 static bit cycle; void Timer0_ISR (void) interrupt 1; void Timer0_ISR (void) interrupt 1 { if(cycle) { P1_2 = OFF; TH0 = 0xC3; TL0 = 0xF2; cycle = LOW; } else { P1_2 = ON; TH0 = 0xFA; TL0 = 0x99; cycle = HIGH; } TF0 = OFF; return; } void main (void) { EA = ON; ET0 = ON; TR0 = OFF; TF0 = OFF; TMOD &= 0xF0; TMOD |= 0x01; TH0 = 0xFA; TL0 = 0x99; cycle = HIGH; P1_2 = OFF; TR0 = ON; while (1) { } } |