Servo won't stop turning...

Hi everyone.
I got a little problem with a servo. It's a common one, the GWS S03N.
I've connected it to the arduino as this:
-brown -> GND
-red-> +5
-orange -> pin n°9

And then, no way to use it as a normal servo. I mean, when I write a value, it turns CW or CCW, always at the same speed, and stops only if I use servo.detach().
Someone knows how to use it with angles, as with any servo?

Here's the piece of code used for tests:

#include <Servo.h>

Servo myservo; // create servo object to control a servo

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

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

void loop()
{

}

Doesn't it hit the mechanical end-stops?

@AWOL > there's no mechanical end stop in this one I think, I can make it turn forever.

@Richard > already done. With 180 value, it does ~2 turns CCW, then ~turns CW and so on. I tried to change this value to 90: it goes for 1 turn CW, stops for a few ms, goes for 1 turn CW again and so on.

I actually got a problem a bit similar to this, except they are not full rotation servo's.

When the voltage drops a bit, they go crazy and moves in one direction (same direction every time), only way to make them stop is to totally disconnect them, and then try again. Adding a better power supply fixed that problem. How do you power yours, is it the 5V on board pin, or a 5V external power supply?

I tried this one too, servo acts the same way. About the arduino I'm using, it's Duemilanove, yes. It's powered through USB only, and the servo is connected as mentionned in #1 post, directly to the board. And my clue that the servo is good is that I have another one, exactly the same. Same results.
I'm going to try servo.read...And BTW: thanks for your answers :wink:

It's powered through USB only, and the servo is connected as mentionned in #1 post, directly to the board.

I think that is your problem. Try an external power supply.

Signal to arduino pin 9
Servo gnd to arduino gnd and battery/power supply
Servo positive to battery/power supply

And about the power supplied: this servo's designed to work with 4.8V.

Try an old nokia charger, they are 4.5V, or something else around the voltage you need.

@bld: tried supplying it the way you proposed: now it turns always CW...

The measured voltage using my original setup is 4.78V...could'nt be better!

It should work the same way as before. Only difference is that you got the "high" current away from the arduino

Yep, but it's not the case :frowning:

What if you try the sweep example? Does it then change direction?

Yep:
With 180 value, it does ~2 turns CCW, then ~turns CW and so on. I tried to change this value to 90: it goes for 1 turn CW, stops for a few ms, goes for 1 turn CW again and so on.

Am I missing something? When you say

@AWOL > there's no mechanical end stop in this one I think, I can make it turn forever.

doesn't that mean it's a continuous rotation servo (presumably with the feedback pot replaced by a fixed resistance) and so it's supposed to rotate continuously?

Andrew

You can find it here, but i'm not shure this page will help. it's the GWS S03N:
http://www.newpower-modelisme.fr/modelisme-gws-25-114-23.html?PHPSESSID=fe48a77

Did you buy it from there unmodified?

Andrew

No, it comes from here: http://www.smallrobot.com/
I won it ten years ago at a programming contest. Servos were controlling its wheels.

Well there you go. It's doing what it's supposed to do - going round and round as if it's driving wheels. Once a servo is modified to drive wheels continuously it's no longer usable as a "normal" servo that you can set to a particular angle (not unless you un-modify it anyway).

Andrew

The measured voltage using my original setup is 4.78V...could'nt be better!

The arduino board generally (and USB computer ports) cannot supply enough current to operate a servo very well. learn the difference and relationship between voltage and current. You need an external power supply of ~1a for a servo to work well. That being said, it sounds like you have a "continous rotation servo". google that to understand how they work. Below is some simple test code You can use with the serial monitor to test your servo.

//zoomkat 7-30-10 serial servo test
//type servo position 0 to 180 in serial monitor
//for writeMicroseconds, use a value like 1500

#include <WString.h> //provides easy string handling
String readString = String(100);
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
      Serial.begin(9600);
        myservo.attach(9);
        }

void loop() {

        while (Serial.available()) {
        delay(10);  
          if (Serial.available() >0) {
        char c = Serial.read();  //gets one byte from serial buffer
        readString.append(c); } //makes the string readString
        }
        
      if (readString.length() >0) {
      Serial.println(readString);
      int n;
      n = atoi(readString); //convert string to number
      myservo.writeMicroseconds(n);
      //myservo.write(n);
      readString="";
      } 
   }

When you say "modified", what are you talking about?