Newbie needs help with servo project

Hi!

I'm having a devil of a time trying to start my project.

  • I need to control a servo motor from my Arduino and it needs to sweep a minute hand across a clock, so the servo has to have nearly 360 degrees of motion (but not continuous motion).
  • I've purchased a GWS S125 1T/2BB winch servo which is supposed to accomplish this, however the servo seems to move almost randomly instead of going to position 0, position 90, etc.
  • Thinking maybe the Arduino needed more power/conrol, I purchased a Motor Shield (R3)
  • Thinking maybe it was a power problem, I connected an external power source to my Arduino, but it just constantly resets the Arduino
  • I have no problems when using another servo - but the other servo only has 160 degrees of motion

As you can see, I've got the buying things part down pat - I'm just not very good at making things work. :cold_sweat: Do you have any suggestions? Maybe another servo that I could use if this one requires too much volt/amps?

Thanks so much!
-P

How much voltage is the servo rated for?
Did you try a simple sketch under File-->examples-->servo to see if your servo is working right?

Yep, I did a simple sketch to make the servo go to position(0), then to position(90). It just kinda kept spinning.

The specs for the servo says it requires between 4.8 and 6 volts.

Are you sure that you can position a winch servo like you can with a standard servo?

No, I'm really not sure one way or the other. It does say it's a "digital servo", but I'm too ignorant to know what that means.

I'm completely open to using another servo, however, if anyone has any suggestions for one that would meet my requirements.

From the Pololu page on that servo:

These servos do not have physical end stops, so commanding them past their limits will cause them to rotate continuously until you change the commanded position back to something within its actual range. In our tests, this did not damage the servo, but we strongly recommend against it as there is no guarantee this will not damage the servo’s feedback potentiometer

You might want to do some experiments with numbers around 90 and see what you get.

Some winch servos have interesting control setups. I thought all winch servos were just multiturn standard servos, but the below servo seems to have more to offer. Not sure if the GWS S125 could be similar. Bottom is some servo test code that you might use to test your servo.

http://www.robotshop.com/ca/hitec-hs785hb-servo-motor-2.html

// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

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
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  } 
}

Thanks so much! This solved my problem - I've adapted the code for my need and it works great.

#include <Servo.h>

Servo panServo;

// SERVO VARS
int angle = 0;
const int pulse0Degrees = 1000;   // pulse width for 0 degrees
const int pulse360Degrees = 1940;  // pulse width for 360 degrees
const int pcenter = 1000; // using 1000 for center, or 0 degrees, you may want to use something different

int servoPanPin = 9;     // Control pin for servo motor

void setup() {
  panServo.attach(servoPanPin);  

 // Default center, or close to it
 panServo.writeMicroseconds(pcenter);	// close to center GWS125-IT/2BB/F ?
}

void loop() {
    
    int pulse = getPulse(45);
           
    panServo.writeMicroseconds(pulse);
    delay(5000);    
}

int getPulse(int angle) {
  return map(angle,0,360,pulse0Degrees, pulse360Degrees);
}

zoomkat:
Some winch servos have interesting control setups. I thought all winch servos were just multiturn standard servos, but the below servo seems to have more to offer. Not sure if the GWS S125 could be similar. Bottom is some servo test code that you might use to test your servo.