C servo programming

Status
Not open for further replies.

Makaram

Member
Hey guys,
Made a custom delay function so that it could take variables since __delay_us(); doesnt


function is void delay_us(int a)
{
for(int i = 0; i < a; i++)
{__delay_us(1);}


}



simple as they come.
Yet when I put 1500 (center the servo) it freaks out where using the inbuild delay function works.
In fact the delay time (a) to center with this function is 55?!?!!?
what is going on here. i realise that the function may be a little laggy but that much/?
 
Servo position is a function of duty cycle.

May help to start at the other end.
Use a scope or logical analyzer (or PICkit logic tool) to look at the signal sent to the servo.
Then ask yourself why it is generating that signal. Post it here.

Post the code that uses this function
 
Servo position is a function of duty cycle.

Actually, for model servos, it is more a function of pulse width. You can change the duty cycle considerably, but keep a constant pulse width, and position won't change.

John
 
Last edited:
Actually, for model servos, it is more a function of pulse width. You can change the duty cycle considerably, but keep a constant pulse width, and position won't change.

John
I stand corrected. But he still needs to look at the output.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…