How do i tell my servo to stop?

Hello, i'm working with continuous rotation servo's and i'm having trouble finding the code to make then stop turning. Here's what I have so far: (This makes the servo's start turning)

{myservo.write(180);

To make them stop I tried this:

{myservo.write(LOW);

but that only makes them continue turning, can someone leave some code that would help? thanks! :slight_smile:

Somewhere around 90.
LOW == 0

LOW is the same as zero. Look at the help page for Servo.write:

On a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement).

1 Like

Your post title is incorrect. Once modded for continuous rotation, you no longer have a servo. So, your question is how do I make my variable speed motor stop.

The answer is pretty simple. Write the correct position, and it will stop. Now, the hard part is determining the correct position.

Continuous rotation "servo"s are generally controlled using the Servo::writeMicroseconds() method, rather than the Servo::write() method. There is a range of values that makes the servo move one way, and a range of values that makes it move the other way. The value in the middle makes it stop - typically around 1500, with larger values up to around 2200 making it turn faster one way, and smaller values, down to about 800 making it turn faster the other way. The farther from the midpoint, the faster it goes.

Assuming you have your servo wired correctly, you can use the below test code to find the the ~stop value for your servo (usually something near 90 deg or 1500us). There is also a servo "detatch" command that might be of interest later.

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

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 
    int n = readString.toInt();  //convert readString into a number

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

    readString=""; //empty for next input
  } 
}

There is also a servo "detatch" command

Though for reasons of pedantry, the library spells it "detach".

AWOL:

There is also a servo "detatch" command

Though for reasons of pedantry, the library spells it "detach".

And detach is not a proper way to 'stop' a servo, because it stops all pulses to the servo and the servo loses all holding torque and can therefore be turned by the load attached to it's output arm or wheel, having only the friction of it's output gearing to hold the load where last commanded.

As stated, the proper way to stop a servo is to issue a command to the desired 'stop position' and do not issue any further new servo write commands. The servo library will continuously 'refresh' the same last sent position command to the servo, which can then offer full correcting torque if the mechanical load tries to turn the output wheel or control arm in either direction.

R/C servos were designed for the Radio control hobby and their systems never stopped sending PPM position command pulses to the servos unless and until power was turned off.

R/C servos were designed for the Radio control hobby and they never stopped sending position command pules to servos unless and until power was turned off

Or transmitter (the source of the pulses) range exceeded.

AWOL:

R/C servos were designed for the Radio control hobby and they never stopped sending position command pules to servos unless and until power was turned off

Or transmitter (the source of the pulses) range exceeded.

Called entering the drama zone. :wink:

Called entering the drama zone

BT, DT - spent two hours searching a cabbage field for a lost glider.

The servo library will continuously 'refresh' the same last sent position command to the servo

True

which can then offer full correcting torque if the mechanical load tries to turn the output wheel or control arm in either direction.

Not true for a continous rotation servo. There is no internal feed back in the continous rotation servo nor load detection mechanism. When a continous rotation is in a true neutral stopped condition, the servo shaft turns just the same as when it is not electrically connected to anything. In both cases the internal h-bridge in the servo is not getting any signal to operate the motor. The servo detach function is useful in some DIY continous rotation servos that suffer from position creep, probably due to using the origional pot for the internal servo voltage divider.

Not true for a continous rotation servo.

True. But then again I don't considered modified continuous rotation servos to even be servos. I have riled to even have them called servos, as that only perpetuates the confusion to newcomers and therefore often purchased in error thinking they are getting a servo with extra features, only later to find out they have come to posses a servo that has had a frontal lobotomy and has lost all contact with the wonderful world of servos and feedback control theory.

I feel about continuous rotation servos like PaulS feels about the arduino's delay() function, only more so.

Lefty

But then again I don't considered modified continuous rotation servos to even be servos

I recently ordered this continuous rotation servo ->rhydoLABZ

does it mean im doomed?

But then again I don't considered modified continuous rotation servos to even be servos.

Probably why the OP said "Hello, i'm working with continuous rotation servo's" instead of saying "Hello, i'm working with servo's". In the robotics arena most understand the difference between the two.

I think then i can add a potentiometer to make it a standard servo

NI$HANT:

But then again I don't considered modified continuous rotation servos to even be servos

I recently ordered this continuous rotation servo ->rhydoLABZ

does it mean im doomed?

Not necessarily. As long as you were in need of only a bidirectional, variable speed, geared motor drive, then you got what you were looking for. If you had any other ideas about what such a circumcised servo is, then maybe you are.

Lefty

i think i need angle determination that can't be known by my ATmega unless/until there is a pot in the servo WHICH is not in this one , but Hey :smiley: the positive point here is i got too deep into concept of servo motor control because of this and READ PID systems to make a digital servo and got a whole new knowledge of a promising field.