Does servo always start at 90 degrees? [SOLVED]

I have some strange behaviour in my ruler plotter. The plotter includes three servos and it seems that when I start my program, all three servos turn to 90 degree. Like the myservo.attach(9) would send the 1500 µs to the servo just for handshaking or something. I'd just want a confirmation that this is how the servo lib behaves. Or that it doesn't. If it does, I have to trash the lib and write my own >:( .

The thing is, two of my servos can't be at the same time at 90 degrees, because of the geometry of the attached arms.

Try writing a value with servo.write() immediately before you call servo.attach()

For full details of the behaviour the source code for the servo library is included with the Arduino IDE.

...R

Could you explain what writing the value would do? I mean, I will test that, but what am I supposed to expect? And what value should I write?

void setup(){
  servo.write(startPos);
  servo.attach(servoPin);

If startPos = 10, servo goes to 10 degrees at startup.

Johan_Ha:
Could you explain what writing the value would do? I mean, I will test that, but what am I supposed to expect? And what value should I write?

You would have tried it and found out the answer long before you get this Reply. The Arduino system is great for learning-by-doing.

@edgemoron has explained it.

You are the only person who knows where you want the servo to go and therefore what value to use.

...R

Thanks for the replies. Yes, I could have figured this out. Only I have trouble finding time and space for working on this, so right now my equipment is packed away. And it will be great to get it assembled next time when I know exactly what to do.

The way to set the start position is clever. It could be mentioned in the references. I couldn't find anything. OTOH, what should one do, if one just wants to start at the position, where the servos happened to be when the machine was last time shut?

Johan_Ha:
OTOH, what should one do, if one just wants to start at the position, where the servos happened to be when the machine was last time shut?

That is not so simple.

If you can organize an orderly shut-down you could record the positions to the EEPROM memory and read from that at next startup.

But if someone just pulls the power that won't work. And the EEPROM has a limit to the number of write cycles so it is probably not practical to save the position every time the servo moves.

You can get servos with an extra wire that allows the Arduino to read the value of the position potentiometer. It is probably also possible to modify most servos to add that feature.

...R

Johan_Ha:
what should one do, if one just wants to start at the position, where the servos happened to be when the machine was last time shut?

Maybe this could work for you or anyone later. You can try and always end the run at the position where you start the servos always and want to start the servos always. You know your own positions