Continuous Rotation Servo - Servo.Write() value to stop servo?

Hi everyone,

I'm currently building my first robot based on the Arduino Uno R3 microcontroller.

The first program I created is to test the servos by making the robot move forward, backwards, left, right, stop, etc...

The program listing told me to use a Write() value of 90 in order to stop both of the servos, but they still moved a bit. I experimented a bit and found that a value of 94 then worked.

Can someone help me understand why the value of 90 didn't work?

Thanks,
Ken

Okay - a standard servo has a potentiometer tied to the output. This is the feedback that the servo uses to position itself based on the pulse lrnght it recieves on the signal wire. On your continuous rotation servo that potentiometer has probably been replaced with a couple resistors. The value of that voltage divider is off a bit. so - 94 = stop. (maybe anything from 92-96) you need to adjust your code so your servo commands have a +4 tacked onto them.

I worked briefly with some Basic Stamp based robots. They had a routing that used a button to tell it to add 1 to the servo position. You ran it and stepped through the number and noted where the servo stopped going both directions. then you picked a number in the middle and that was the "Zero Speed" number.

Thanks so much for the detailed explanation!

I was just going to move along after I "fixed" it, but thought it might be good to understand why each servo may have it's own unique "stop" value.

If your servos start to drift, using writeMicroseconds might make it easier to keep the servo centered in the stopped position.

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