Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top