ticklechicken

I'm making a remote start for my generator and I have a servo to operate the choke. When I power my system, both the Arduino and the servo get power at the same time. My servo gives a quick little twitch and rotates about 30 degrees. This isn't desirable. Everything runs off the 12V battery and the servo gets its power from a 5V BEC. The servo is too big to run off the Arduino 5V supply.

I played around a little and I can get rid of the twitch by delaying the power to the servo. My current solution is to manually connect the BEC after the Arduino is alive and sending a control signal to the servo. This works, but obviously isn't a good long term solution.

Anyone else experienced this? Any good solutions?

My current thought is to use a MOSFET to control the BEC. I would just turn on the BEC around 200 milliseconds after the Arduino control signal is sent. Is there some product out there that outputs 5V and can be easily turned on/off through a built in Arduino input (combined BEC and MOSFET/relay)? I'm trying to reduce assembly time as I have to build a bunch of these.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.I speak for myself, not Arduino.

The most common thing with servos is that they twitch when power is applied. Some are much worse than others. The GWS servos I have are especially bad.

That's if you aren't even sending pulses to the servo. Then, you have the problem that theservo will almost never be in the exact position corresponding to the first pulse it gets, and it will go to the commanded position at maximum speed. So, 2 uncontrollable movements,(a) one at power up, and (b) the other with the first command pulse.

For (a), try different servos. For (b), you might use some sort of external position feedback,such as another pot, or alternately, take advantage of the fact that servos have poor torque when the pulses aren't coming in at a full 50-Hz rate. IOW, send the first few pulses at a slowupdate rate so the servo takes a while to get over to its commanded position.

ticklechicken

Thanks for the suggestions. I had to put this away for a while, but I'm back for the weekend.

The problem is in the setup, not in the loop. The twitch is at the myservo.attatch() and myservo.write() commands. As AWOL suggested, I tried swapping those commands and also adding a delay(1000) in between the commands. None of these ideas worked. What's shown below is the last code I tried.

oric_dan - (a) I've tried 3 servos, and they all do this. I'm buying cheap servos, so maybe that's the problem. (b) In my system, the servo will always end in the start position for the next operation. I don't have to worry about this part of the initial servo jump.

Simple servo test code. I noticed in your code that a comment said pin 8 was being used, but the code used pin 9. Also, if the 5V BEC can be set to 6v, the servo will perform better. Does the BEC function the same as an UBEC that is used to power servos (In usually see the BEC associated with brushless motors)?

// zoomkat 10-22-11 serial servo test// type servo position 0 to 180 in serial monitor// or for writeMicroseconds, use a value like 1500// for IDE 0022 and later// Powering a servo from the arduino usually *DOES NOT WORK*.

void setup() { Serial.begin(9600); myservo.writeMicroseconds(1500); //set initial servo position if desired myservo.attach(7); //the pin for the servo control Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded}

A write sets the timing for the pulse, but if there's no pin attached to the Servo object, it effectively changes the default position for the Servo.Say, for example, your application always parks the servo at zero degrees.At startup, the default behaviour of the Servo object would be to move the servo to 90°, and you would do an immediate write to set it to zero. It may well twitch.Do the write before the attach, no twitch.Or, you could just put the horns on with a ninety degree displacement.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.I speak for myself, not Arduino.

ticklechicken

zoomkat - Yes, its acutally a UBEC. It's an old habit from the r/c car days to call them BEC's. I switched the UBEC output from 5V to 6V and I still get the twitch.

AWOL - I changed my starting position from 50deg to 90deg. I still get the twitch.

Let me give everyone more detail. When the myservo.attach(servo) line is executed, the servo rotates 30deg clockwise. It doesn't matter if I write a myservo.write(start) before this line or not. The attach line always causes the 30deg cw rotation. I've tried manually moving the servo horn to some random position before energizing the system. Even then, the servo rotates 30deg cw before going to its start position. I'm stumped.

ticklechicken

Good idea. I just checked all the wiring and the grounds look good. When I was going over my breadboard, I realized that I was assuming the two grounds on the UBEC were grounded to each other. I just verified this with the multimeter, but I added a ground circuit across the UBEC grounds just to be safe. Still twitching...

I've done some tinkering with servos controlled by the arduino and never had this issue.

As noted, some servos, such as GWS, twitch much more than others on power application. Other than finding servos that don't twitch, it may work to use a Mosfet to apply power to the servo [p-chan Mosfet on high-side power], and start the incoming pulses before power is applied. Maybe.

ticklechicken

As noted, some servos, such as GWS, twitch much more than others on power application. Other than finding servos that don't twitch, it may work to use a Mosfet to apply power to the servo [p-chan Mosfet on high-side power], and start the incoming pulses before power is applied. Maybe.

This works with the servos I have. After I power on the Arduino, I manually connect the servo to power and there's no twitch. So I know the P-chan Mosfet circuit you describe will work.

I swapped my Uno boards and the twitch is still present. When swapping servos on the new Uno, one thing that was interesting is that different brand servos twitch in different directions (ccw vs cw). I'm ordering some other servos today. If that doesn't do it, I'll do the Mosfet design.