Servo control without servo control

I'm a little confued on how to generate pulses. I want to be able to control the pulses sent to a servo, but I don't want to use the servo.h tool. I've found that sending a "myservo.write(0);" or "myservo.write(180) doesn't neccessarily command the servo to hit it's stop. I already stripped one because the "0" pulse output was further than the physical stop.

In other words, I want to set up a board with a pot that will change the pulses manually, display those pulses, and send the pulses to the servo so I can see where the pulses put the servo arm. I have a servo tester that shows when the servo hits its stop (measures amps) and then I can mark the pulses for both stops.

Thanks!

You could try "myservo.writeMicroseconds()".

You could also put a small resistor (1 ohm?) between the servo and Ground. Then the voltage across the resistor would be a measure of the current (Amps) through the servo.

I've found that sending a "myservo.write(0);" or "myservo.write(180) doesn't neccessarily command the servo to hit it's stop. I already stripped one because the "0" pulse output was further than the physical stop.

Sounds like you need to learn to slowly test the limits of your servos before sending them high or low values. Below is some servo test code.

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

Exactly what I was looking for. Thank you so much. I tested a metal gear micro servo with this program and found that the servo met its stops at 7 degrees and 170 degrees. I would have burnt this one up without your program also. Thank you again. With the new ranges set, the servo doesn't even get warm. :smiley:

c131frdave:
Exactly what I was looking for. Thank you so much. I tested a metal gear micro servo with this program and found that the servo met its stops at 7 degrees and 170 degrees. I would have burnt this one up without your program also. Thank you again. With the new ranges set, the servo doesn't even get warm. :smiley:

The arduino implementation of servo.write(degrees) was really a sin in this hardware guys mind. It makes an assumption as a default that all servos can travel a full 180 degrees and the default minimum and maximum pulse widths values used are certainly capable of destroying some servos right out of the box as this thread has shown.

Now the servo libraries do give you the 'hooks' to 'correct' the defaults effectively mapping actual pulse width travel stops to 'degrees', but still that still has the error of assuming 180 degrees travel in software is actual true travel range that the servo actually can have. And as most servo manufacture fail to list their actual travel range and minimum and maximum pulse values, it really is a dangerous library in the hands of any one new to using real word servos, if blindly using the defaults the library uses.

I try to always move my servos using servo.writeMicroseconds() and only after I have fully characterized a specific servo as to it's actual min and max pulse width values.

A servo is a terrible thing to waste! :wink:

Lefty

Agreed. Thanks! I was looking through my servo catalog and I noticed at least half of them have their physical stops (pegs in the gears) at 160 degrees rather than 180. These pegs can be removed, but it's worth noting that at least half of the servos I've found will burn up with the standard arduino code if you're not careful!