Hello, I've searched the board and found similar issues but nothing exactly the same as what I'm experiencing...
My Circuit:
I am using a fairly high-powered servo (at least compared to ones I've used in the past) rated at 25kg.cm, with voltage input limits of 4.8-6.8v.
I am powering the servo with 4*1.5V D batteries to give 6V (actually measuring as 6.3V), with the control pin connected to a PWM pin on a Mega which I'm powering using USB. Ground of the battery pack is coupled to the ground of the Mega.
To eliminate the effects of anything else, there is currently nothing else in my circuit.
My problem:
With everything connected up, I can get a few different behaviours. First - a simple sketch instructing the servo to move to a single position and stay there, e.g.
Servo myservo;
void setup(){
myservo.attach(9);
myservo.write(90);// move servos to center position -> 90°
}
void loop(){
}
The servo quietly & rapidly 'clicks' and there is no movement. If I apply gentle pressure I can fairly easily manipulate the servo, and if pushing in the right direction, it will 'snap' to the right position. Once there, it will NOT budge with even significant manual force. Unloaded, it is drawing only 3.1mA, when loaded this rises to 100s of mA with moderate force.
Making things more complicated, if I write a simple sketch asking it to move between a few positions, e.g.
#include <Servo.h>
Servo myservo;
void setup(){
myservo.attach(9);
myservo.write(90);// move servos to center position -> 90°
}
void loop(){
myservo.write(90);// move servos to center position -> 90°
delay(500);
myservo.write(30);// move servos to center position -> 60°
delay(500);
myservo.write(90);// move servos to center position -> 90°
delay(500);
myservo.write(150);// move servos to center position -> 120°
delay(500);
}
Behaviour is as above - clicking, no movement, and easy to manually force the servo. It will now occasionally 'snap' to one of the positions, but it remains quite easy to manipulate.
When trying to figure out the problem, I've tried a few things. The only thing with any success is to write a loop moving the servo in 1 or 2 degree increments, with a short delay between each step e.g:
#include <Servo.h>
int a = 1;
int mode = 1;
Servo myservo;
void setup(){
myservo.attach(9);
}
void loop(){
if(mode == 1){
myservo.write(a);
delay(10);
a=a+1;
if(a>=90) {
mode = 2;
}
}
else {
myservo.write(a);
delay(10);
a=a-1;
if(a<=0){
mode=1;
}
}
}
This successfully gives a slow sweep back and forth, however, the behaviour is not suitable for my project:
- It is too slow. Decreasing the delay below 10mA, or increasing increments results in no movement.
- It is too weak - while sweeping like this, the stall torque is ridiculously small.
Being very new to microcontrollers and electronics in general, I might be missing something obvious - can anyone see something wrong it the system I have described? Otherwise, any ideas what is causing this and how I can get full operation of the servo?
Thanks,
arichw