Hello! I am unfortunately having a problem with the Hiwonder 20 KG Digital Servo (Model HPS-2018). With my test code, the servo is supposed to move smoothly between two set points. Instead, it randomly gets stuck and makes a faint clicking sound. The servo is being controlled by an Arduino Uno and is separately powered by a 5V power source (6 AA batteries through a voltage regulator). According to the Amazon listing, it should work with a 5V source. Will you please help me determine the problem?
//www.elegoo.com
//2016.12.08
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
Serial.begin(9600);
myservo.attach(10); // attaches the servo on pin 10 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
It looks like you could power the servo directly from the batteries (without a regulator). The batteries can supply peak currents where the regulator cannot.
Your power supply for stall current of 3A servo is probably underestimated . These guys are happy with 6-8V at 3A. few AA batteries are not able to supply that.
The minimum voltage required for the HPS-2018 is 6V, not 5V.
To use it, tried powering the servo directly from a 7.2V source (6x rechargeable AA batteries at 1.2V each) and it worked. This is within the manufacturer's voltage range of 6V - 8.4V, so it is safe. I was careful to only use 1.2V rechargeable batteries, as 6x 1.5V batteries would equate to 9V, which is too high for the servo.
These are RC world servos. Designed for 2-3S lipos (with maybe an external BEC - Battery Eliminator Circuit - in the 3S power system) where nominal voltage in a 2S is 7.4V, 8.4V fully charged.)
Oh cool. What's the rest of the circuit? I see @kmin suggested an AC-DC adapter which, if wired looks to be a good one.
If batteries, you may consider one based on price and charging requirements. SLA batteries are the least expensive and can be regulated as needed with a buck converter, you might look at a 12V 5Ah type (where Ah or mAh is essentially "the size of your gas tank")
commonly used as battery backup in building alarm systems https://www.batterymart.com/p-12v-5ah-sealed-lead-acid-battery.html
Or you might look at the RC hobby world and purchase a 2S lipo, but if you don't already have a charger for these or experience, you might pass on this option due to the learning curve of using lipos outside of premade applications like RC cars (which automatically monitor the voltage so it doesn't go too low, which for lipos is bad).
Overall though, an wired option will be your best bet though since a battery like the 12V 5Ah option will only last a couple hours in an animatronic (Hallowe'en?) that's running a few times a minute for the intended effect. One of my magic chests uses a 1/5 scale rated 486 oz/in torque @ 7.4V and such a battery just makes it from 5:30-10pm, used I'd say once per minute on average over that time frame.
Final tip: in your code, you might consider the use of these functions
void Attach(int pin){
servo.attach(pin);
servo.write(15); // or whatever your starting position is
}
void Detach(int pin){
servo.detach();
}
to detach the servo after it's done it's effect and reattach it as needed right before use again. It will cut down on servo chatter, save battery power (if you go that route) and likely help extend the life of the servo itself.