### Author Topic: How to stop a continuous rotation servo?  (Read 12045 times)

0 Members and 1 Guest are viewing this topic.

#### Eithman1

• Jr. Member
• Posts: 9
##### How to stop a continuous rotation servo?
« on: April 21, 2013, 11:03:01 PM »
I have modified a continuous rotation servo but even after I exit where it is being sent a pulse, it continues to go in that direction. Other than transistors or something physical, is there any way I can just stop the servo after a set amount of time in the code? Any help would  be really appreciated. Thanks!

#### newInRobotics

• Supreme Robot
• Posts: 1,015
• N.I.R.
##### Re: How to stop a continuous rotation servo?
« Reply #1 on: April 22, 2013, 12:31:05 AM »
To stop it You have to set its speed to 0.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

#### Eithman1

• Jr. Member
• Posts: 9
##### Re: How to stop a continuous rotation servo?
« Reply #2 on: April 22, 2013, 10:56:04 AM »
Ive read that sending a Pulse Width of 1.5 ms will stop it. But it did not give any example code on how to achieve this. I can not find any on google either. Could anyone please give me an example code of how to do this or a link to one. I would really appreciate it. Thank you!

#### jkerns

• Robot Overlord
• Posts: 270
##### Re: How to stop a continuous rotation servo?
« Reply #3 on: April 22, 2013, 12:19:19 PM »
You modified a "standard" servo for continuous rotation?

You are sending a pulse now, right? So you should already have the code you need to send the pulse, right?

Large pulse widths cause it to rotate one direction, small pulse widths cause it to rotate in the other direction and somewhere in between it will (nearly) stop. Exactly what pulse width will make it stop will depend on where you set the potentiometer in your servo. A simple experiment with different pulse values would be in order.

I get paid to play with robots - can't beat that with a stick.

http://www.ltu.edu/engineering/mechanical/bachelor-science-robotics-engineering.asp

#### Duane Degn

• Jr. Member
• Posts: 40
##### Re: How to stop a continuous rotation servo?
« Reply #4 on: April 22, 2013, 03:47:53 PM »
I can not find any on google either. Could anyone please give me an example code of how to do this or a link to one.

It would help to know what microcontroller you're using.

As jkerns suggests, sometimes the pulse length needed to stop a CR servo isn't exactly 1.5ms. Depending on how you modified the servo (it might be a good idea to tell us) you can use the potentiometer to set the zero point while the uC is sending its 1.5ms pulse. If you used the two resistor technique the pulse length needed to stop the servo may not be exactly 1.5ms. In this case, you'd need to find the right pulse length by trial and error.

Servo need a pulse every 20ms whether or not they are moving. Depending on the uC and servo library you're using, these refresh pulses may be taken care of for you in the background.

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #5 on: April 28, 2013, 10:37:06 PM »
actually has little to do with the mcu and 1.5ms rarely works to stop a servo. removing pulses entirely is the best method. most srvos will stop dead.

#### Duane Degn

• Jr. Member
• Posts: 40
##### Re: How to stop a continuous rotation servo?
« Reply #6 on: April 29, 2013, 11:03:41 AM »
actually has little to do with the mcu and 1.5ms rarely works to stop a servo. removing pulses entirely is the best method. most srvos will stop dead.

It has a lot to do with the microcontroller. Some uCs pulse the servos in the background and you have take action to turn the pulsing off.

1.5ms will always stop a CR servo that has been properly adjusted with a trim pot. Many servos jitter pretty bad when they don't receive a pulse on schedule but I haven't tested completely stopping the pulses.

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #7 on: April 29, 2013, 05:44:09 PM »
as a developer of radio control products ive collected over 40 different models of rc servos (towerpro, turnigy, gws, etc) and about half of them converted to continuous rotation. in no case did i experience jitter when removing pulses. however jitter is 100% a problem with 1.5ms pulse. and with the slightest change in temperature or voltage like battery dropping it almost always starts turning one way or the other. slowly at first then picks up speed with time. was never able to adjust this out with trimmer and fixed divider even worse.

