How to stop servos before reaching position

I need help in stopping a servo. I'm using a linear servo found here (-R option):

http://firgelli.com/Uploads/L12_datasheet.pdf

Basically, it works like a traditional servo. Black, red, white connections. Pulse sent to control "degree" 0-180 of the servo, in this case retracted and extended. I'm using the servo library included with the arduino software.

Since linear servos take a reasonably longer time to reach the specified position, I was wondering if I could somehow interrupt and stop the servo before it reaches the positions. For instance, if the servo is fully retracted and the user specifies the servo to fully extend, along the way I want the user to be able to stop the servo at any position during that time.

Do I have to set up some sort of enable pin that controls the power directly to the servos?

You might try using the servo detach function.

zoomkat:
You might try using the servo detach function.

Servo - Arduino Reference

Thanks. I thought the same, but unfortunately it didn't work. I'm assuming once the servo is sent the "pulse" to move to a specified angle, even after you detach it, it is still set to move to that position, and since still powered, won't stop until it gets there (probably bc of the control circuitry on the actual servo). Any other thoughts?

Assuming you are using the servo only version I would set up a function that works similar to fading an LED. Adjust the fade rate to the servo speed. That way the servo is never very far from the set point. Depending on load, precision and speed this may need some tweaking.

I'm assuming once the servo is sent the "pulse" to move to a specified angle, even after you detach it,

If that is the case it's not servo compatible as they say it is.

One question, does detach actually stop the pulse train? The documentation is crap (as per normal) and doesn't spell that out. It may just shut the class down but not stop the timer generating the pulses.

One way to find out, pull the wire after doing the detach (or at any time actually).

BTW, that's one sweat actuator, I've filed it for later.


Rob

tjbaudio:
Assuming you are using the servo only version I would set up a function that works similar to fading an LED. Adjust the fade rate to the servo speed. That way the servo is never very far from the set point. Depending on load, precision and speed this may need some tweaking.

Can you further elaborate? I think I get what you're saying but I may be wrong. Are you suggesting I move the servo in "steps" in which I can keep track of the position? The problem is that it cannot be time dependent, like as you mentioned, unfortunately in my case the load will vary almost every time.

R/C servos were never designed to operate with no signal input pulses yet with power still applied. Their behavior in that condition is not defined, and may even very between manufacures and models of servos.

It's as if the servo detach function is a solution looking for a problem. I haven't yet seen a example that justifed is useage, but then again I'm an old hardware guy and don't claim ultimate wisdom on how useful any given function might be.

Lefty

Graynomad:
It may just shut the class down but not stop the timer generating the pulses.

I'm thinking that may be the case. I never tried pulling the wire out because I assumed using detach would do that for me. I'll try tomorrow in lab.

The actuators are pretty sweet. Thing is, this is for a senior design project, funded by the university. I get to keep whatever we don't use... accidentally ordered an extra pair 8)

retrolefty:
R/C servos were never designed to operate with no signal input pulses yet with power still applied. Their behavior in that condition is not defined, and may even very between manufacures and models of servos.

Lefty

Yea, not sure why it keeps moving even without a signal input pulse. Any other suggestions? Should I just set up something to cut off the power?

Should I just set up something to cut off the power?

A bit drastic but maybe.

The trouble is what happens when you re apply the power? Or maybe that doesn't matter to your application.

Anyway let's see if the pulse train stops after detach first, if not then there should be a software method to make it do so. If the pulses stop but the actuator continues on it's merry way then maybe drastic action is called for :slight_smile:


Rob

Anyway let's see if the pulse train stops after detach first,

From the servo lib: detach() - Stops an attached servos from pulsing its i/o pin.

Actually a little awkwardly worded as the signal to a servo is a input so the servo can never 'Pulse it's i/o pin'?
But it's pretty clear that detach stops sending any pulses to an attached servo.

Lefty

Yea, going out of the way just to cut off the power does seem a little drastic especially for such a simple request. Well see...

Just to be clear:
signal pulse = movement
detach = no signal pulse
therefore no movement

Standard for servos correct? How do the pulses actually control the different positions?

Never mind, read up on it here:

http://www.servocity.com/html/how_do_servos_work_.html

But I am still assuming that once the pulse stops, it is stuck at the last position?

As Lefty says, "Their behavior in that condition is not defined" so I guess all bets are off. Another logical option would be to return to the center position.


Rob

Graynomad:
Another logical option would be to return to the center position.

If by center position, in my case, you mean between fully extended and retracted then that's what I currently have it setup to do. But I really need it to stop at the current mechanical position.

Also, I read up that some digital servos remember the last set position and continue to move to that position even if the pulse is cutoff. That appears to be my situation. Looks like I will have to cut the power off and assume everything will act normal when re-powering. Any ideas on how to set that up?

But I really need it to stop at the current mechanical position.

The problem is that the software has no true feedback from the servo as it it's actual position at any given instant, especially if it's activly moving from one position to the another. That datasheet shows that the actuator does have an optional 3 wire feedback pot avalible. If you could retrofit that option and by wiring that to a arduino analog input pin you would always have a true position feedback mechanism that could go a long way to solving your needs. With no need for a detach kluge.

Lefty

Looks like I will have to cut the power off and assume everything will act normal when re-powering. Any ideas on how to set that up?

Did you actually try disconnecting the signal wire and verify the actuator continued to move or stopped moving? Just curious as I have a pair of continous rotation servos connected to my arduino and always powered up, and they don't move or do anything when I'm not sending them a control signal. Connected up a regular servo, and it also acts like it isn't connected to a servo controller. Just wondering if we are still just "hanger flying" on the no signal subject.

It looks like they only draw 200-450mA max so a large transistor or small relay would do.

If you're dead lucky the servo will do nothing on power up and therefore stay where you left it.


Rob

What are these things doing? If they can run slower then use my fade method and just move them at the slowest anticipated speed. Can you add a pot to them so the arduino can know the current position? Can you order another one with simple motor and pot interface?

Thanks guys for the replies. Pulled the pin and it kept going. Unfortunately don't have time to interface with a pot or order a new one.

The load varies greatly because it is used to lift objects of different weight.

Graynomad:
It looks like they only draw 200-450mA max so a large transistor or small relay would do.

If you're dead luck the servo will do nothing on power up and therefore stay where you left it.


Rob

Can you explain how I can hook up a transistor like an electronic switch to control the power?