Rotation angle of Servo???

I am using Vigor VS 2 servo. As per data sheet, its output angle is >=170 degree and pulse traveling 800 to 2200 μsec.

When I give command of 90 degree to rotate, it rotate slightly more than 90 degree but when I give command of 85 degree then it is looking like exact 90 degree.

I have written simple program as written below.

Servo myservo;
int pos = 0;
void setup()
{
myservo.attach(9);
}
void loop()
{
myservo.write(85);
}

What I require to modify to get the exact angle as per program code.

Thank You,

Regards,
Nirav

Do you know that your servo is actually that accurate?

Also, you are calling the servo write far too frequently in loop(). Servo uses PWM. You can't change the parameters faster than the actual PWM frequency and expect it to work.

A difference of five degrees is less than the spacing of the seconds/minutes markings on a watch face - are you sure the two positions are identical?

The arm on a servo can be installed in many different positions. Perhaps the position of the arm on the shaft is wrong. Move the servo to 90° and while it is there, remove the arm and re-install it positioned at 90°.

If you want more precise position control use servo.writeMicroseconds().

Use servo.writeMicroseconds() for finer control.

And allow time for the servo to respond between successive writes. A servo is very slow compared to an Arduino.

...R

Servo test code you might use to determine the best command value to use to position the servo in the desired position. You get finer control using writemicroseconds.

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

Robin2:
Use servo.writeMicroseconds() for finer control.

And allow time for the servo to respond between successive writes. A servo is very slow compared to an Arduino.

...R

Dear Robin,

I have tried to do the things by using servo.writeMicroseconds(). In this case, I am getting the 90 degree rotation at approx 1700 usec (Range is 800 to 2200 for Vigor VS-2 Servo) whereas I should get the 90 degree at approx 1500 usec. Isn't it???

For 1500 uses, servo rotates only approx 60 degree instead of 90 degree.

aarg:
Do you know that your servo is actually that accurate?

Also, you are calling the servo write far too frequently in loop(). Servo uses PWM. You can't change the parameters faster than the actual PWM frequency and expect it to work.

Dear Aarg,

In datasheet, there is nothing mention regarding accuracy.

I have used tried by providing delay(200) but it is still not working as per expectation.

ecaits:
whereas I should get the 90 degree at approx 1500 usec.

You are assuming too much precison.

Do things the other way round. Figure out what numbers of µsecs gives you the angles you want and then use those numbers.

...R

For 1500 uses, servo rotates only approx 60 degree instead of 90 degree.

What is the full physical rotation range of your servo? 60 deg from what starting point? What are the deg positions at which the servo stops rotating?