this is just my experience. i suppose its possible there are exceptions but  hard to believe with the limited number of servo ics out there.

#### Duane Degn

• Jr. Member
• Posts: 40
##### Re: How to stop a continuous rotation servo?
« Reply #8 on: April 30, 2013, 12:18:40 PM »
Well that's something I didn't know. I've just seen so many programs with misbehaving servos caused by not supplying the servos with a 50Hz pulses. It just seems wrong to me not to send any pulses. It sounds like you've done this with a greater variety of servos than I have so I'll take your word for it.

It still just seems wrong to starve the poor servo of its refresh pulses but if it will turns off the servo, it's a lot easier than trying to add a relay.

#### jwatte

• Supreme Robot
• Posts: 1,345
##### Re: How to stop a continuous rotation servo?
« Reply #9 on: April 30, 2013, 01:10:17 PM »
Hobby servos are designed to stop applying torque if they lose the controlling pulse. This is a safety feature for when a transmitter is turned off or goes out of range, for example. All servos I've used have behaved like this. You may also have experienced this: If you power on a servo before you provide a pulse to it, it will not apply any power!

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #10 on: April 30, 2013, 02:28:09 PM »
there is no such thing as starving servos. 50hz (20ms) is a myth. for example its impossible for an avr/arduino type chip to supply 20ms frame rate with any useful degree of pulse resolution using oc pwm. so 4ms is in fact the typical frame rate to get 64 or 128 steps and the servos work fine with that short a refresh. maximum fame rate can also be much longer than 20ms. 0.1hz (10 seconds) for example because it tends to hold the position dictated by the last pulse.

as far as torque an unpowered servo has plenty. iits almost impossible to rotate the arms on a high torque/low rate servo without damaging it. stalled or jarred control surfaces are the #1 reason for stripped gears. not wear or other mysterious forces. a robot will stop instantly when power or pulses are removed and its wheels will appear to be locked. solid.

researching servo ic data sheets or just playing with them on the bench for a few minutes under the conditions described will reveal the truth. imo removing pulses is not only the best but actually the only way to stop a robot completely.

#### jwatte

• Supreme Robot
• Posts: 1,345
##### Re: How to stop a continuous rotation servo?
« Reply #11 on: April 30, 2013, 07:48:05 PM »
Quote
its impossible for an avr/arduino type chip to supply 20ms frame rate with any useful degree of pulse resolution

Interval between pulses has little to nothing to do with actual pulse width and precision.

If you use a single 16-bit timer to do both the interval (dead time) AND the pulse width, then yeah, you'd have that problem. So, don't do that!

I control 8 servos with better-than-microsecond resolution and a choice of pulse rate from 10 ms to 100 ms. The trick is in how you generate the PWM across the output port, and disabling interrupts while the pulses are going out in parallel (and thus turning off interrupts for up to 2 milliseconds at a time.) The 16-bit timer is used as a clock source only during this time; pins are written high/low using PORT output writes.

I recall hobby transmitters using 30 ms intervals back in the days, so I don't know where 20 ms come from. My guess is that any duty cycle up way past 50 ms would work before servos start losing sync. However, at some point, a hobby servo will stop applying torque if you stop feeding it pulses.

Quote
as far as torque an unpowered servo has plenty

Friction != torque

Quote
removing pulses is not only the best but actually the only way to stop a robot completely

Here we agree!

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #12 on: May 01, 2013, 10:37:25 AM »
unfortunately because of througput and isr latency issues im forced to use timer oc exclusively in my applications. 0% cpu involvement. too much going on to waste interrupts on servos/motors.  even the 8 bit do a great job on my tiny24, mega8, mega328, and mega1284 projects. i am a great fan of servos for motors as lowest cost and easiest way to implement robot locomotion.

friction/torque, whatever you choose to call it that puppy aint gonna roll downhill. or budge at all for that matter.

#### Duane Degn

• Jr. Member
• Posts: 40
##### Re: How to stop a continuous rotation servo?
« Reply #13 on: May 01, 2013, 09:41:28 PM »
there is no such thing as starving servos. 50hz (20ms) is a myth.

