Getting Servo to spin free (or somewhat freely) during a sketch

Hello , this is my problem I am building a small automatic gate that what will be operated with 2 x LDX-227 servos which has 17kg-cm force. A picture of the gate is provided for reference. The weight of the gate will be ~21.51 lbs. Through my calculations I am fairly sure that the two servos will be able to operate the gate 90 degrees in both directions.

Picture for Reference:

Note the red rectangular devices are the servos which will naturally act as a hinge for the gate.

Here is my complete go so far (I have not even begin to implement the ultrasonic detectors, I am still in the servo testing phase.)

My problem is that if the gate is not operating properly I will have a button that can be pressed to cease all functions of the gate (and servos). The gate will be being used by my grandma so she will need to be able to push a button is the gate is not working properly for some reason)
By ceasing all functions I mean being able to open or close the gate by hand. I have tried the command

myservo.detach();
delay(10000000); // followed by a long delay so I can test moving the servo by hand

So far after executing the detach command I cannot move the servo by hand (atleast as easily as I could while the power was off).

Long story short I want to be able to push a button and have the servos move freely (and therefore the gate as well). Note I do understand that the servo doesn’t “exactly” move freely when its not being powered, but for the purposes of the length of the gate ~40 inches, the gate will basically be able to be moved without much effort…)

Any help would be appreciated!! I have thought of using MOSFET to disconnect the power to the servo when commanded to but I feel there must be a simpler way!!

Thanks for any help at all!!

//CONTROLLING SERVO FOR DOOR

// including libraries
#include <Servo.h>
Servo myservo;  // create servo named myservo
int angle; // declare int angle

// *** SETUP ***
void setup() 
{
  //setting servo to mid point (its a 270 degree servo0
  int angle = 135; 
  angle = map(angle, 1, 270, 1, 180);
  myservo.attach(3);  // attaches the servo on pin 3 to the servo object (servo is called myservo)
  myservo.write(angle); // sets servo to mid angle (135)
  
  Serial.begin(9600); 
  Serial.println(angle); //Print some angle information
}
//

// *** LOOP ***
void loop()
{
delay(1000);
angleChoose(45);
delay(1000);
angleChoose(225);
delay(1000);
angleChoose(135);
delay(1000);

myservo.detach(); // detach the servo so it should run somewhat freely????
Serial.println("detached");
delay(1000000);

}
// CONVERTING 180 angle system to 270 angle system
void angleChoose(int choice){
  angle = choice;
  angle = map(angle, 1, 270, 1, 180);
  myservo.write(angle); // writes to specific angle chosen
  Serial.println(angle); //prints angle writen to
}

Note my intent for this program is to turn the servo to midpoint, then delay 1 second, turn 180 the there way, wait 1 second, then go back to midpoint, and then detach and be able to be moved freely

That looks like a nice servo for a robot elbow or knee. I found a specification page for it but I could not see any specification for side-load or radial-load. I doubt that it’s strong enough to hold the weight of the gate. Put some normal hinges on the gate and make the servo operate it through a pushrod.

You should not use two servos in parallel like this. They will fight each other. They will always be a little out of sync with each other. Power consumption will be 2 or 4 times higher than if they aren’t fighting. Just select one servo that is big enough to move the gate on its own. Add a helper spring or counterweight if you have to.

So servo.detach() doesn’t seem to do the same thing as turning off the power to the servo? Then it seems like either your grandmother has to push a little harder or you need to turn off the power to the servo. Pololu makes some nice solid-state switches.

You think that the servo in this configuration (2 of them) till not be able to support the weight of a ~21.51lbs gate?

I did some rough calculations (Im a student so I trying to figure out this stuff) and found that the top servo will have ~76 N of tension in the horizontal while the button servo will have the same (76 N but in compression) . Do you think this is too much?

