Tower Pro Micro Servo Problem

I am new to servos so this could be something that is either common, or there is a simple fix. I have purchased a Tower Pro MG90S Micro Servo in which to experiment with in order to possibly incorporate within a future project. I have used the Servo library with a potentiometer in order to rotate the servo from 0 to 180 degrees. When the potentiometer is full at 179 bits, the servo sits a 180 degrees. When I rotate the pot to 0 bits, the servo probably reaches about 10 degrees then grinds to a halt making a terrible buzzing noise. Sometimes it is difficult to swing the servo back into safe territory.

Hi.
Be very meticulous when writing code, but also when describing a problem.
Are you sure you are setting your potentiometer to 179 bits ?
I'm sure you're meaning something else.

Show the code you are using, nicely put in [code] [/code] tags ofcourse.

And please, could you hit the enter button once or twice when composing a message here ?

Servos generally have less than 180 degrees of physical travel, so this sounds normal to me.

When the potentiometer is full at 179 bits, the servo sits a 180 degrees. When I rotate the pot to 0 bits, the servo probably reaches about 10 degrees then grinds to a halt making a terrible buzzing noise. Sometimes it is difficult to swing the servo back into safe territory.

I'm guessing everyone knows what you mean but you should know that pots are resistors and they don't have "bits". There is a voltage on the wiper that is read by an ADC and converted to some PPM value using something similar to the Map function:
like this: (from "Knob" Example in IDE Servo library:

 // Controlling a servo position using a potentiometer (variable resistor) 
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> 

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
void loop() 
{ 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 
}

Point being, it would be more appropriate to say "when I turn the pot to 100% which corresponds to 179 "counts" (not "bits", since that is a term reserved for binary nomenclature, not PPM software counts. You'll probably think I am splitting hairs but I thought that you should know that what you are saying doesn't make sense.

Some servo test code you can use to determine the mechanical limits of your servo.

// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a 
// to decrease) and enter to change servo position 
// (two hands required, one for letter entry and one for enter key)
// use strings like 90x or 1500x for new servo position 
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continous rotation servo
//int pos=90;

void setup()
{
  myservo.attach(7, 400, 2600); //servo control pin, and range if desired
  Serial.begin(9600);
  Serial.println("serial servo incremental test code");
  Serial.println("type a character (s to increase or a to decrease)");
  Serial.println("and enter to change servo position");
  Serial.println("use strings like 90x or 1500x for new servo position");
  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) {
    if(readString.indexOf('x') >0) { 
      pos = readString.toInt();
    }

    if(readString =="a"){
      (pos=pos-1); //use larger numbers for larger increments
      if(pos<0) (pos=0); //prevent negative number
    }
    if (readString =="s"){
      (pos=pos+1);
    }

    if(pos >= 400) //determine servo write method
    {
      Serial.println(pos);
      myservo.writeMicroseconds(pos);
    }
    else
    {   
      Serial.println(pos);
      myservo.write(pos); 
    }
  }
  readString=""; //empty for next input
}

I should of mentioned I have implemented the "Knob" Example in IDE Servo library.

Apologies, I do know what a potentiometer is, I was just referring to the steps/counts (0 to 127) from the map function as you guessed.

In regards to the potentiometer going from 0 to 100%, I had the serial monitor open to determine this.

Servos generally have less than 180 degrees of physical travel, so this sounds normal to me.

That's good to know, as I thought I may of had a faulty servo.

Some servo test code you can use to determine the mechanical limits of your servo.

Thanks, I'll upload the servo code later and experiment :slight_smile: