Help with springrc sm-s4315r servo motor

hi all

i am using a pic18f4520 board. I connected a springrc sm-s4315r continuous servo motor to port A.

i am just trying to control it to spin clockwise or anticlockwise but to no avail…it just doesnt move on its own. However if i give it a slight manual push in the direction corresponding to the pwm i programmed it to (<1.5ms clockwise), it will start to spin perfectly fine. it doesnt budge if i try to push it in the wrong direction.

i have attached my code below using mplab c18 compiler. This is assuming that a high pulse with duration below 1.5ms results in clockwise turn.

#define leftservo PORTAbits.RA0

void main (void)
{

while (1){
leftservo=1;
waitmis(5); //loop delay function, results in clockwise
leftservo=0;
waitmis(125);
}
}

void waitmis (int count) //Gives a delay of 0.15 ms
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<25;j++);
}
}

anyone knows the problem? i have checked and the pin is sending out the pulse as per instructed.

If the comments in your code are correct, then you are sending out a pulse of length 0.75 ms. The typical range of valid servo pulses is 1-2ms. Try sending pulses of different widths, like 1.1 or 1.3 ms.

Also I’m surprised that your PIC program is working: I would have thought that you would need to clear the TRIS bit, and use the LAT bit to set the output value instead of the PORT bit.

Also, this might be a power issue. How are you powering the servo?

–David