servo shudder issue

Hello all. I am on my first project and kinda lost at the moment. I have servo/servo1 on the left and servo2/servo3 on the right. My problem is that when servo2/servo3 reach the 5 oclock position they shudder before reversing and moving back to the 1 oclock position. What is causing that and how can I fix it? I would also like to have the servos stop for a few seconds before changing direction. A simple pause would be great! Thank you in advance for helping me!

Here is my code

// Sweep
// by BARRAGAN <http://barraganstudio.com> 
// This example code is in the public domain.


 #include <Servo.h> 
 // a maximum of eight servo objects can be created 

 Servo myservo; // create servo object to control a servo 
 Servo myservo1; // create servo object to control a servo 
 Servo myservo2; // create servo object to control a servo 
 Servo myservo3; // create servo object to control a servo 


 int pos = 0; // variable to store the servo position 
 int pos_opposite = 0;
 
 void setup() 
 { 
 myservo.attach(9); // attaches the servo on pin 9 to the servo object 
 myservo1.attach(10); // attaches the servo on pin 10 to the servo object 
 myservo2.attach(11); // attaches the servo on pin 7 to the servo object 
 myservo3.attach(12); // attaches the servo on pin 6 to the servo object 
 } 


void loop() 
 {
 myservo2.write(90); 
 myservo3.write(90); 
 delay(25);

for(pos = 0; pos < 90; pos += 1) // goes from 0 degrees to 90 degrees 
 {                                            // in steps of 1 degree 
pos_opposite = 180 - pos;
 myservo.write(pos);                // tell servo to go to position in variable 'pos' 
 myservo1.write(pos);              // tell servo to go to position in variable 'pos' 
 myservo2.write(pos_opposite); // tell servo to go to position in variable 'pos' 
 myservo3.write(pos_opposite); // tell servo to go to position in variable 'pos' 
 delay(25);                                // waits 15ms for the servo to reach the position  
 }
for(pos = 90; pos >= 1; pos -= 1 ) // goes from 90 degrees to 0 degrees 
 { 
pos_opposite = 180 - pos;
 myservo.write(pos);                  // tell servo to go to position in variable 'pos' 
 myservo1.write(pos);                // tell servo to go to position in variable 'pos' 
 myservo2.write(pos_opposite); // tell servo to go to position in variable 'pos' 
 myservo3.write(pos_opposite); // tell servo to go to position in variable 'pos' 
 delay(25);                               // waits 15ms for the servo to reach the position

 } 


 }

They probably shudder because they can't turn through the sort of angle you're demanding

My guess is they shudder because the poster forgot to select the code section and then hit the # icon. If he goes back and modifies that post maybe they will stop.

AWOL: They probably shudder because they can't turn through the sort of angle you're demanding

AWOL thanks for the reply! What do you mean by the sort of angle I am demanding? The left side works just fine and if I have set this up then the right side should just be doing the same thing as the left, correct? How would your code look for this?

How do you describe ‘left’ or ‘right’?

Grumpy_Mike: My guess is they shudder because the poster forgot to select the code section and then hit the # icon. If he goes back and modifies that post maybe they will stop.

Lol so new to the forum. I didn't even see that button when I first posted. Now that I have changed my post, care to take a stab at my questions?

AWOL: How do you describe 'left' or 'right'?

I am a little confused with your question. Left would be the 2 left servos and right would be the 2 right servos. If you are asking me something about the code please dumb it down for me. This is my first project and first time creating code. Thanks! XD

I would put a large delay between the first and second loop and see which loop the shuddering occurs from. It could be also that you are going too fast, so increase the loop delay. Finally print out the values and see if the second loop is sending it further than you think.

Servos are not guaranteed to rotate through 180 degrees (and you may wish to examine your for loops and the comments). They simply may not be able to rotate that far. Try reducing the loop limits, and see if they still shudder.

defines are useful for this sort of thing

Grumpy_Mike: I would put a large delay between the first and second loop and see which loop the shuddering occurs from. It could be also that you are going too fast, so increase the loop delay. Finally print out the values and see if the second loop is sending it further than you think.

You sir are a boss! After reading your post I looked at this

myservo2.write(90); myservo3.write(90); delay(25);

And asked myself why it was there. I removed it and the shudder is gone! Thank you for being the fresh eyes I needed!

One other question! How would I delay the reverse rotation? Right now the servos move 90 degrees, change direction and repeat. How would I set it up so the servos move 90 degrees, wait a few seconds, change direction, wait a few seconds etc etc.

AWOL: Servos are not guaranteed to rotate through 180 degrees (and you may wish to examine your for loops and the comments). They simply may not be able to rotate that far. Try reducing the loop limits, and see if they still shudder.

defines are useful for this sort of thing

AWOL thanks for the input! I really appreciate all the help I came here for! This community rocks!

Put a delay(1000) between the two loops and one at the end of the second loop. Then nothing happens between movements.

Grumpy_Mike:
Put a delay(1000) between the two loops and one at the end of the second loop. Then nothing happens between movements.

LOL I was putting the delay in the wrong place. Now the servos go up, pause, come down, pause. When the servos go down and pause there is a humming sound. Got any idea why? It sounds like it is still trying to move but it can’t.

Also what is hot for a servo? I can feel heat from it but it’s not anywhere close to hot to the touch.

When the servos go down and pause there is a humming sound. Got any idea why?

Probably because it doesn't know the words.

It sounds like it is still trying to move but it can't.

Is there anything trying to mechanically move it, it could be just trying to correct it's position.

Hot is anything you can't stand to keep your finger on.

Grumpy_Mike:

When the servos go down and pause there is a humming sound. Got any idea why?

Probably because it doesn't know the words.

It sounds like it is still trying to move but it can't.

Is there anything trying to mechanically move it, it could be just trying to correct it's position.

Hot is anything you can't stand to keep your finger on.

Words, they fail me!

The servo sounds like it wants to move but isn't. The humming sounds more like the motor is engaged but nothing is happening. This does not occur on the left side at all. It happens in the same place the shudder occurred.

Sounds like you need zoomkat's test sketch

A servo is basically a feed back system translating the position of a pot to match the input value given by the pulses. Sometimes these don't quite match up and noise in the system causes this. Try just moving it a very small amount from the noisy position in the code. This sort of thing happens with servos when they are still.

Sounds like your servo is straining against its internal mechanical stop. Make sure the servo grounds are all connected to the arduino ground. Below is some servo test code you can use to test your servos for roation range and proper operation.

// 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(2000); //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);  // 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();

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