When plugging some servos on the arduino, they shake a bit. I saw on many threads that it may come from giving few current but I use a stabilized power supply directly plugged on the motors. The reason may also be that I am exceeding servos mechanical limits, it is not what happends here because arduino sends something like 1750 us pulses. I also saw that there are some tricks about the arduino's clock but I can't remember where, does someone has an idea ?
My code to test this issue calls only one time "my_servo.write(...);" in the setup() function.
Since you use a seperate supply, have you made a good common ground connection? What servo model? Cheap servos can shake occasionaly. More info can be useful.
The servos and the arduino have a comon ground. The motors are HS-785HB : http://www.servocity.com/html/hs-785hb_3_5_rotations.html.
Does it from the 3.5 rotations ?
I also saw that there are some tricks about the arduino's clock but I can't remember where, does someone has an idea ?
You can disable interrupts on timer0 (thus losing millis(), micros() and delay() functionality) by going:
TIMSK0 = 0x00 ;
Since timer0 interrupts have a higher priority than timer1 interrupts (used by the Servo library),
this will reduce/eliminate occasional jitter on the Servo library outputs.
Oh, thank you, it is a bit drastic but I think it is possible to not use these functions. I'm on another issue for now but I will give it a try.
You really need to provide a much more narrowly focused description of the problem.
Is it possible that the servos get power before they get a signal from the Arduino?
When plugging some servos on the arduino, they shake a bit.
Assuming you are physically plugging in the servo wiring, any electrical noise generated on the servo wiring when connecting or disconnecting the wiring can cause erratic servo movement.
@Robin2 : yes there are powered on before the arduino send them a signal but the problem still exists after.
@zoomkat : my post was a bit confusing, I plug the servos one time and they shake each time I try the project.
Yesterday, I saw with another project that sending too much debugging text to the computer made the same thing (the servo is making squeaky noise). Removing all the function taking time solved the problem. I will try to remove unnecessary code and maybe disable the first timer to see what happend.
I would try starting the Arduino before powering the servo and see if that solves the problem. If it does I would add a circuit (a relay?) so that the Arduino only switches power to the servos after it has started.
Thank you. Powering the Arduino before the motors didn't change anything but removing all time eating functions made the motors shaking less frequently and consequently. The erratic moves are not visible, I can just hear them. I consider the problem as solved.
Interesting. It seems as if some of the other code is preventing the Arduino from sending the proper signal to the servos. I must experiment with this when I get back to my servo project.
I wonder if the problem has anything to do with the 3.5 revolutions of the sail winch servos. Presumably they interpret the usual servo signal pulse (1ms to 2ms) as the extremes of 1260 degrees of motion compared with a "normal" servo that is only concerned with about 180 derees of motion. The sail servo would be much more sensitive to small variations in the pulse width.
I built a few model sailboats some years ago but at the time I couldn't afford a sail winch servo. I wasn't doing anything competitive.