Go Down

Topic: Servo twitch on startup (Read 2 times) previous topic - next topic


I'm making a remote start for my generator and I have a servo to operate the choke.  When I power my system, both the Arduino and the servo get power at the same time.  My servo gives a quick little twitch and rotates about 30 degrees.  This isn't desirable.  Everything runs off the 12V battery and the servo gets its power from a 5V BEC.  The servo is too big to run off the Arduino 5V supply.

I played around a little and I can get rid of the twitch by delaying the power to the servo.  My current solution is to manually connect the BEC after the Arduino is alive and sending a control signal to the servo.  This works, but obviously isn't a good long term solution.

Anyone else experienced this?  Any good solutions?

My current thought is to use a MOSFET to control the BEC.  I would just turn on the BEC around 200 milliseconds after the Arduino control signal is sent.  Is there some product out there that outputs 5V and can be easily turned on/off through a built in Arduino input (combined BEC and MOSFET/relay)?  I'm trying to reduce assembly time as I have to build a bunch of these.


Have you tried to write the servo position before the attach?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.


The most common thing with servos is that they twitch when power is applied. Some are
much worse than others. The GWS servos I have are especially bad.

That's if you aren't even sending pulses to the servo. Then, you have the problem that the
servo will almost never be in the exact position corresponding to the first pulse it gets, and
it will go to the commanded position at maximum speed. So, 2 uncontrollable movements,
(a) one at power up, and (b) the other with the first command pulse.

For (a), try different servos. For (b), you might use some sort of external position feedback,
such as another pot, or alternately, take advantage of the fact that servos have poor torque
when the pulses aren't coming in at a full 50-Hz rate. IOW, send the first few pulses at a slow
update rate so the servo takes a while to get over to its commanded position.


Any good solutions?

Posting your code might help.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)


Jan 27, 2013, 02:43 am Last Edit: Jan 27, 2013, 05:05 pm by ticklechicken Reason: 1
Thanks for the suggestions.  I had to put this away for a while, but I'm back for the weekend.

The problem is in the setup, not in the loop.  The twitch is at the myservo.attatch() and myservo.write() commands.  As AWOL suggested, I tried swapping those commands and also adding a delay(1000) in between the commands.  None of these ideas worked.  What's shown below is the last code I tried.

Code: [Select]
#include <Servo.h>
Servo myservo;

int servo = 9;     // pin output to control the servo
int start = 50;    // start position of servo
int finish = 130;  // finish position of servo

void setup() {  
 myservo.write(start);   // move servo to start position
 myservo.attach(servo);  // attaches the servo to pin 9
 *** non-servo related code removed ***

void loop() {
 *** all this code works fine ***

oric_dan - (a) I've tried 3 servos, and they all do this.  I'm buying cheap servos, so maybe that's the problem.  (b) In my system, the servo will always end in the start position for the next operation.  I don't have to worry about this part of the initial servo jump.

EDIT - corrected comments in code to pin 9

Go Up