Servo Speed

Is it possible to up the speed of the servo so it moves from A-B quicker?

Please find the code below what I am using to control exhaust valves.

const int  buttonPin = 2;    // the pin that the pushbutton is attached to
const int servoPin1 = 9;
const int servoPin2 = 10;


// Variables will change:
int buttonState;         // current state of the button
int lastButtonState;     // previous state of the button
bool servoFacingLeft;



//servo stuff
#include <Servo.h>
Servo myservo1;
Servo myservo2;

void setup()
{
  Serial.begin(9600);          //  setup serial
  // initialize the button pin as a input with pullup, active low
  pinMode(buttonPin, INPUT_PULLUP);
  //initialize button states
  buttonState = digitalRead(buttonPin);
  lastButtonState = buttonState;
  //servo
  myservo1.attach(9);
  myservo2.attach(10);
  Serial.println("Exhaust Valves "); // diagnostics

}

void loop()
{
  // read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) //changed
  {
    if (buttonState == LOW) //new press, so change servo flag
    {
      servoFacingLeft = !servoFacingLeft;
    }
    delay(50);
  }

  lastButtonState = buttonState; // save the current state as the last state, for next time through the loop


  if (servoFacingLeft) //positions the servo
  {
    myservo1.write(-180); // 180 or -180 depending on type of valve
    myservo2.write(-180); // 180 or -180 depending on type of valve
    Serial.print("Valve Status: ");
    Serial.print(" Valve Open");
    Serial.println(" (Loud Mode)");

    {


    }
  }    else
  {
    myservo1.write(180); // 180 or -180 depending on type of valve
    myservo2.write(180); // 180 or -180 depending on type of valve
    Serial.print("Valve Status: ");
    Serial.print(" Valve Closed");   
    Serial.println(" (Quiet Mode)");
  }
}

Kind Regards,
Mike.

Commercial servos move a bit faster when powered at the upper end of their voltage range, but you should not exceed the maximum supply voltage. The numbers are usually given in the manufacturer's specs.

Servos should ALWAYS be powered separately from the Arduino, with a power supply capable of at least 1 Ampere per servo. Connect the servo power supply ground to the Arduino ground.

You have no real control over the speed of a normal servo. If you write one angle then write a different angle the servo basically goes at full speed between them. The only way to get faster movement is to either to run the servo at a higher voltage or buy a different servo.

OTOH I don't know why you are writing -180 because the range of a write(angle) in Servo.h is 0 to 180. I'm not 100% certain what it does with negative angles.

Steve

Thanks for your replies guys.

slipstick:
You have no real control over the speed of a normal servo. If you write one angle then write a different angle the servo basically goes at full speed between them. The only way to get faster movement is to either to run the servo at a higher voltage or buy a different servo.

OTOH I don't know why you are writing -180 because the range of a write(angle) in Servo.h is 0 to 180. I'm not 100% certain what it does with negative angles.

Steve

I think you can use 0 or -180 and they do the same thing.

the code works for what I want it to do.

Mike.

I think you can use 0 or -180 and they do the same thing.

The standard Arduino servo library specifically sets negative angles to zero, so nothing but confusion is created when you use them.

Hi,

s200bym:
Is it possible to up the speed of the servo so it moves from A-B quicker?

Please find the code below what I am using to control exhaust valves.

What are the valves part of?
Have you thought about using solenoids?
Tom.... :slight_smile: