SERVO MOTOR won't stop rotating!

We currently have a small robot controlled by Arduino, It has two wheels each controlled by a servo motor (which have been broken so that they rotate 360 degrees). However all of a sudden we have a problem, one of our right left motor when connected will just continuously rotate (despite the code telling it to go slow and reverse etc.) The right motor works fine. We also tried changing the left motor that was continuously rotating and the new motor also only continuously rotates. I have attached one of the codes below which we are using, but the same happens with any codes. (We are using a 6v power supply for the servos and a 9v power supply for the arduino)

#include <Servo.h>

Servo servoLeft; // Define left servo
Servo servoRight; // Define right servo

void setup() {
servoLeft.attach(11); // Set left servo to digital pin 10
servoRight.attach(9); // Set right servo to digital pin 9
}

void loop() { // Loop through motion tests
forward(); // Example: move forward
delay(500); // Wait 2000 milliseconds (2 seconds)
turnLeft();
delay(50);
turnCURVEleft();
delay(500);
turnCURVEright();
delay(30);
turnCURVEleft();
delay(500);
turnLeft();
delay(300);
forward();
delay(200);
reverse();
delay(200);
turnRight();
delay(30);
forward ();
delay (200);
reverse ();
delay (200);
turnRight ();
delay(50);
turnCURVEleft ();
delay (300);
turnLeft();
delay (60);
forward ();
delay (600);
stopRobot();
delay(5000);
}

// Motion routines for forward, reverse, turns, and stop
void forward() {
servoLeft.write(65);
servoRight.write(351);
}

void reverse() {
servoLeft.write(171);
servoRight.write(245);
}

void turnRight() {
servoLeft.write(65);
servoRight.write(81); // HAVE TO WORK OUT IF THESE ARE ACTUAL POINTS
}
void turnLeft() {
servoLeft.write(155);
servoRight.write(351);
}
void turnCURVEleft() {
servoLeft.write(155);
servoRight.write(245);
}
void turnCURVEright () {
servoLeft.write(65);
servoRight.write(81);
}
void stopRobot() {
servoLeft.write(155);
servoRight.write(81);
}

THANK YOU !

sorrelm:
controlled by a servo motor (which have been broken so that they rotate 360 degrees).

What did you do with the potentiometer used in the servo?

Load this program into the Arduino and let us know how the robot behaves.

#include <Servo.h> 

const byte servoLeftPin = 11; 
const byte servoRightPin = 9; 
const int STOPPED = 1500;
 
Servo servoLeft; 
Servo servoRight; 
               
void setup() 
{ 
  servoLeft.attach(servoLeftPin); 
  servoRight.attach(servoRightPin); 
  servoLeft.writeMicroseconds(STOPPED);
  servoRight.writeMicroseconds(STOPPED);
} 
 
void loop() 
{ 
 
  
}

The robot should not be moving when using the code above.

Please read "How to use this forum" and follow instructions in item #7 about attaching code. You used a quote block instead of a code block.

sorrelm:
However all of a sudden we have a problem,

My first assumption would be that something has broken. Perhaps a wire inside the servo has come loose. It sounds like the servo has lost its reference.

...R

Robin2:
My first assumption would be that something has broken. Perhaps a wire inside the servo has come loose. It sounds like the servo has lost its reference.
...R

No, not inside the servo at least, unless the same thing has happened to two servos:-

We also tried changing the left motor that was continuously rotating and the new motor also only continuously rotates.

Maybe the signal wire to that servo has a bad connection or is broken.
Or possibly the left servo signal wire is connected to the wrong pin:-

servoLeft.attach(11);  // Set left servo to digital pin 10

And among other things, this is invalid:-

servoRight.write(351);

Heaps more cases of that in the code, too.
Values sent to the servo using 'write()' must be between 0 and 180.

And this shouldn't be "stop":-

void stopRobot() {
  servoLeft.write(155);
  servoRight.write(81);
}

Both values need to be about 90 for "stop".

Duane's code should help sort out the cause.
(Or writing 90 to both motors with 'Servo.write()'.)

OldSteve:
No, not inside the servo at least, unless the same thing has happened to two servos:

Sorry. I missed that piece.

...R

OldSteve:
No, not inside the servo at least, unless the same thing has happened to two servos:

I think this could be a posability.

sorrelm:
(which have been broken so that they rotate 360 degrees).

The above quote is a strange way to describe converting a servo to continuous rotation.

