Minimum possible angle movement of HS 311 Servo motor

Dear All,

I hope you are all in the best of your health and spirits.

The servo.h library does not allow the use of floating numbers. I desire the maximum possible accurate movement of this motor. Currently, I can only move it to 1 degree. How do I get to floating numbers?

I am not good at this stuff .Any help regarding the matter would be highly appreciated.

Thank you.

Are you sure the servo can be positioned as closely as you want in the first place?

Servo test code where you can use the writeMicroseconds to test your servo.

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

JimboZA:
Are you sure the servo can be positioned as closely as you want in the first place?

I am not sure on that either. :~ I guess, it depends on the gear and the teeth assembly?

Thank You ZoomKat. Appreciate it.

I've tinkered with servo resolution in the past and .5 deg is about the limit of resolution with standard servos. Also analog servos usually have about 5us deadband internally to reduce position hunting.

adilrahim:

JimboZA:
Are you sure the servo can be positioned as closely as you want in the first place?

I am not sure on that either. :~ I guess, it depends on the gear and the teeth assembly?

Yes I see that's a nylon geared one... and I also read that sometimes there's an intrinsic lack of positioning ability in the potentiometer mechanism in a servo. I'd be really surprised if you can get even repeatably to anything like a degree. But that's me just guessing...

So what I'm going to do is rig up some kind of pointer / protractor thing this weekend and see what kind of luck I have. I've got a couple of standard size HK15138s and micro size HXT900s.

What sort of loading will your servo be subject to?

Edit... hey ZK, that's exactly the kind of rig I have in mind... I was thinking 1/2 degree tops, most likely even 1 degree. We'll see.....

JimboZA:
What sort of loading will your servo be subject to?

Running on no-load conditions as of now.