servo startup help how can I ensure a gentle "warm up cycle"

So I am new to the board and looking for a source to answer an Arduino servo project's rough power up. The project uses a pair of servos operating together to swing a small door. I have been working with intro level sketches over the last few weeks. I have powered and re-powered my Arduino Uno several times with different codes and each time the unit is powered the two servo motors move to their last position at what appears to be full speed resulting in a rather jerky and jumpy power up.

What can you suggest in the code that would force the servo motors to gently move toward their new code starting position? Like a 'warm up cycle'.

Can you post your code? It sounds like you need a value sent out in the setup section so that before the loop runs you have set a position.
Is there anything that makes the servos change position after they are powered off?

By their nature the servos are burning power to hold them in position so they can jerk when powered on, This can be a code issue or it can be the internal rotary sensors telling the servo what's "home" or it can just be a transient power pulse. And on that note a schematic might help us to point you in the right direction.

FYI. We have tried ramping power to solve a particularly bad jerk issue but that actually made it worse and we got a jitter instead.

If the servo moves BEFORE the servo.attach() and servo.write() statements are reached (assuming both are near the top of setup() ) a 4k7 resistor between the servo signal wire and GND may keep it quiet - it worked for me.

...R

My guess is (but he, you forgot to post code) you do a attach() before you do a write().

Servo communication is only one way, the Arduino can tell the servo where to go but the servo can't tell the Arduino where is it. So when you power up the Arduino it has no idea where the servo is and just assumes a home position. And the moment you attach() the servo the Arduino tells the servo to go to that home position. You can solve this by doing a write() to a position you know is the starting position and only after that attach() it. Then the Arduino will sent that position to the servo instead.

I had the same issue, plus the problem that if all the servos started at the same time it caused such a power drain that the arduino reset.
I could solve the 'all at once' problem by introducing a delay between calls to Servo.attch() but then the initial movement from the unknown starting angle to the centre-position of the servo could still be quite jerky.
I played with using attach-detach cycles with a varying amount of delay between them, like below. Wasn't perfect and could be jerky depending on load, but it did improve things. Behaviour may vary on type of servo. This was tested with lightly loaded SG90s.

I got the idea to do this from a question here and in that thread retroLefty comments on the undesirability of powering the servo with no control signal. I agree, but nonetheless, in this case doing so helped me.

void attach(Servo s,int p, soft){
  if(soft){
      for (int i=0; i<10; i++){
      s.attach(p);
      delay(30);   //avoid 20, behaved oddly
      s.detach(); //I'm hoping I can modulate away the startup jerk
      delay(100);   //making this larger makes the 'soft startup' more obvious
    }
  }
  s.attach(p); //leave it attached
}

it caused such a power drain that the arduino reset.

How are the servos powered ? Not from the Arduino 5V pin I hope.

No, from a battery pack. (I could get around this by using a higher capacity pack but I'd rather not), Nonetheless, having all the servos go off at once suddenly is undesirable, and the main point was to avoid the uncontrolled speed of the motion that happens immediately after attach() if the servos aren't at their central position.

If you don't know the position of the servo arm before the program starts I don't think it is possible to move to a programmed position slowly.

What I have done to avoid all my (12) servos coming on line at the same time is something like this

servo.writeMicroseconds(initialPosition);
servo.attach(servoPin);
delay(100);

but that does not avoid a sudden move to the initialPosition

If you can arrange a shut-down sequence that moves all the servos to the start position before the power is turned off it will make the start-up much smoother.

...R

Yup, and that is just why I tried attaching and detaching the servo rapidly.
The idea was that detaching it would interrupt it when it was on its way at top speed from the initial unknown position to what appeared to be its central position. The servos appear to do this immediately after an attach() even before you try to move them.
Then after a short delay, reattach, detach etc until enough time has passed that they should have reached their central positions and won't move any more.
I made the delay after the detach() in my code above longer to make the soft startup more obvious.

BTW, I agree with your suggestion about 'parking' the servos before poweroff. Great idea.

The servos appear to do this immediately after an attach() even before you try to move them.

Attaching a servo makes it move to its last commanded position if there was one or 90 degrees if the attach() is done before any servo.write()

Note that you can do a servo.write() before the attach() to preset the position that will result from the attach()