I'm trying to control some servos (model: Turnigy TG9e) using Arduino. I power them from an external power supply (5V, 3Amp) and not forgetting to make a common grounding. This works fine.
The problem is whenever I press the 'reset' button (on the Arduino), the servos are twitching fast all the way to one end which is a total disaster in my project :-/
I tried the following: (1) adding a resistor between the output pin and the servo command input. same problem. (2) adding a resistor between the servo command input and the ground. same problem.
what am I missing ?
ps: I also noticed that without ANY input signal to the servo (just power and ground), when I touch its signal wire - the servo still twitches...
I am having this exact same problem. I think the problem is in the code.
The variable I am using to write the angle is initialized as equal to 1. Therefore the arduino writes this value to the motor before entering the loop. This creates a total disaster as my project uses fragile parts not meant to accelerate so quickly. Here is the code I am using.
const int pin0 = 0;
const int pin1 = 1;
int angle = 0;
if (((analogRead(pin0)) > (analogRead(pin1))) && (analogRead(pin0) - (analogRead(pin1)) > 50))
angle = (angle + 1);
if (((analogRead(pin0)) < (analogRead(pin1))) && (analogRead(pin1) - (analogRead(pin0)) > 50))
angle = (angle - 1);
Thanks Justin, but I don’t believe that it’s a code problem. As I mentioned, it does the sudden jump even without any control signal (signal wire - unplugged !), just by the mere touch over the servo wires. I think it has something to do with static charges, or capacitance… (?!)
how does one properly deals with these erratic out-of-range jumps ? do I need an external servo controller?
You probably could lightly ground the signal lines with a high resistance resistor to keep the lines from having a floating charge. I think I've read that the arduino cycles thru the pins when it resets, which also could cause a problem.