Servo's not centering or working properly

Hello everyone,

I have 2 servos (Robbe 8431) from an r/c kit I bought in 2012. I'm finally working on this and have decided to use an Arduino for control.

I connected a joystick to my Arduino and then connected one of the servos to the Arduino. Both of the servos have issues in regards to the control.

Servo 1: This servo isn't getting the full 180-degree travel. It seems like it is centering around 110-120 with the joystick centered. With the joystick full right it goes to 180 and with the joystick full left, it goes to about 10 degrees or so.

Servo 2: Upon initialization, this servo immediately goes to 0 degrees. When you get to approximately 900, on a 0-1023 scale of the potentiometer, it immediately goes to 180 degrees. If you let go of the joystick at all it immediately rotates all the way back to 0 degrees.

I'm using the same code for both servos and only disconnecting from one servo and connecting to the other in order to test each one.

Thanks for any help!

Code

#include <Servo.h>
int joyPin1 = 0;
int value1 = 0;
int servoValX = 0;

Servo myservo1;


void setup() {
  // put your setup code here, to run once:
  myservo1.attach(9);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  value1 = analogRead(joyPin1);
  servoValX = map(value1, 0, 1023, 0, 180);
  myservo1.write(servoValX);
  Serial.println(value1);

  delay(15);
}

Hi and welcome to the forum.
Use of code tags on your very first post is great! Karma++

It is not unexpected to have a servo provide less than 180 degrees. There is a bit of variability, even among different servos of the same model.

Rather than (or in addition to) the joystick value, I would want to see the servo command value servoValX.

The behavior of your second servo is just bonkers. I suspect it is a bad servo and will need replaced.

vinceherman:
Hi and welcome to the forum.
Use of code tags on your very first post is great! Karma++

It is not unexpected to have a servo provide less than 180 degrees. There is a bit of variability, even among different servos of the same model.

Rather than (or in addition to) the joystick value, I would want to see the servo command value servoValX.

The behavior of your second servo is just bonkers. I suspect it is a bad servo and will need replaced.

Thanks for the help.

I looked back at Servo 1 and it seems just slightly off center. It's most likely something I can deal with.

However, Servo 2 is just bizarre. It's also warm to the touch so I'm thinking maybe something is burned out with it's motor because I can run Servo 1 just as much as Servo 2 and it doesn't get warm to the touch at all.

Servo 2 is probably running hard up against the physical limit and stalling the motor.
I would not continue to use it.

If you have two identical servos and they don't behave equally, switch them to verify that the problem is in the servos. The problem might also be in the code (switch the pins in the code) or in the connecting wires. Switch. Switch. Localise error. Act accordingly.

Attempting to power servos from the Arduino 5V output will cause bad behavior, and can destroy the Arduino.

Use a separate power supply and connect all the grounds.

Thanks for the advice everyone.

I think I burnt out servo 2. Like I mentioned it only goes from 0 to 180. Nowhere in between.

I know it is the servo because I can disconnect from one and plug right into 2 and get different behavior. No changing of the code or anything. I feel if they are the same servo, which the are, they should both stall out or not stall out. That’s what makes me think I broke 2.

What advice would you recommend for powering the servos?

Well, the servo can handle 6 V. So can Arduino. So a packet of four C batteries (R14 batteries) gives you 6 V. Your Arduino should accept that voltage. Common ground for servos and Arduino and the negative out from the battery pack. 6 V directly to the servos power in and to the Arduino. Then signal from an Arduino digital out pin to the servo.

Cheaper servos don't always have the full range of motion.

Beware the map function. You probably are never telling your servos 180.

INTP:
Cheaper servos don't always have the full range of motion.

Beware the map function. You probably are never telling your servos 180.

What would you recommend doing instead of this?

jct32:
What would you recommend doing instead of this?

As I said above:

Rather than (or in addition to) the joystick value, I would want to see the servo command value servoValX.

So print out the result of the analogRead, value1.
AND print out the result of the map function, servoValX.

Move your joystick to the limits of its movement, noting the highest and lowest values that the analogRead brings back. Also note how close to 0 and 180 servoValX gets.

If you get 0 and 1023 for the limits of the joystick, you are good. If you get different numbers, put those in to the map command where you currently have 0 and 1023.

Then try again. How close is servoValX coming to 0 and 180 now?

That - plus if you think Servo1 is not centring properly also show us what values for value1 and servoValX you are getting when your joystick is in the centre. You're expecting something close to 512 and 90.

Steve