I am stumped at the moment ... I am using a Mega2560 and have 18 MG995 servos and use the Servo library. Just for testing I did the typical creating a Servo instance for each servo, in this test case just one instance for one servo. I have the servo on digital pin 23. I of course do the testServo.attach(23). I want the servo to start off at position 0 so, I do a testServo.write(0). The problem is, the servo advances to what amounts to be about the halfway point in its overall arc. No matter what position the servo is in at when first powered on, it goes right back to that position. I have tried different servos on different pins with the same result. Any ideas?
What happens when you run the Sweep example ?
How is the servo powered?
Post your code. The write(0) should be BEFORE the attach() if you want to be sure the servo will start up at position 0. What happens if you write() different values e.g. 45 or 90?
And for 18 x MG995s you will need a serious power supply separate from the supply to the Mega. And good solid wiring not through a breadboard.
Steve
It sweeps forward and back to where it was. When I remove power from the servo after telling it to go to 0 I can manually turn it counter clockwise to what should be the 0 position.
slipstick:
Post your code. The write(0) should be BEFORE the attach() if you want to be sure the servo will start up at position 0. What happens if you write() different values e.g. 45 or 90?And for 18 x MG995s you will need a serious power supply separate from the supply to the Mega. And good solid wiring not through a breadboard.
Steve
Why write(0) before? Seems odd, without attaching it to the servo pin, it wouldnt be talking to the servo.
As far as powering the servos, for testing I am just using 1 servo, so the 5v/GND pins are plenty. Once fully assembled I will be using a lithium-ion 10000mAh USB battery pack.
Writing 0 first gives that value to the Servo library so it doesn't need to use its default of 90.
Also the stall/startup current for a single MG995 is around 1.5A. The 5V pin can't safely supply anywhere near that current.
But you carry on. You're always entitled to ignore advice.
Steve
Once fully assembled I will be using a lithium-ion 10000mAh USB battery pack.
Is the capacity of the pack important?
How many of the servos will be moving at once?
(I think I know the answer to that last question, but I'm interested in your reply)
Why write(0) before? Seems odd, without attaching it to the servo pin, it wouldnt be talking to the servo.
You have the source of the Servo library; why not take a look?
"The problem is, the servo advances to what amounts to be about the halfway point in its overall arc. No matter what position the servo is in at when first powered on, it goes right back to that position. "
Do you have your code to show? Note that pins may be undetermined states when a board boots up, which may cause issues. There are a number of things you might do to troubleshoot your issue, but without knowing what you are currently doing, no sense fumbling around n the dark.
Hi,
Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Thanks.. Tom..