Go Down

Topic: Servo troubleshooting help/general questions..(ServoTimer2 lib) (Read 1 time) previous topic - next topic


Been playing with some servo's lately.. and noticed odd behavior..    searched around and read a few articles..

figured I'd post here as well..  :)

* how to solve jitter/twitching? I see it sometimes twitch when its in its end position?

* (more important) how do you compensate for the initial position the servos move to when powered? (before you can send any type of servo.write() command?)

ie: if you have two servos two to lift/move a platform together..  when you power they both individually move to their random/default positions before the code is attached/write a position to them?

* (maybe specific to library or other user fault/error) ServoTimer2 uses pulse instead of angle...

Im using this instead to help understand/use the library itself:

#define degreesToUS( _degrees) (_degrees * 6 + 900) // macro to convert degrees to microseconds

as in:

myservo.attach(9); // attaches the servo on pin 9 to the servo object myservo1.attach(3); // attaches the servo on pin 3 to the servo object

myservo1.write(degreesToUS(pos - 10));

it also seems I need to 'off-set' one of these servo's to the get both servos to the same angle/position..

ie: if I write


to both servo & servo1.. they do NOT match/end at the same place. (maybe just mis-aligned arm placement?)

......and while I have tried ranges from 10-150.....  I only seem to have about 45 degrees of movement? before I here clicking (like Im at the end of the gear/range (like if I use 170.. I need to adjust down a bit)

maybes its the ServoTimer2 and the degreetoUS() conversion?  (figured I'd be able to use (roughly) 0-180 degrees..while trimming for not full 180 range/movemet.. but 45?)

actual values passed:

int pos = 0; // variable to store the servo positions
int pos1 = 150; // variable to store the servo positions

this 'looks' to give about 45 degrees of movement on cheapie hobby servos..



HI, now i working with servotimer2 but unfortunately I have compiling errors. After reading a lot of post and trying things I think that the copy of the library I have It,s not working well.
Can you pass me ServoTimer2.cpp and ServoTimer2.h ?

Thank you very much, and sorry for my English.


I found it by googling.. several links here and at Adafruit forums..

if you still cant find it.. I'll upload it when I get a chance.

still like some discussion on the above topics though?..

how to overcome them?


Just a couple of comments. If you try to drive the servos past their mechanical stops by
sending too large or too small a pulsewidth, they'll grind and complain. Every servo is
different in how far it will move out beyond +/-45 deg.

Secondly, it's best to use a separate power source for the servos than what's powering
the Arduino board, and to also put some additional filtering on the servo power buss, at
the point where the battery/supply connects to the buss. Eg, 220uF and 100nF caps.

Thirdly, whenever you get a new servo, you need to send a 1500 usec pulse to center it,
then check that the servo horn is positioned to the proper central position, and remove
and re-position if necessary.

Go Up