Servo sometimes moves sometimes it doesn't

I have spent a lot of time trying to figure this one out but just I can’t come up with something.

The problem is that I’m working on a robot arm (it uses 5 servos) and last week I had all the servos moving correctly, but when I tested it again last thursday it just wouldn’t do anything. Also, I’m testing the exact same code I had before but still no response, every now and then when I turn in the power supply for the servos and then execute the code, the servos would move, but that is very randomly. I have checked the connections from the microcontroller (ATmega16) to the servos, also I have checked the voltage and current supplied (5V and 6Amps respectively), and finally I have checked the pulse that I’m sending (which is the exact same as last week when it actually worked.

Im getting REALLY frustrated about this…any help will be greatly appreciated.

Also, the way I’m sending the pulses is something like this:

             PORTD=0xFF; //Sets all PORTD high (just for testing purposes to see that all the pins were working)
            delay_us(550); //Maintain the high status for the desired duty cycle
            PORTD=0x00; //Clears all of PORTD
            delay_us(19450); //Maintains the clear status for the remaining of the 20ms

I know this is not the best way to do it but I’m kind of short in time and this is a very straight forward way of doing it, and if it worked fine once, what could have happened that it’s not working anymore? :confused:

9 out of 10 times this type of issue is due to a power supply issue. You need to check the voltage being supplied to the servos when they are moving (not the non moving voltage).

It may also be that the IO pins are now configured as input pins. IE you probably need to set the DDRD register.

Somthing like: DDRD=0xff;

Kurt

Post an image of your wiring so we can help you better…