Starting servo position code needed

I have a robotic arm set to a button. When I power up the uno, the servos lurch to a position that is not the starting position I wrote in program. After hitting the button, and the servos cycle through their code, they then settle to the desired starting position. How do I stop that? Is there a code? A piece of hardware? Any ideas would be appreciated.

Have you searched the forum? There was a post about that a year or so back... I can't remember who it was.

It had something to do with the sequence of the commands in the sketch.

Sorry I'm so hazy, but I'm pretty sure it answers the same problem you have: you'll just have to search or wait until someone else responds.

When you execute the attach, the servo moves to its commanded position. If you haven't already done a write, that position defaults to 90.

Writing the position you want before the attach may not be enough though. Unless you left the servos in a known position when you power down and write those position before you attach on the next power up, you will still see a lurch. Some fancier digital servos have a mechanism to give feedback on their positions; regular hobby servos don't.

Edit: Grammar

I found with one of my servos that putting a 4k7 resistor across the signal and ground connections completely stops it moving until the Arduino takes control. Of course that doesn't deal with the situation where the servo was not stopped at the initialize position.

You could, perhaps have a piece of code that runs from setup() which moves the servos to their initial positions slowly. And/or you could have a formal "shut-down" procedure that sends the servos to their initial positions before switching off the power.

...R

I like the idea of an orderly shutdown. I'm building the uArm with 3x servos, and I guess it could wrench itself to bits on power-up if it was turned off with the servos a long way from home. I'll give that some thought.

JimboZA: Have you searched the forum? There was a post about that a year or so back... I can't remember who it was.

Jimbo, I did search, but I wasn't sure how to word it, hence my ambiguous title, when you look up servo position, you get info dumped on your from all angles.

wildbill: When you execute the attach, the servo moves to its commanded position. If you haven't already done a write, that position defaults to 90.

WildBill, I do havethem 'attached', it is only when I first power up the walwarts that the servos lurch to their position, after the initialization, the system works perfectly.

Robin2: I found with one of my servos that putting a 4k7 resistor across the signal and ground connections completely stops it moving until the Arduino takes control.

Robin, I have a 25v 2500uf cap on it now, and it seems to take a lot of jitter. Would a 4K7 be that much different? and in what way?

Time to post your code I think.

@JimboZA, the orderly shutdown is fine as long as the code doesn't crash and nobody pulls the plug. I think an orderly start-up is probably more important. Could you manually move the arms to the start settings without causing damage (before the device is powered up).

@Bstanko6 a resistor is completely different from a capacitor. Try both. I'm not good at analogue electronics but I would worry that putting a capacitor on a signal line would degrade the signal. Or have you the capacitor connected between +ve and -ve? Note that I have the resistor between signal and -ve.

...R

Robin, I assume then I need a resistor for each servo? correct?

Bstanko6: Robin, I assume then I need a resistor for each servo? correct?

Yes

...R