Here is a picture of the orientation of the servo when it will be in the gate, as you can see the servo Is a dual pole ( I Think that's what they call it, there's also a spot that pivots at the bottom as well)


  • the servo seems to have a perfect construction to be used as a hinge (id imagine for like an elbow on a robot and I understand using it to control a gate isn't really its intended purpose)

I realize that the servos may be "fighting eachother" if not perfectly synced up, so I am either planning to operate both servo off a single arduino pin (with a separate 7.5v 3000mAh power supply) AND also mounting the servo to my gate (which will be welded from thin metal) with an 1/8 in rubber gasket therefore each servo is not completely rigid in its mount to the gate. (meaning that there will be some leeway in the degrees, its hard to estimate at the moment but I would expect any where from 2-8 degrees "give" so that the servos do not spend so much current fighting eachother if they are not perfectly synced.

I do appreciate the previous reply and a suggestion to use a linear actuator to opperate the gate, which is probably the easier and more logical thing to do, but I already have the two servos laying around and would liek to do my best to make the project work with the LDX-227 servos.

Thanks for any other information!! :slight_smile:

EDIT
But there is also the option of doing a double door type of thing so the gate is actually two gates while 1 servo controls each gate, if you guys believe the "servos fighting each other" is that big of an issue. (I do have the wireless chips available to be able to accomplish this....Let me know what you think...
By doing do gates (double door type of gate) each gate would weight about 10 lbs but would be only supported by the single servo.. Just any brainstorming is appreciated and I'm sure my grandma is going to be thrilled to not have to struggle so much to get through her gate!

Thanks a million guys

I sure hope this is an indoor gate. I see NO spec for being waterproof.

Paul

The servos won’t “fight” if they are headed toward the programmed angle. For example, if they are both commanded to go to 90 degrees, they will both be moving toward 90 degrees as fast as possible and they will simply be “helping” each other.

They will only fight when they get to the stopping point, or if you “step” them slowly. And, I kind-of assume you’ve got mechanical stops?

IMO - This isn’t a “servo application”. The gate doesn’t have to go-to arbitrary angles like a servo. It’s just got a couple of stopping points. Of course, servos are “easy” because they have a built-in driver but I doubt commercial automatic gates are build that way.

The double gate sounds more sensible. Much less than half the stress on the servo when it's standing still and no issues with synchronisation.

But, in the absence of any specifications from the manufacturer, it's impossible to say if the servo will support that weight. It "looks" like a big beefy servo that can hold 21lb axial load but I don't know and I suggest you try harder to find out before you build the gate.

The problem with two servos in parallel isn’t the control signal from your Arduino, it’s that each has an internal analog control loop so that driving to position x will result in position x plus/minus some error due to manufacturing tolerances which varies from device to device.
The disagreement on where position x should be results in the servos perpetually fighting each other.

Ok thanks for all help ladies and gentlemen, (yes the gate is indoors btw).

If you were to build this same type of gate that needs to be able to rotate through 180 degrees, what type of motor/linear actuator/would you plan to be the most logical for this application? Or just simply a DC motor?? (Note I would like the gate to open both ways (depending on which way the person is walking towards it it will open away from them)

As I mentioned I'm new to this type of stuff and seen the mounting brackets on the LDX-227 and thought they would be excellent and easy to mount to the metal I am using (1x1 inch square tubing 0.060'' wall thickness.) And of course I can always redesign the gate making it weigh less..... Also of course another option is to mount the gate easing traditional hinges that support ALL the weight of the gate, so the servo has no axial load on it...) too many options!!!

I may scrap the Servo Idea and try something else if someone points me towards a better solution to accomplish the project.

***(back to the original question of whether the command servo.detach(); will allow the servo to free move that is a negative. I tested it out by giving the command servo.detach(); and then unplugged the wire that was connected to the Pin on the Arduino (the one that was controlling the servo) and I was still NOT able to move the servo by hand. It seems the servo will still be locked at the last position even if you use the command servo.detach(); AND unplug the wire going from the servo to the Arduino.)

Thanks all!

The servos you have are probably adequate. But without specs it's impossible to say from this side of your computer screen.

The gate must be closed because of what reason? It's keeping a dog or child out of the kitchen? How big is the intruder? How much force can they put on the gate? Linear actuators are great because they require no power to hold position and their holding force is many times their driving force.

MorganS:
The servos you have are probably adequate. But without specs it's impossible to say from this side of your computer screen.

The gate must be closed because of what reason? It's keeping a dog or child out of the kitchen? How big is the intruder? How much force can they put on the gate? Linear actuators are great because they require no power to hold position and their holding force is many times their driving force.

The gate is basically to keep dogs in, a german shepherd, I cannot wrap my head around how to be able to use a single a linear actuator to be able to open the gate both ways, but I suppose if I compromise I can just have it open on way.

I think before I purchse even more parts Im going to try the servo way (with hinges supporting the gate so no load on the servos and I might even just need one) but if that fails Ill break down and get something like a linear actuator because the gate can be easily modified to accommodate one of those... Any how ill keep posting my progress if anyone is interested.

dingusbird:
The gate is basically to keep dogs in, a german shepherd, I cannot wrap my head around how to be able to use a single a linear actuator to be able to open the gate both ways, but I suppose if I compromise I can just have it open on way.

I think before I purchse even more parts Im going to try the servo way (with hinges supporting the gate so no load on the servos and I might even just need one) but if that fails Ill break down and get something like a linear actuator because the gate can be easily modified to accommodate one of those… Any how ill keep posting my progress if anyone is interested.

Have you considered the speed at which the gate will try to open and close ?

If you command a servo to “go to position x” it will try to get there as fast as possible, which the inertial load of the gate will prevent. The result will be high current draw in the servo motor, leading to over-heating, and eventual premature failure.

The speed of the motor in a servo is reduced to nothing as the servo reaches its commanded position, and you can use this to your advantage by ramping your open and close setpoints. Tune the ramp rate so that the gate opens and closes at a reasonable speed, without overloading the servo(s).

Having said all of that, it seems to me all you need to keep the dog in is an automatic gate closing device - e.g. a spring.

Have a google about at gate opening devices - the devices you will see are pretty hefty and water proof .I wouldn’t use a servo - if someone bangs into the gate they are likely to strip the servo gears, the inertia in the system may also do this as it try’s to start the gate moving .
Maybe a motor , gear box pulleys, limit switches and a slipping clutch might be the way , or buy you opening device and control that

Yes I had considered the speed and was going to lower it to not strip the gears, but may just consider something more simple for this project like the spring. My biggest worry being stripping the gears if someone tries to fight the gate while it’s moving

dingusbird:
Yes I had considered the speed and was going to lower it to not strip the gears, but may just consider something more simple for this project like the spring. My biggest worry being stripping the gears if someone tries to fight the gate while it’s moving

Perhaps something like this would suit. Waterproof as well. Think how hard it would be to ensure a servo was waterproof.