Go Down

Topic: Servo wont stop turning. (Read 479 times) previous topic - next topic

visal

Before anyone goes up in arms, I have read this thread:
http://forum.arduino.cc/index.php?PHPSESSID=j3f4jgjuofibqaduectu7kpas5&topic=19294.msg141195#msg141195
I have a similar problem, except, my servo is a gws s125 continous rotation servo without any modification. It is a sail winch servo.
Here is my code:
Code: [Select]

#include <Servo.h>
Servo myservo;  // create servo object to control a servo
                                // a maximum of eight servo objects can be created
int pos = 850;    // variable to store the servo position

void setup()
{
  myservo.attach(24);  // attaches the servo on pin 9 to the servo object
  Serial.begin(9600);
}

void loop()
{   
  myservo.writeMicroseconds (850);
  Serial.println("@850");
  delay (3000);
  myservo.writeMicroseconds (1600);
  Serial.println("@1600");
  delay(5000);
}


So when I run this code, It turns in one direction (more than 360 degrees) for 3000 micros and doesnt stop anywhere. Then turns in the other direction for 5 seconds and stops only when it has to execute the writeMicroseconds(850) command.
If i change the delay to 30000, it will continue turning for 30 seconds until I detach.
This is the link to the product if anyone would like to see the specs.
I am also running it on an external power supply of 6V (close to 5.8 after using the batteries). Yes, the grounds are connected.
Also if it helps, 850 is close to 0deg and 2150 is close to 360 degrees (know this from past experience).
I am lost, I have been banging my head on this all day and it doesnt make sense. I scaled from a complex code structure to the simple one I posted and it still doesnt work.
Thanks for the help people.

Cheers,
v

solderspot

In the code you are attaching to pin 24 and not pin 9 as the comment suggests. Probably just a typo but just in case....

Some one else had an experience where the pot got disconnected from the gearing. Do you have some other servo controller you can test it with, just to make sure it's not the servo?

Here is a discussion about this servo that someone else was having problems with: http://www.rcgroups.com/forums/showthread.php?t=1038420#post12088381

Otherwise the code looks fine. What board are you running on?
solderspot
journal: http://solderspot.wordpress.com
github: https://github.com/solderspot

MAS3

Hi.

What are you expecting from a continuous rotating servo ?
It has no mechanical stop, nor a center position.
You are sending a command to get the servo rotating one direction, then a command to start rotating the other direction.

Did you do some investigation about how a servo works, how to send it commands ?

Code: [Select]
  myservo.writeMicroseconds (850); makes it rotate.
Code: [Select]
  myservo.writeMicroseconds (1600); makes it rotate in the other direction.

What would happen if you send it some command that is in the center of these 2 values ?
The number of that is 1250.
So let's try that.
Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

visal

@solderspot- I was using the example as a code base. the wiring is connected to pin 24. I am running it on a due.
@MAS3- It just turns around and starts rotating in the other direction for the amount of delay specified.
Earlier when I used to use this. If I wrote a command such as myservo.writeMicroseconds (1250), it would go and stop at the corresponding location. 850 and 2150 were roughly the same location (0 and 360 degrees).

-v

zoomkat

The below sail winch servo is not the one you have, but it may operate in a similar manor. Note that it can operate as both a normal servo and a continuous rotation servo depending on the us commands sent. Bottom is some servo test code that might help sort out how your servo operates.

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


Code: [Select]

// zoomkat 12-25-13 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// Send an a to attach servo or d to detach servo
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h>
String readString; //String captured from serial port
Servo myservo;  // create servo object to control a servo
int n; //value to write to servo

void setup() {
  Serial.begin(9600);
  myservo.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7, 500, 2500);  //the pin for the servo control, and range if desired
  Serial.println("servo all-in-one test code 12-25-13"); // so I can keep track of what is loaded
  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) {
    Serial.println(readString);  //so you can see the captured string

      // attach or detach servo if desired
    if (readString == "d") {
      myservo.detach(); //detach servo
      Serial.println("servo detached");
      goto bailout; //jump over writing to servo
    }
    if (readString == "a") {
      myservo.attach(7); //reattach servo to pin 7
      Serial.println("servo attached");
      goto bailout;
    }   

    n = readString.toInt();  //convert readString into a number

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

bailout: //reenter code loop
    Serial.print("Last servo command position: ");   
    Serial.println(myservo.read());
    Serial.println();
    readString=""; //empty for next input
  }
}

Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

visal

Thank you for the testing code, zoomkat.
I tried it out and under no instance does the servo actually stop anywhere.
I am able to control the speed of the servo by entering the values within the range of 0-180 with 88 resulting in no motion.
I am able to write microseconds as well which (depending on the value) changes direction. But the servo never stops.
Could this be a feedback issue? This is a fairly new servo. And it has not been over worked at all.

Warm Regards,
v

MarkT

This particular servo is unreliable:
http://www.rcgroups.com/forums/showthread.php?s=774bd18ae37336b6de53197c7d84ccd3&t=1038420#post12088381

I note Pololu discontinued it, no doubt because it doesn't work...  Its supposed to do 360
only, not continuous rotation.
[ I won't respond to messages, use the forum please ]

Go Up