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.
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.
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.
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.
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
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