What? Analog servo only receive power during a pulse. If pulses are spaced out too much the servo will loose it holding power.

a robot will stop instantly when power or pulses are removed and its wheels will appear to be locked. solid.

Again, what? My hexapod slumps to the ground without power (or pulses). My CR servos (10kg*cm) turn relatively easily without power. Given, it's not likely to roll down a gentle slope but I sure wouldn't describe it as "locked. solid". I've heard of unpowered servos being used as a type of dampened bearing since it resists but doesn't completely stop movement.

I don't know how well Arduinos do with multiple servos but a Propeller (my favorite uC) can drive 32 with 1us resolution using one of its eight "cogs" (aka processor). Here's a video I did showing off the Propeller.

QuickStartControlling32Servos120129.AVI

#### jwatte

• Supreme Robot
• Posts: 1,345
##### Re: How to stop a continuous rotation servo?
« Reply #14 on: May 01, 2013, 11:23:46 PM »
Quote
What? Analog servo only receive power during a pulse. If pulses are spaced out too much the servo will loose it holding power.

That's not how it works, actually...

The canonical analog servo circuit I'm familiar with charges a capacitor with the input pulse. The longer the pulse, the higher the charge on the capacitor. The capacitor slowly discharges through a resistor.

Separately, the voltage out of that capacitor is compared to the voltage divider made up by the position sensing potentiometer. This could use a comparator circuit, or an opamp. When the comparision is too high one way, the motor is made to spin the appropriate counteracting direction. In old-school, fully analog servos, that might conceivably be as simple as the opamp output driving the bases of two power transistors (one NPN and one PNP) to drive the motor one way or the other.

If you remove the pulses, the capacitor will slowly discharge, and the servo will turn towards zero.

When I was a kid, and radio controlled airplanes and cars were pretty new (we're talking '70s here,) I vaguely recall friends having servos that lost trim as the battery lost voltage. That's a direct effect of the charge/discharge capacitor implementation of the pulse demodulation circuit! (Myself, I couldn't afford one of those toys at the time; this was *way* before cheap microcontrollers and Chinese manufacturers.)

Now, once integrated circuits entered the picture, the analog design in this system had to be emulated for compatibility. So, even with modern, digital, servo driving circuits, there is some time, after which, the motor drive will be turned off if no additional pulse has been received. These modern chips will not generally emulate the behavior of slowly turning to 0 when the pulse is removed, though, and I think this is for the better!

So, the sentence above is not correct. The width of the pulse decides the goal position that the control logic will seek. The presence of the pulse starts a timer, and the motor/logic in the servo will keep trying to achieve the last-set goal position, until that timer expires. Thus, saying that "analog servo only receive power during a pulse" is not particularly accurate IMO. A servo will energize its motor when it receives a pulse, and for some amount of time after the last pulse was received. That time is not standardized, and may be in the 50 ms to 1000 ms range perhaps. Thus, if a servo has a 50 ms timeout, and you send it pulses every 52 milliseconds, the servo will actually repeatedly turn on/off, which will reduce the output torque, and will probably cause stuttering when trying to hold a position against a counterforce.

Now, the sentence *could* be accurate in a certain circumstance. A possible implementation of a servo using PWM involves using a voice coil, a retracting spring, and a mechanical damper. The voice coil would only be powered when the pulse was high, and the spring/damper/coil system would approximate a particular average position over time. That servo would be pretty crude, and would "hum" at the speed of your pulses. I haven't actually seen any servo built that way, but the world is a large place, so maybe it exists :-)

Quote
a robot will stop instantly when power or pulses are removed and its wheels will appear to be locked

Here I agree with Duane: That's simply not the case. A gear motor that has no power applied will not exert any torque, one way or the other. However, the friction involved in spinning the gears, especially for high-gear-ratio (== high torque) servos, can be significant. For some hobby servos, you'll actually break the output gear before you manage to move the inert motor through the gear box. Personally, I find that to be a poor choice of design parameters for the system. However, you will only see "wheels locked" as an apparent effect of the passive mechanical losses in the gearbox; a servo motor without power does not actively exert torque one way or another. A high-quality gear box with low losses will let you turn the powered-off servo pretty easily.

