I have a continuous rotation servo I'm trying to control using an Arduino Nano and the Servo library.
This is the servo HSR-2645CR Continuous Rotation Digital Robot Servo:
It has a narrow dead band which may be contributing to my issues.
I can go full speed in either direction by using myservo.write(0) or myservo.write(180), but I can't stop it using myservo.write(90), myservo.write(89) myservo.write(91), or myservo.writeMicroseconds(1500).
When I try to set it to it's midpoint the servo jitters back and forth 1 degree. If I comment out all my servo related code, the servo is static. If I leave myservo.attach(servoPin); in my setup block the servo jitters even without writing a speed/position to it.
The Nano is running 12 Neopixels and two leds which are powered by their own 5V 10A DC power supply.
The servo is powered by its own 7.4 V 2S Lipo.
All circuits are connected by a common ground.
I swapped the CR servo out with a normal 180 Servo and I get even worse jitter after setting an angle.
After I set the servo position, I only write to it if the incoming target position is different that the current position:
f(receive_data.swivel==89){
currentServoPos = 90;
} else {
currentServoPos = receive_data.swivel;
}
//Serial.println(currentServoPos);
if(lastServoPos!=currentServoPos){
myservo.write(currentServoPos);
//myservo.writeMicroseconds(1500);
lastServoPos = currentServoPos;
Serial.println("currentServoPos");
Serial.println(currentServoPos);
Serial.println("lastServoPos");
Serial.println(lastServoPos);
}
To make things even more confusing I found this utility sketch for testing servo angles:
I can only get servo to go max speed at myservo.write(20) and myservo.write(160);
Servo does not budge using myservo.write(0) and myservo.write(180).
Also once it does start turning I CAN get it to stop using myservo.write(92) or myservo.write(93).
Since the servo behaves OK with the utility sketch, is it possible it's picking up noise from the load of LEDs? My next step is to add a 220 uF capacitor directly across servo:
Does anyone have any other tips I could try?