Go Down

Topic: Servo goes to 180 as soon as power is applied (Read 1 time) previous topic - next topic

Farris

The topic pretty much says it. I'm trying to control a Futaba S3003 with an Arduino Uno. I have the servo mounted to pin 8 in the code and plug the board in with a wire going from 8 to the white signal wire, the red line going to 5v, and the black line going to ground. However, no matter what position I put in the code, even when I just use the servo sweep example, the servo immediately turns clockwise to its max limit and stops. It also does this as soon as power is applied without a signal cable.

What step am I missing?

Are you using the Servo Library and not PWM? Or, (less likely) if the servo does expect PWM, are you giving it PWM?

Farris

I'm VERY new to this, so please forgive me if I give you the wrong feedback.

I think I'm using the servo library because I'm using the include <servo.h>

Farris

Double checked and there is no change when using pin 9.

zoomkat

Generally people post their code when they have potential code problems. Servos will travel to the ends of their travel when they get out of bound or malformed pulses.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Farris

OK. I'm just trying to debug it with the standard sweep... but here is what I'm using since you asked.

Code: [Select]
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}

Farris

Just tried it with a different servo and it seems to work fine. Put the first one back in and it goes back to 180 and stops. Maybe the first servo is just bad and needs to be replaced?

Farris

I don't know anyone around me that's into that stuff. I would go to the local hobby shop, but it shut down a few months ago. Literally the closest place is about 1 hour away. But, like I said, the other servo works. I just need 2 for the project I'm working on. Guess I'll get a replacement.

PaulS

Are both servos the same type? It looked to me like you are expecting the Arduino to power the servo. In general, this is not a good idea, as servos draw more current than the Arduino can provide.

If you have 2 different servos, perhaps one is drawing more current than the Arduino can provide, while the other does not.

If you use a different power source for the servo, and connect the servo power ground and Arduino ground, do you have the same problem?

Farris

Both servos are the exact same manufacturer and model, Futaba S3003. I even bought them from the same shop.

I am powering them, one at a time, through the arduino for testing. I was using a 6v RC battery pack, but it met an unfortunate end when the 2 copper wires that were connecting it to the bread board touched and made it go poof. OK so it wasn't as much of a poof as it was a fire. I am getting a new battery pack this weekend, along with an inline fuse and some better (non hacky) connectors. And it looks like a new servo too.

Thanks for all the help so far folks.

I'm having one slight problem still with my current code where the servo moves about 10* away from the 0 position, which causes it to not be able to move to the 180* position and then keep trying to force itself to go there. I'll post the code when I get home this evening.

Also, the servo seems to be moving a little bit slower than I'd like. I heard that there is a setspeed function. Could someone tell me how that works please?

PaulS

Quote
I heard that there is a setspeed function.

Where did you hear that? Most people want to slow the servo down, because it moves too fast.

The delay() between the steps limits the top speed. Reduce the time, or remove the call altogether to get higher speed. If that is still not fast enough, get a different servo, or gear it up.

Farris

OK. So whatever I get once I hook it up to the 6v battery this weekend is as fast as I can get without modifying it.

The end state for this project will be to have the servos control a mask in an Ironman costume so that the face plate will lift and move back. Basically they'll pull a hinge that will do this. I just want it to be a quick and smooth movement.

PaulS

Servo horns, the little plastic pieces that linkages attach to, generally have several holes. Move the linkage closer to the center to get slower movement/more torque. Move the linkage farther from center to faster movement/lower torque.

The key will be finding a position where the torque is still adequate to move the piece.

Farris

#13
Feb 23, 2011, 06:29 pm Last Edit: Feb 23, 2011, 06:34 pm by Farris Reason: 1
Thanks for the suggestions. I know that it isn't the most optimal solution, but it's one that I have reference for that I have seen work well. If I find that the 2 servos don't move fast enough I may go with something else. Right now, since I need to have everything done by the end of August, I have less time to experiment than I'd like since the suit itself still needs to be finished and then I have to figure out how to construct the arc reactor and control the lights in the hands.

And by control the lights in the hands, I mean I want to add a flash when I do certain movements. Considering hooking up a camera flash next to a 2" LED shield. Just have a switch in the wrist that activates the camera flash when I bend my hand up.

Go Up