Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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) {

    }
}



List of 30 messages in thread
TopicAuthorDate
General Pulse Width Modulation on 8051            01/01/70 00:00      
   The logic seems good            01/01/70 00:00      
      How to post code            01/01/70 00:00      
      Code I'm using            01/01/70 00:00      
         Problem lies with SDCC and PSW handling.            01/01/70 00:00      
            similar "issue" with Keil?            01/01/70 00:00      
            PSW not touched in recent version            01/01/70 00:00      
               Old SDCC (ver ??) vs New SDCC (ver 2.50)            01/01/70 00:00      
                  strange            01/01/70 00:00      
                     not strange, sorry            01/01/70 00:00      
                        Still no good            01/01/70 00:00      
                           Still not strange            01/01/70 00:00      
   Alternative method            01/01/70 00:00      
   65536, not 65535            01/01/70 00:00      
      Caught that errror            01/01/70 00:00      
         why not use the PCA, it is made for this            01/01/70 00:00      
            No PCA available            01/01/70 00:00      
               slim PICkins            01/01/70 00:00      
               go ahead, spend $7            01/01/70 00:00      
                  Why not read 8051 stuff?            01/01/70 00:00      
                     Excellent - Thanks            01/01/70 00:00      
                  Atmel Flip            01/01/70 00:00      
                     MAX232(equivalent)            01/01/70 00:00      
                        Another Option            01/01/70 00:00      
                     level convertor            01/01/70 00:00      
                        aka "Transceiver"            01/01/70 00:00      
         JSIM.EXE is all you need and it FREE.            01/01/70 00:00      
   Still not strange            01/01/70 00:00      
   Follow Up to the original post            01/01/70 00:00      
      Dumb and dumberrer            01/01/70 00:00      

Back to Subject List