Servo Midpoint / generell understanding

HI everyone,

I have this HiTec HS-625 Servo http://www.servodatabase.com/servo/hitec/hs-625mg, which has a max angle of 90 hooked to an Arduino Mini Pro. It has its own power supply with shared GND. Now I have a basic understanding question: What happens, when the Arduino is initially turned on? Is the servo by itself trying to get to its midpoint? Because this rather expensive piece is somehwat randomly moving into one direction and then back at first power up. If so, how do I tell the servo, to go to 0 degrees and stay there "until further notice"? I am using the basic servo library, or (for easy of use), the varspeedservo library. I am stating myservo.write (0); in the void setup, but it does not seem to do it. As a comparison I have this cheap china servo, which does not show this behaviour at all. It jiggles a bit at the beginning, but then stays where it is. From what I read it looks like it is much better to drive the servo with write(microseconds) anyway ... still have to look into how this works. Do servos always start from their midpoint anyway? In my case I need the whole 90 degress rotation to accomplish what I´m after, where it is important that the servo does not "think" it is at midpoint and then moving in the oposite direction ...

I hope I made myself clear ... and anyone can share some insight.

Do servos always start from their midpoint anyway? In my case I need the whole 90 degress rotation to accomplish what I´m after, where it is important that the servo does not "think" it is at midpoint and then moving in the oposite direction ...

Servos do not determine on their own where they 'start at' when first powered up, rather they just go to the position the servo library commands them to when you first attach them in your startup function. So you should attach them early in the setup function before any possible delay commands you may be using. The servo library has a default startup position command of 1500 usec control pulse output which is the 50% position for servos, so 45 degrees for your specific servo. The default startup position is in the Servo.h library file and looks like this:

#define DEFAULT_PULSE_WIDTH  1500     // default pulse width when servo is attached

You could edit the file to have it startup at any value within your servo's pulse width range. Or just issue a Servo.write command to your desired servo starting position right after you servo attach command, shouldn't make much difference.

Lefty

Reply #7 on this thread might help....

What happens, when the Arduino is initially turned on? Is the servo by itself trying to get to its midpoint? Because this rather expensive piece is somehwat randomly moving into one direction and then back at first power up. If so, how do I tell the servo, to go to 0 degrees and stay there "until further notice"?

If desired you can set the position for the servo before attaching it like below.

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

Thanks everyone. Seems to work fine issuing the writeMicroseconds(somevalue) right before everything else.
Since I´m rather new to Arduino one follow up question: let´s assume the servo´s start position after “boot” should always be 2000. But the last time I´ve switched everything of, it was set to 1000. So when just writing myservo.writeMicroseconds(2000); in the setup procedure, the servo tries to go to that value ASAP.

But since I´ve attached something to it that cannot take such fast movement … can I tell the servo to move to the start position from wherever it is right now in a somewhat controlled, slow fashion? Before the actuall viod() is started?

let´s assume the servo´s start position after "boot" should always be 2000. But the last time I´ve switched everything of, it was set to 1000.

Then don't do that. Always set the servo to the start position before shtdown.

But since I´ve attached something to it that cannot take such fast movement

Then you really need to make a more robust design.

can I tell the servo to move to the start position from wherever it is right now in a somewhat controlled, slow fashion? Before the actuall viod() is started?

How do you know "wherever it is right now"? Typical hobby servos do not have position feedback.