This is why I asked about the pots.

The above quote is a strange way to describe converting a servo to continuous rotation.

Well, there was a servo before, and then it got screwed with, and now it's a motor, gearbox and not very good speed control.
I'd call that broken.

Groove:
I'd call that broken.

I don't completely disagree but I think CR servos are pretty easy way of adding a small motor with gearbox and a h-bridge to a robot. All controlled with a single I/O pin. I can see why they're popular.

If the servos are powered from a regulated power source, the speed is much more consistent than when powered from batteries which fluctuate in voltage.

Here's my "cheap bot" driving in a figure 8.

I like HobbyKing's HX12K metal gear servos. They're really easy to convert to CR.

Here's a picture of the two "servos" I used with my cheap bot.

You can see I left the pots connected and dangling out the side (with the power and signal wires).

BTW, the little Fitec CR servos don't have good speed control characteristics. Apparently you're better off hacking a cheap HobbyKing servos than purchasing these ready made CR servos.

Not only are some servos easier to convert to CR than others, but there's also a lot of variation in how well the speed of the servo/motor can be controlled.

They're not "CR servos".
They are not servos at all.

Groove:
They're not "CR servos".
They are not servos at all.

Okay, you've convinced me.

For the record, I did put servos in quotes (but only once).

DuaneDegn:
Here's a picture of the two "servos" I used

So what do we call a motor with gearbox and pulse length controlled h-bridge?

"Broken servo"?

I doubt "broken servo" will replace "continuous rotation servo" anytime soon.

@Degn
You're new - and you link back to that other forum a lot.

Basic trouble shooting should identify the problem. If the servos can be swapped between pins and the same servo will not stop rotating while connected to either pin, then the internal pot (if still attached) probably needs to be adjusted such that the motor stops rotating while a 1500 us command is being supplied. If the non stop issue is associated with a particular pin, then the wiring associated with that pin and servo is probably bad. Probably a bad ground connection. Below is some servo test code that might be useful for setting up the servos.

// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a 
// to decrease) and enter to change servo position 
// (two hands required, one for letter entry and one for enter key)
// use strings like 90x or 1500x for new servo position 
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continous rotation servo
//int pos=90;

void setup()
{
  myservo.attach(7, 400, 2600); //servo control pin, and range if desired
  Serial.begin(9600);
  Serial.println("serial servo incremental test code");
  Serial.println("type a character (s to increase or a to decrease)");
  Serial.println("and enter to change servo position");
  Serial.println("use strings like 90x or 1500x for new servo position");
  Serial.println();
}

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) {
    if(readString.indexOf('x') >0) { 
      pos = readString.toInt();
    }

    if(readString =="a"){
      (pos=pos-1); //use larger numbers for larger increments
      if(pos<0) (pos=0); //prevent negative number
    }
    if (readString =="s"){
      (pos=pos+1);
    }

    if(pos >= 400) //determine servo write method
    {
      Serial.println(pos);
      myservo.writeMicroseconds(pos);
    }
    else
    {   
      Serial.println(pos);
      myservo.write(pos); 
    }
  }
  readString=""; //empty for next input
}

zoomkat:
Basic trouble shooting should identify the problem. If the servos can be swapped between pins and the same servo will not stop rotating while connected to either pin, then the internal pot (if still attached) probably needs to be adjusted such that the motor stops rotating while a 1500 us command is being supplied. If the non stop issue is associated with a particular pin, then the wiring associated with that pin and servo is probably bad. Probably a bad ground connection. Below is some servo test code that might be useful for setting up the servos.

Most likely the latter, since two servos exhibited the same behaviour on the left side.
On the right hand side, one (at least) of those servos behaves as it should.

As you still have the original potentiometers connected to the servos is it possible that you moved the "knob" so the pot is no longer in the centre where it should be.

Any time I converted a servo I put in two fixed resistors to supply the reference point.

...R

Hi,
My continues rotation servos, have a pre-set pot inside, with a small hole where you can pop a small screw driver in and adjust it, so that when sending the value 90 which should be stop, you can alter the pot to get the wheels to stop, sometimes they creep a bit, this can also happen as the battery power goes down.

Modded servos, Yes I too used 2 fixed resistors with the pot in the centre.

Mel

Cactusface:
Modded servos, Yes I too used 2 fixed resistors with the pot in the centre.

Just for clarification I completely removed the potentiometers from my Continuous Rotation servos.

...R