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
}
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.
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.
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.
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.
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.
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.