sg90 servo deflection

Hi I'm trying to use a servo to control the position of a model windmill (not its sails) on my model railway.

The servo will be imbedded in the baseboard and will rotate the body of the windmill around the vertical axis.

The problem I have is that when switched on the servo immediately deflects by roughly 20 degrees (anti-clockwise viewed from above).

Is there any way to suppress this deflection?

Is this a feature of all servos or just the SG90?

Many thanks for any help

It's It might be (see Robin2 below) a result of where it was when you finished with it compared to the first place you tell it to go.

If you reliably know that it's at X degrees when you shut down then do a servo.write(X) before your servo.attach() then it won't fly off to the default position but go to X, which means if it's already there, it won't move.

(ie, the 20 deflection is not 20 in absolute terms, it just happens to be 20 degrees away from where you left it.)

I have found the same effect with a small HobbyKing servo. But it does not happen with another Hitec servo.

I assume the problem is that there is a short period between the Arduino being powered up and the servo being attached and taken under control. I only noticed this problem yesterday so I have not explored a solution yet. Actually for my use (controlling points or signals) it probably would not really matter. But I can see how the windmill behaviour would look a bit strange.

And to follow from @manor-royal, the problem I detected is not a result of the servo stopping in the "wrong" position because several brief restarts (i.e. without leaving it connected long enough for servo.attach() to happen) will progressively move the arm all the way to the limit of the servos movement.

...R

Hm ok, that's very interesting Robin2.

Maybe my answer is a red herring then, although it behooves OP to try the servo.write before servo.attach idea.

BTW @OP, here's the line in servo.h where it sets the default pulse to 1500ms, ~90 degrees:

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

Robin2:
And to follow from @manor-royal, the problem I detected is not a result of the servo stopping in the "wrong" position because several brief restarts (i.e. without leaving it connected long enough for servo.attach() to happen) will progressively move the arm all the way to the limit of the servos movement.

...R

Thanks robin

This is exactly my problem the servo deflects at each power-up by approx 20 degrees
Even with the arduino not powered-up.

thanks manor_royal

@manor_royal.
I have already included a servo.write before my servo.attach in void setup. The result is always the same – a rapid deflection at power-up of approx 20 degrees.

Am i right in assuming from your answer that your set-up does not experience deflections during power-up? If this is the case may I ask the make and model of your servo? Please.

colubridae:
Am i right in assuming from your answer that your set-up does not experience deflections during power-up? If this is the case may I ask the make and model of your servo? Please.

I won't answer that until I've checked that it never happens, but I've certainly never noticed it before. Or should I say I've never noticed that I noticed, if you know what I mean.

Sorry, I didn't realise your problem was purely power related, I assumed it was a control thing.

So just to clarify: if you literally apply just power to the servo, with no live control wire, it deflects by 20-odd degrees no matter where it last stopped?

If so what happens if it was stopped at the end of travel and can't move another 20?- does it start coming back?

manor_royal:
I won't answer that until I've checked that it never happens, but I've certainly never noticed it before. Or should I say I've never noticed that I noticed, if you know what I mean.

Sorry, I didn't realise your problem was purely power related, I assumed it was a control thing.

So just to clarify: if you literally apply just power to the servo, with no live control wire, it deflects by 20-odd degrees no matter where it last stopped?

If so what happens if it was stopped at the end of travel and can't move another 20?- does it start coming back?

Yes to first question. Simply powering-up produces a consistent 20 degree deflection. I’ve now tried it on a second SG90 and get the same result.

In an answer to your second question, at full deflection the servo seems to try another 20 degree deflection but simply produces what I can only describe as a squeek.

In point of fact the deflection is not a ‘serious’ problem, it’s the speed of the deflection. This would produce a problematic torque on the joint of the sails to the sail-motor housing of the model.

Many thanks in advance

I just found this here:

Without signal, they will constantly wind themselves around with each successive power-up.
Look up how a servo works internally and you will see the reason why.
Hint, it has to do with the internally generated servo position signal to the comparator.

I just checked with a sg90 I have and it has the same strange behaviour. It always moves at power up regardless of last position. If you unplug and plug in again it takes another 20 degree step.

However..

As a test I tried hot plugging the servo into a header that already had a signal and it only twitches but does not take a big jump.

So can you power your servos up with a relay or something after they are getting their signal? Should stop the jump.

alka:
So can you power your servos up with a relay or something after they are getting their signal? Should stop the jump.

Will try that solution. Many thanks.

colubridae:
Will try that solution. Many thanks.

While it should work it is a real PITA.

I suspect a small transistor would be sufficient to control the power to the servo - simpler than a relay.

...R

Robin2:
While it should work it is a real PITA.

I suspect a small transistor would be sufficient to control the power to the servo - simpler than a relay.

...R

Agreed, a transitor would be a better choice than a relay.

I have now tested 5 different types of servo.

As indicated earlier the small HobbyKing servo moves with every power-up while it has no signal. Two other types (but don't know the make) behave the same.

An old and larger Hitec servo and a really tiny HobbyKing servo don't move at all until they get the servo.attach() signal.

Clearly this unwelcome phenomenon is not an intrinsic property of servos as was implied by the piece quoted in Reply #7.

...R

The SG90 is known for that. In most situation you can overcome it by connection a pull up (something like 4k7) between signal and the servo 5V. But I rater get the tiny bit more expensive SG92 which is as stable as a rock :slight_smile:

My errant HK15178 servo was not tamed by either a pull up or a pull down resistor.

...R

I have been chatting online with HobbyKing.

I had not noticed that the tiny HK-5330 is a digital servo and the guy I was chatting with said that the digital servos will not misbehave at startup. He suggested these models

  • hkscm12-5
  • hkscm9-5
  • hkscm9-6
  • turnigytm-tss-10hm-ds

as possible alternatives.

...R

Yep, digital servo's are better at it. That's why I take a SG92 over a SG90. It's his digital brother :slight_smile:

My old Hitec is certainly not digital but it is house-trained :slight_smile:

...R

Thanks for all replies.

For the moment I'm postponing (not abandoning) the vertical axis movement and going with PWM on the windmill sails only.

Will continue my attempts at a later date.

Nice to know there's lots of help available.

thanks again