I’m trying to control an HS-785HB winch servo with an Arduino Uno to move a rail up and down, and it’s not working for me. I’m pretty new at this, so I’m sure it’s some boneheaded mistake on my part, but I can’t figure out what it is.
I have a shop DC power supply set to provide 6V and 1800 mA and I’ve connected the servo to its positive and negative terminals. I’m running code like at https://forum.arduino.cc/index.php?topic=388506.0 , which uses the servo library (#include <Servo.h>) to attach to the servo and write different microsecond values to it. In every case, the behavior I get is the servo just rotates continuously counter-clockwise drawing about 100 mA (no load). In fact, I get this same behavior if I just touch the signal wire with my finger. If the signal wire is disconnected from the pin and not touching me, then the servo stops rotating. Using a multimeter connected to the PWM pin, I do see about 50 Hz (49.93) and 7.5% duty cycle for 1500 microseconds, which is what I expect.
In the thread I linked, the poster experienced the same problem. One suggestion was “connect the grounds together”. That may be where I’m going wrong. When I connect the servo to the the ground of the power supply or to the Arduino ground, it doesn’t draw any current at all. Does that make sense?
The servo power supply and the board grounds have to be connected or you will get erratic behavior from the servo. The electrical control signal from the board to the servo has to have a ground path back to the board.
So, I can connect the servo ground (black wire) to the Uno board ground, but then the circuit doesn't work, i.e., it draws no current. That's where I'm confused. The only way I can get a working circuit is to connect the servo's red wire to the positive terminal of the power supply and the black wire to the negative terminal of the power supply. The power supply has a separate ground terminal, but connecting the servo's black wire to that also ends up with 0 current.
Maybe a picture will help.
So, I can connect the servo ground (black wire) to the Uno board ground, but then the circuit doesn't work, i.e., it draws no current. That's where I'm confused. The only way I can get a working circuit is to connect the servo's red wire to the positive terminal of the power supply and the black wire to the negative terminal of the power supply.
That's good so far but the negative terminal must ALSO be connected to Arduino GND.
Yes, thanks guys! That's what I was missing. I had servo ground directly to power -VE. Servo ground to Arduino ground and power -VE to Arduino ground ... that's the secret sauce.