Servo Motor Step Less Than 1 Degree

I am doing a group project in which we are designing an actuator for a valve handle using the Arduino Uno R3 board and the ANNIMOS 60KG Digital Servo 8.4V High Voltage Stainless Steel Gear Large Torque High Speed Waterproof Baja Servos - 270 Degrees. We are using push buttons to turn the servo by one degree increments, which in turn opens the valve by one degree increments. During testing, we found that the one degree increment was too large for what we needed. We tried to change the increment to values less than 1 degree, but it did not work with our Arduino code. Is there any way to have this increment less than one degree?

I've attached the code and a TinkerCad model to this post for clarity.

#include <Servo.h>


Servo myservo;  // create servo object to control a servo


int angle = 45;    // initial angle  for servo
int angleStep = 1;


#define LEFT 3  // pin 3 is connected to left button
#define RIGHT  4 // pin 4 is connected to right button


void setup() {
  Serial.begin(9600);          //  setup serial
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(LEFT,INPUT_PULLUP); // assign pin 3 ass input for Left button
  pinMode(RIGHT,INPUT_PULLUP);// assing pin 4 as input for right button
  myservo.write(angle);// send servo to the middle at 45 degrees
}


void loop() {
  // Servo button demo by Robojax.com
  while(digitalRead(RIGHT) == HIGH){


    if (angle > 0 && angle <= 180) {
      angle = angle - angleStep;
       if(angle < 0){
        angle = 0;
       }else{
      myservo.write(angle); // move the servo to desired angle
      Serial.print("Moved to: ");
      Serial.print(angle);   // print the angle
      Serial.println(" degree");
       }
    }
    
  delay(100); // waits for the servo to get there
  }// while
  
  while(digitalRead(LEFT) == HIGH){


    if (angle >= 0 && angle <= 180) {
      angle = angle + angleStep;
      if(angle >180){
        angle =180;
       }else{
      myservo.write(angle); // move the servo to desired angle
      Serial.print("Moved to: ");
      Serial.print(angle);   // print the angle
      Serial.println(" degree");
       }
    }
    
  delay(100); // waits for the servo to get there
  }// 
}

Did you try writeMicroseconds?

if microseconds creates not enough mechanical resolution consider using a steppermotor with gear.

here are some quite expensive but very precise rc-servos.

https://www.01mechatronics.com/c/supermodified-servos/

best regards Stefan

Depending on the valve you are operating you might be able to improve your linkage . Most valve types are most sensitive for the first 1/3 or so of opening.
You could operate the valve via a bell crank linkage ?

1degree of movement is tiny - it’s possible your valve is sized too big for the task

60kg is a real strong servo. I'm pretty sure that this servo can do the job even on a big valve.

How much turnangle to you really need? How big is the turnangle between valve fully closed
and fully opened? How much resultion do you need? 0,5 degree? 0,1 degree?

Another solution could be to mount a rotary-encoder with a high resolution (2000 pulses per revolution) on the valves axle
or mounting a rotary-encoder on a DC motor-axle with a low resoltion (20 - 100 pulses per revolution) and use a gear with a high rpm-ration of 1:50 or 1:100.

How fast must the valve turn?
How big is the real torque? Do you really need a 60kg-servo?

best regards Stefan

Update:

Thank you all for your replies. We tried using the "writeMicroseconds" function to try and increase the resolution, but there was no significant change in how the motor operated (code is below). We tried it in increments of 1, 5, and 10 microseconds, but the servo would only move after about 4-5 button presses.

Also, we discovered an issue where if we were able to get the servo to move after a button press, press the other button that makes the servo move in the opposite direction would not result in the servo return to the position it was previously at.

#include <Servo.h>


Servo myservo;  // create servo object to control a servo


int angle = 1000;    // initial angle  for servo
int angleStep = 1;


#define LEFT 3  // pin 3 is connected to left button
#define RIGHT  4 // pin 4 is connected to right button


void setup() {
  Serial.begin(9600);          //  setup serial
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  pinMode(LEFT,INPUT_PULLUP); // assign pin 3 ass input for Left button
  pinMode(RIGHT,INPUT_PULLUP);// assing pin 4 as input for right button
  myservo.writeMicroseconds(angle);// send servo to the middle at 45 degrees
}


void loop() {
  // Servo button demo by Robojax.com
  while(digitalRead(RIGHT) == HIGH){


    if (angle > 500 && angle <= 1000) {
      angle = angle - angleStep;
       if(angle < 500){
        angle = 500;
       }else{
      myservo.writeMicroseconds(angle); // move the servo to desired angle
      Serial.print("Moved to: ");
      Serial.print(angle);   // print the angle
      Serial.println(" degree");
       }
    }
    
  delay(100); // waits for the servo to get there
  }// while
  
  while(digitalRead(LEFT) == HIGH){


    if (angle >= 500 && angle <= 1000) {
      angle = angle + angleStep;
      if(angle >1000){
        angle =1000;
       }else{
      myservo.writeMicroseconds(angle); // move the servo to desired angle
      Serial.print("Moved to: ");
      Serial.print(angle);   // print the angle
      Serial.println(" degree");
       }
    }
    
  delay(100); // waits for the servo to get there
  }// 
}

TheMemberFormerlyKnownAsAWOL:
Did you try writeMicroseconds?

Thanks for this! We tried this, and still encountered problems with resolution. I posted an update as a reply to this thread.

I don't think ordinary hobby servos can do better than one degree (if that). Apparently your rather nicer servo can't either.

You could throw money at the problem and buy something even better, or try a different solution. Stepper motor maybe, perhaps some gearing could help or micro stepping might get you something.

It seems odd that single degree resolution on your valve is too little - what are you doing?

wildbill:
I don't think ordinary hobby servos can do better than one degree (if that). Apparently your rather nicer servo can't either.

You could throw money at the problem and buy something even better, or try a different solution. Stepper motor maybe, perhaps some gearing could help or micro stepping might get you something.

It seems odd that single degree resolution on your valve is too little - what are you doing?

We are trying to automate the value to be able to to control the mass flow rate through the system based on a preset mass flow rate value. The system we are working through has a lot of instability, so we designed a sensor that would relay the current mass flow rate to the Arduino, which would adjust the valve opening to less more or less air flow through the valve. We need the valve to be able to be opened in small increments so that the mass airflow could be precisely controlled, but 1 degree causes the mass airflow through the value to increase by significant amounts.
We are working with a ball valve.

usually ball-valves are just for open / close completely by a quick doable 90 degree-turn.
Those ball-valves have a non-linear position to flow-diamater correlation.

Your system seems to need a valve that variates airflow linear and with 1 degree to change the airflow only a small amount.

You still haven't described the whole system. If it is not a secret please describe it in detail.

details overview:
We are talking about details. Please give an overview over your whole project.
in mimimum 70% of all cases knowing the whole thing offers completely different and much better working solutions.
This is like

Newbee: "I want to do better cutting please help me sharpening. "
Expert: Sure I can help you with what are you cutting?
Newbee: With a scissor.
Expert: OK take this sharpening tool
Newbee: Yea works great Next question How can I make it cut faster I need to finish faster.
expert: Motorised scissors.
newbee Yea works great though still not fast enough.

expert: Ok can you give an overview about what you are cutting.
newbee: the green of a football-arena.
expert: Oha! take a big mowing tractor with a seven boom spindel-mower and GPS-steering

In the beginning the newbee always just told details.
The expert was assuming the newbee knows that his basic approach is well suited.
which turns out to be very bad suited
that's the reason why it is always a good idea to give an overview and to explain what shall happen in the end.

best regards Stefan