I don't understand why there are so many half-truths and weird understandings of how servo motors and their control pulses work. The systems are very simple, and reasonably well documented. Anyone who has a basic understanding of electronics and mechanics can find out the truth pretty easily.

#### Duane Degn

• Jr. Member
• Posts: 40
##### Re: How to stop a continuous rotation servo?
« Reply #15 on: May 01, 2013, 11:42:51 PM »
My reading of Futaba's pdf lead me to believe analog servos gets a shot of power once per pulse with the amount of power being proportional to how far off target the position of the servo is with respect to the target position.

Is my understanding of the pdf incorrect or is the Futaba's description of how servos work incorrect?

Here's a link to the pdf.

http://www.futaba-rc.com/servos/digitalservos.pdf

Edit: I see I didn't word my description very well. Yes, power isn't only applied during the pulse but the pulse triggers the application of power to the servo. If the refresh frequency of the pulses sent to the servo is reduced the amount of power to the servo is reduced. (I think jwatte and I agree on this.)
Instead of saying "Analog servos only receive power during a pulse", I should have said "Analog servos only receive power when they receive a pulse". When fewer pulses are received, the servo receives less power, thus "starving the servo".

Again, this applies to analog servos. Digital servos how their own uC and send a continuous PWM to the servo's motor.
« Last Edit: May 01, 2013, 11:54:07 PM by Duane Degn »

#### Duane Degn

• Jr. Member
• Posts: 40
##### Re: How to stop a continuous rotation servo?
« Reply #16 on: May 02, 2013, 12:00:40 AM »
For some hobby servos, you'll actually break the output gear before you manage to move the inert motor through the gear box.

Do you have an example in mind? I probably have a dozen or so different models of servos but I have never found one that wont let you turn the motor my turning the servo horn. One does need to start moving servos slowly (and some very slowly) but I haven't found a servo that wont move at all.

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #17 on: May 02, 2013, 11:26:14 AM »
there are "old world" brand servos and then modern mainstream chinese "micro" servos which, in terms of sales and manufacturing, outnumber the former 100:1. i do have some old oddball types but 99% of my stock purchased last few years (hextronic, towerpro/tpro/tp, gws, turnigy, corona, hk, em, bms, vigor, bluearrow, etc) are based on aa51880 or clones.  they behave similarly and as ive described above. one way to tell whether its old or new tech is to look throught the plastic shell.  if you see transistors or other discrete components then this is not the modern rc servo referred to here.

if you remove pulses it does not move to zero or any other extreme. it simply stops and in addition resists further efforts to rotate. just because it is unpowered does not mean the arm now moves freely. depending on the speed you try to force it and gear ratio theres a good chance it will strip. as i mentioned before this is the main reason they fail in real world use. control surfaces jamed or jarred cause stripped gears. very few actually "wear out" or sustain electrical failure.

i highly recommend picking up a few cheap (\$2) generic units from places like dealextreme, hobbypartz, aliexpress, hobbyking,  or ebay and playing around with a servo tester . the testers are only a couple bucks or you can throw one together in few minutes with pic or avr. you will quickly see how the majority of modern servos behave in regards to torque/friction and removed pulses.

im sure if cantilevered far enough some servos can be made to sag or break. but in terms of sumo, tank, or other wheel robots my suggestion to stop by removing pulses is good advice with no undesirable side effects.

#### jwatte

• Supreme Robot
• Posts: 1,345
##### Re: How to stop a continuous rotation servo?
« Reply #18 on: May 02, 2013, 12:30:40 PM »
For some hobby servos, you'll actually break the output gear before you manage to move the inert motor through the gear box.

Do you have an example in mind? I probably have a dozen or so different models of servos but I have never found one that wont let you turn the motor my turning the servo horn. One does need to start moving servos slowly (and some very slowly) but I haven't found a servo that wont move at all.

