Go Down

Topic: Adafruit PWM/Servo Shield SG90 Servos Buzzing (Read 6193 times) previous topic - next topic

davidhunter

Hello All,

I've looked through the forums, and elsewhere online but I can't find the answer to a simple query. I want to know the pulse width min & max settings to use for the TowerPro SG90 servo with the Adafruit PWM/Servo Shield? I'm sure someone must know this as they are both popular products.

I have found on a spec sheet that the pulse width of the SG90 is 500 - 2400 ┬Ás, but the Adafruit library uses a different scale, something out of 4096 and I'm a bit confused by the maths as it doesn't come out with the correct value and I'm still getting some of the servos buzzing when at one of the extremes. Trial and error has only worked so well.

If I do the calculations:
1000000/4096 = 244.140625
500/244.140625 * 60 = 122.88;
2400/244.140625 * 60 = 589.824

But these values cause a fair bit of buzzing on the servos and I'm worried I'll damage them. Through trial and error the better values are something around min:140, max:640; And that doesn't seem to get a full 180 out of them.

Can anyone recommend values that they have used, or other reasons why the buzzing may be occurring? I am powering it with a 5v 10a supply and running 16 servos at once from the shield. The buzzing can still occur if there are less though.

Thanks in advance,

David

KCheshire

Not sure if you're still checking this thread or not, but here are the values I've been using that have been working pretty well:

0 degrees - 175
90 degrees - 425
180 degrees - 675

Like you, I checked the datasheet also, saw the 500-2400, tried it and didn't get what I expected.  Hope that helps!

davidhunter

Thanks, I really appreciate you posting your values. I'll check them next time I fire the servos up!

Cheers,

David

zoomkat

Quote
and I'm still getting some of the servos buzzing when at one of the extremes.


Hopefully the servo gears haven't stripped when driven against the internal hard stop (some 9g servos do that) . Below is some test code you can use to test your servos with the adafruit shield removed (using the servo.h library).

Code: [Select]

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

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up