Modified Servo only rotating in one direction (TowerPro SG-5010)

Hi everyone,

I'm sorry for posting yet another question on the forums about this (I searched and it seems like it has pretty much been beaten to death), but I haven't been able to find the answer based on the other threads I have read....that or I am too stupid to read between the lines!

I've modified a TowerPro SG-5010 to rotate continuously (with the pot still in place as opposed to the resistor route). The rotation works fine when I send a signal to the motor, but it both remains at a steady speed (which is slower than what it is capable of) and, more importantly, rotating in the same direction no matter what I write to it.

During modification I wrote "0" to the motor and rotated the internal potentiometer until the motor stopped moving. Now that part is ok....when I write "0" to it now, nothing happens. Writing any other number causes the motor to rotate slowly counter clockwise, regardless of the number.

Does anyone have any ideas on what might be causing this? I would love to be able to rotate at full speed in either direction if possible.

The code I am using is below (hopefully it's just a code thing!). Any suggestions would be greatly appreciated.

#include <Servo.h>

Servo myservo;
int position = 90;
int counter = 0;

void setup()
{
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 Serial.begin(9600);
 Serial.println("servo attached");
 myservo.write(position);
 delay(1000);
}


void loop()
{
 if(counter%2==0){
   position = 0;
 }else{
  position = 170; 
 }
 counter++;
 Serial.print("changing position to ");
 Serial.println (position);
 myservo.write(position);
 delay(1000);
}

During modification I wrote "0" to the motor and rotated the internal potentiometer until the motor stopped moving.

I believe you have set this up incorrectly. As a 0 degree command outputs a minimum pulse width. By modifying the ex-servo is has become a bidirectional variable speed geared motor (no longer a servo), your motor stopped position should be at the 1500 usec pulse width position, or 90 degrees if using the servo library. So output a 90 degree command (or a 1500 usec command) and readjust your pot for motor stopped condition.

Lefty

rats...was afraid of that! Anyhow, thank a bunch for the suggestion. I will get on it now and report back!

thanks retrolefty, that did it!

I noticed as well, the higher I set the write angle above 90 (up to 180), the fast the motor went (ie, setting it to 91 is extremely slow and 180 seems full speed). Is this the case? Is there a way to check if the speed is maxed out?

Generally speaking with these types of servos, +-100us from the neutral stopped point the servo will be at its max speed. Below is a continous rotation servo that is probably similar to yours.

http://www.lynxmotion.net/viewtopic.php?f=31&t=6388

Oh,

I did also modify my servo (also tower sg5010) so that it could do full turn. However, I'm having trouble setting the 90degree position. Im using a modified version of your system (Code is included below).

When I try to stop the motor from spinning by turning the potentiometer to the middle it stops, but only for a while. After some time it starts spinning again. Any ideas why?

BW,
Sharapolas

#include <Servo.h>

Servo myservo;
int position = 90;
int counter = 0;
int inByte = 90;
void setup()
{
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 Serial.begin(9600);
 Serial.println("Servo attached");
}

void loop() {
  myservo.write(position);
  delay(10000); 
  //myservo.write(90);
  //delay(1000);
  
  /*if(Serial.available()>0){
   inByte=Serial.read()-'0';
   Serial.println(inByte);
   Serial.println("\n");
   myservo.write(inByte);
 }*/
 
}

When I try to stop the motor from spinning by turning the potentiometer to the middle it stops, but only for a while. After some time it starts spinning again. Any ideas why?

The pots in servos are sensitive to any movement, touch, or possibly temperature changes. You also need to use writeMicroseconds to have the best control of the servo. Use the below code to send 1500us to the servo, then carefully adjust the pot shaft until it is centered in the motor stopped position. Then to stabalize the pot shaft to limit any shaft movement, you could use a tiny drop of some easy to remove glue like rubber poster cement, a tiny drop of hot glue, or similar products to secure the shaft to the pot body.

// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0019 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(2000); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-21"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(1);  
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    } 
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n;
    char carray[6]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray); 
    myservo.writeMicroseconds(n); // for microseconds
    //myservo.write(n); //for degees 0-180
    readString="";
  } 
}