Unwanted servo travel

Hi,

I'm new to Arduino and i've been playing with the example sketches. I'm trying out a servo with a potentiometer running the knob example sketch. It works ok except that when i turn the potentiometer fast to the center (position 90) from one end (position 180), the servo will quickly travel to the other end (position 0) and then back to the center position (90). It only does this from 0 to 90, not the other way around (90 to 0). If i turn it slow (normal speed) it won't overshoot.

I came about this problem when i hooked up a joystick(basicely a potentiometer on springs) instead of the potentiometer. When i pulled the stick to one side and let it go the servo would go to the center position, but when i pull the stick to the other side and let it go the servo will travel all the way to the other end and back to the center position again.

I made my circuit like this video

I have an arduino uno. a modelcraft y3009 servo http://shop.conrad.nl/hobby/modelbouw/afstandsbedieningen-en-elektronica/servos/servos/209089.html i used this video tutorial from makezine to make the circuit http://blog.makezine.com/archive/2009/02/how-to-tuesday-arduino-101-potentio.html

Does anyone have any idea how i can prevent this traveling of the servo?

I think this is a function of your servo motor not anything you are doing with it. As such I don't think there is a cure.

Perhaps you are getting an input signal of 0 Can you track what the input signals are? Perhaps you are telling the servo to go to zero Can you track what servo commands you are sending to the servo?

I think that some debug statements showing the input and output signals might help identify the problem.

but when i pull the stick to the other side and let it go the servo will travel all the way to the other end and back to the center position again.

Well, perhaps you shouldn't be cocking the joystick to one extreme and then letting it go. Most joysticks I've seen are spring loaded and will over shoot back and fourth when let go until they settle at center. You may need to put some delay in your code to account for this behavior.

Tnx for the replies,

It also happens if i let the joystick go but making sure it can’t jump to the other side.

I did track the signals, it doesn’t show the overshooting.
I tried swapping the current input on the potentionmeter, this gives the same result but mirrored. so now the servo shoots to 180 and back to 90.

below is the code i’m using, i also tried increasing the delay.
plus i tried an if statement that only sends signals to the servo if the potentiometer input changes.

// Controlling a servo position using a potentiometer (variable resistor) 
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott> 

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
void loop() 
{ 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 
}

Does the same issue occurr with both pots in the joystick? It could be due to the construction/quality of the pots themselves. You might try testing your code with a good quality knob type of pot and see if you get the same effects. Does the extreme drection reflect that the pot is inputting a low voltage to the analog input pin? Is the joystick a high quality one, or is it in the surplus $5 range?

It does the same with both pots and also with a third separate potmeter that i have... It seems that this is a servo issue, as the readings don't show the potmeters sending wrong signals. But i think it's odd that when i switch the powerlines around that i get the same result but in the other direction..