Mainly, the problem is when you try to apply force too quickly. Typically, this happens when colliding with something, rather than when trying to turn by hand.
Also, if you overheat servos, parts of the motor may expand and get out of alignment, so the motor has more internal friction, and if the gear ratio is high enough, you won't be able to turn it manually from the output spline.
I've managed to do that to some Dynamixel MX-64s, which was not a fun experience :-/

When it comes to "remove pulses, and the servo stops," I think we are all actually meaning the same thing, and just discussing the accurate description of how it works.
If you stop providing pulses to the servo, then after some timeout (50 ms, 500 ms, whatever) then the servo motor will stop providing any torque, and the only forces acting on the output will be friction in the motor and gearbox. For strong enough servos and/or small enough robots, that friction may very well be sufficient to stop the robot and hold it in place, unless someone pushes it hard; especially on a flat surface.

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #19 on: May 02, 2013, 02:42:54 PM »
I've managed to do that to some Dynamixel MX-64s, which was not a fun experience :-/

yes, i managed to strip a couple of blue arrow 2.5g that way back when they were \$20 a wack. now we can get 1.7 gram digital servos for 1/6th that price. i do find these devices one of the most interesting aspects of buidling small robots. other interesting discussions might deal with how to modify for continuous rotation and also providing optical or hall position feedback. imo robots, like rc models, are among the most fun and educational hobbies. it seems to mix so many interesting technologies.

#### Duane Degn

• Jr. Member
• Posts: 40
##### Re: How to stop a continuous rotation servo?
« Reply #20 on: May 02, 2013, 04:31:02 PM »

I've managed to do that to some Dynamixel MX-64s, which was not a fun experience :-/

Ouch! I've only used Dyanamixel AX-12+ servos and I thought those were expensive. It would not be fun to damage such a nice servo.

I think we are all actually meaning the same thing, and just discussing the accurate description of how it works.

But if we all described it the same way we wouldn't have the fun of arguing about it.

i do find these devices one of the most interesting aspects of buidling small robots. other interesting discussions might deal with how to modify for continuous rotation and also providing optical or hall position feedback. imo robots, like rc models, are among the most fun and educational hobbies. it seems to mix so many interesting technologies.

Amen, brother!

Robots are a really fun way to learn about electronics and physics.

I've been working on some PCB designs to use AS5055 magnetic encoders inside the metal gear HobbyKing servos (I think they'll fit inside most standard sized servos). I think I can get the board as small as the original pot. I'd still need to work how to mount a magnet to the final gear but it would be pretty cool to have a CR servo with 12-bits of position resolution.

Here's one of my videos about the encoders.

MagneticEncoderDaisyChain120323a.AVI

Edit: What ever happened to Eithman1?
« Last Edit: May 02, 2013, 04:38:14 PM by Duane Degn »

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #21 on: May 03, 2013, 06:16:25 AM »
i used really tiny opto interruptor from digikey and bit of foil on the brass motor pinion. in addition to ultra precise robot positioning it turns out you can use this to "fine tune" the 1.5ms method for stopping servos. the 1.5ms time can be adjusted periodically to compensate for drift due to temperature and voltage changes. however once i discovered the no pulse trick there was no need for such electrical, mechanical, and code complexity.

now i use the disconnected pot for position control sensor only.

#### idee17

• Full Member
• Posts: 71
##### Re: How to stop a continuous rotation servo?
« Reply #22 on: May 24, 2013, 07:11:22 PM »
Can't you hold a servo by reading the current postion its then use a interrupt when it changes postion then resend the position it is supposed to be? This could be done with a servo that has feedback systems or setup a encoder the the servo.
There are 10 types of people in the world: those who understand binary, and those who don't.

#### johnwarfin

• Full Member
• Posts: 120
##### Re: How to stop a continuous rotation servo?
« Reply #23 on: May 25, 2013, 07:39:54 AM »
yes, if you dont mind a constanly buzzing servo and a battery that dies well before its time. however the method i just described in the previous post accomplished this without those drawbacks.

• Full Member
• Posts: 71