0

I'm controlling a Hitech HS-625MG servo from a 10k slider via a Nano. For a while the motion tracks the slider position even when moved quickly.

Then, for no reason I can find, it will stop following smoothly & only move in jittery steps & then move as expected again!

The code is cut & paste from the pot-servo example..

#include <Servo.h>

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

int potpin_1 = A0;  // analog pin used to connect the potentiometer

int val_1;    // variable to read the value from the analog pin

void setup() {
  myservo_1.attach(7);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  val_1 = analogRead(potpin_1);             // reads the value of the potentiometer (value between 0 and 1023)

  val_1 = map(val_1, 0, 1023, 0, 180);      // scale it to use it with the servo (value between 0 and 180)

  myservo_1.write(val_1);                   // sets the servo position according to the scaled value

  delay(15);                                // waits for the servo to get there
                                            // have tried values ranging from 5 to 25 same behaviour
}

YouTube vid of the behaviour

Anyone seen this kinda thing before?

EDIT: That is the full code listing & here's the circuit diagram, the same as the knob example frome the Servo examples page except the servo is not being powered by the Nano but is sharing the same power supply. (sorry not next to it at the moment)

enter image description here

  • 1
    We see it all the time. Probably not enough power for the servo motor. Please update your question and show your full sketch and tell how the potentiometer and servo motor is connected or show a schematic. – Jot Dec 8 '18 at 18:06
  • @Jot have edited the OP. Would a cap across the wiper and ground help? – DrBwts Dec 8 '18 at 18:42
  • If you are between working and not-working, then a capacitor might help. I prefer to fix the cause. That the not a full sketch, the loop function is missing a '}' at the end. Did you connect the arduino gnd to the power supply gnd? What kind of power supply is it? 5v 1a ? Please tell us what kind of servo motor it is, can you also give a link to it? A week or so ago, someone had a servo motor that could request more than 2a, it didn't work and a small servo motor was okay. – Jot Dec 8 '18 at 18:47
  • edited the code. Arduino, wiper & servo (hitec HAS625MG) share the same power rails, V+ = 12v – DrBwts Dec 8 '18 at 19:06
  • 1
    That is not a 12v servo motor. That servo motor needs 4.8 to 6v, as most servo motors do. That servo motor is fast and has power, and its stall current is 2.5 amps according to this: hitecrcd.com/products/servos/sport-servos/analog-sport-servos/… therefor you need a power supply of 5v 2.5a for the servo motor. This is indeed a power issue that we see all the time. – Jot Dec 8 '18 at 21:05
1

A servo motor requires a lot of current.

Many have problems when using a servo motor. Sometimes it works a few seconds and then it starts to jitter or it moves a little and then stops or it does nothing and makes a small click noise.

The problem is that servo motors requires a lot of current. Even the small servo motors can require a peak current of 0.5 A. Larger, stronger, and faster servo motors can easily request a peak of a few Amps.

To find the maximum current for the servo motor, look at the stall current of the servo motor.
When a servo starts to turn, it needs a short peak current. That peak current can be near the stall current.

Don't buy a "strong" and "fast" servo motor. 👎
That may sound appealing, but it is better to start with a humble and timid servo motor. 👍
The servo motors have a DC motor with gears inside. Because of the gears it is already strong.

Use a power supply of 5V with enough Amps to be able to supply the stall current of the servo motor.
Use that power supply to power the servo motor (the red wire).
Connect the GND of the power supply to the GND of the servo motor (the black wire) and the GND of the Arduino board.

The 5V pin of the Arduino board can not supply enough power for a servo motor.
It is in the official Arduino examples, but many run into problems with not enough power.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.