To explain more clearly, the original setup was:
The servo is a 360 continuous servo (DS04-NFC) with current draw of "less than 1000mA" operating at 5V.
Arduino Pro Mini
AC DC wall adaptor, 5V 1000mA, wired into a bread board (+/- rows) with servo +/- also connected to those rows
(i.e. receiving power from wall adaptor) and the Pro Mini raw and ground also connected to those rows on the breadboard. Pro Mini VCC is powering a HM-10 bluetooth module.
The problem: The first time that power is supplied to the servo, it moves at full speed 20 degrees (roughly) counterclockwise. This is a big negative because:
-it will possibly shut a sliding door on user's fingers,
-or grind the servo gears if the door/servo happens to hit a physical stop during that sudden movement,
-or just generally scare the user by moving so suddenly.
I have tried every solution mention in various threads such as servo.write(90) [which means "don't move at all" in 360 degree servo language], servo.detach then later servo.attach, attach only the info pin of the servo then later attach power, etc. etc.
In every situation I have tried, the servo jumps 20 degrees at full speed when power is first supplied. No exceptions. It does this when the Pro Mini has a blank sketch, or a regular sketch with servo objects, or any other sketch.
Here's a simple sketch I have been working with, but as you can see from the comments, none of these lines has any effect in stopping the sudden jump of the servo.
#include <SoftwareSerial.h>
#include <Servo2.h> // Include the Servo2 library (non standard library since regular servo library conflicted with software serial causing twitching when HM-10 data was sent over serial)
SoftwareSerial HM10(2, 3); //HM10(Receive Pin, Transmit Pin) -This assumes that the BLE RX to pin 3 and TX to pin 2. Any digital pins may be used. Basically, HM10 RX pin gets attached to Arduino TX pin.
// Variables and objects for servo motor
int servoPin = 10; // Declare the Servo pin; Putting this line here or taking it out has no effect on the jumping of the servo
Servo Servo1; // Create a servo object; Putting this line here or taking it out has no effect on the jumping of the servo
void setup()
{
Serial.begin(57600); // Begin the Serial Monitor connection at 57600bps
Servo1.attach(servoPin); //attaches the servo to the variable servoPin; Putting this line here or taking it out has no effect on the jumping of the servo
Servo1.write(90); //tells the servo to not move anywhere; Putting this line here or taking it out has no effect on the jumping of the servo
}
void loop()
{
//Servo1.write(90); //tells the servo to not move anywhere; Putting this line here or taking it out has no effect on the jumping of the servo
}
Additionally, I should mention that simply connecting power to the servo with no connection whatsoever to the Pro Mini has no beneficial effect, i.e. the servo still jumps 20 degrees one time. Disconnect power and then reconnect, the servo jumps again.
In fiddling around, I discovered that connecting the Pro Mini to USB serial (which supplies 5V power to the Pro Mini) but NOT connecting the wall adaptor results in the servo still jumping 20 degrees (servo is getting power from the raw pin of the Pro Mini in this situation). But the good news is that this 20 degree jump is much milder since the amps coming through the raw pin are much lower than 1000mA. By "milder", I mean the jump is slower than full speed and has much less torque, so it does not grind the gears if the servo has reached a physical stop. This is a big improvement even though the servo is still making the annoying jump.
My.Idea1: Attach the Pro Mini to wall adaptor first, but don't attach the servo to the wall adaptor. In this situation, the servo will not get power from the wall adaptor but instead will only get low amp power from the raw pin of the Pro Mini. After the mild jump is complete, THEN attach the servo to wall adaptor power. I have simulated this with wires and it results in only the mild jump and no crazy jump later. (Not sure how to make this delayed connection between servo and wall adaptor, but I guess it will be a relay or transistor or something like that).
My.Idea2: Roughly the same BUT don't let servo pull power from Pro Mini for the mild jump (since this might damage the Pro Mini?). Instead, have a power connection from the wall adaptor to a transistor/relay (limiting the amps) to the servo, wait for the mild jump to complete, then increase the power to servo to regular levels. I'm even thinking that if the amps supplied to the servo during this initial period are really really low, there might be no jump, mild or wild, at all.
Your.Input?
