User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Let me get this straight about servos & motors...

Fri Nov 08, 2013 8:24 am

So, a motor can turn around an infinite amount of times, and a servo can turn up to 360 degrees, noo more (but it can turn backwards to 0). Right?
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

achrn
Posts: 373
Joined: Wed Feb 13, 2013 1:22 pm

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 8:38 am

By default, for common sorts, yes.

But you can easily modify servos to carry on indefinitely - it's a good way to get a compact highly-geared motor. Also some specific servos come out-of-the-box doing more than one revolution (sail winch servos for radio control sailing boats, for example, can often do 6 turns).

The main difference is that by default a servo runs to a position and then stops. The servo needs a power supply and a position signal (in normal RC, a PWM signal). A motor just runs, but only needs a power supply.

(I'm assuming you don't want to talk about stepper motors, which do run to a position then stop, but the position is just a few degrees further than they are now, and they can keep doing that indefinitely).

User avatar
joan
Posts: 14089
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 8:39 am

mrpi64 wrote:So, a motor can turn around an infinite amount of times, and a servo can turn up to 360 degrees, noo more (but it can turn backwards to 0). Right?
No.

A DC motor can rotate continuously clockwise and anti-clockwise.

A servo generally rotates between end stops which limit its continuous rotation to between something like +100 to -100 degrees from centre. The degrees from centre can be accurately set by using the pulse width (generally 1 to 2 millseconds) sent via its control wire.

Servos can be modified to be continuously rotating (by a hardware change). Then the pulse width sets the servo's speed and direction of rotation.

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 1:57 pm

Do servos normally return back to their original position without prompt?
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
Mortimer
Posts: 923
Joined: Sun Jun 10, 2012 3:57 pm

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 2:16 pm

Generally they don't. If the PWM signal stops or doesn't meet specification, the servo motor controller stops working. They usually require something like PWM pulse every 20ms. The length of the pulse will determine the desired servo position, usually ranging from 0.5ms to 1.5ms, with 1ms indicating centre.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

User avatar
Burngate
Posts: 5934
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 2:24 pm

A servo is merely a motor with feedback, so it depends very much on how that feedback works as to what it does.

As far as I can see, most servos on sale seem to be fitted with a pot for sensing position.
If it also has a spring to return it to "home", then it will go back.
Also, if you remove the input signal the feedback electronics may assume you want it to return to "home".
Or it may not.

Of course you may have a servo that senses speed rather than position, so it will go until you tell it to stop.

User avatar
joan
Posts: 14089
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 2:29 pm

Burngate wrote:A servo is merely a motor with feedback, so it depends very much on how that feedback works as to what it does.

As far as I can see, most servos on sale seem to be fitted with a pot for sensing position.
If it also has a spring to return it to "home", then it will go back.
Also, if you remove the input signal the feedback electronics may assume you want it to return to "home".
Or it may not.

Of course you may have a servo that senses speed rather than position, so it will go until you tell it to stop.
I have never seen a servo fitted with springs or firmware to return to a neutral position if the pulses are stopped.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 3:24 pm

Servos come in all kinds. Most are controlled by PWM, and most have a stop to prevent complete rotation, though continous rotation servos are comon as well, often for around $13USD for a continous rotation servo with a maximum speed of 50RPM and a torque of around 30oz/inch. Or you could also look at continous rotation servos that have speeds up to 180RPM for about $20USD. Of cource if you need more torque than that you will spend more. Such as a 10lb/inch servo that I use costs $45USD.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

achrn
Posts: 373
Joined: Wed Feb 13, 2013 1:22 pm

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 3:55 pm

Mortimer wrote:Generally they don't. If the PWM signal stops or doesn't meet specification, the servo motor controller stops working. They usually require something like PWM pulse every 20ms. The length of the pulse will determine the desired servo position, usually ranging from 0.5ms to 1.5ms, with 1ms indicating centre.
My (slightly elderly futaba) gear works with pulses at 54.3Hz with a pulse duration between 1.0 and 2.0 mS (ie, 0.5mS offset from the figures you've quoted).

I've written PIC assembly code that drives servos (decent futaba and less decent nameless chinese ones) with various frequencies - you don't need to be very close to 50Hz. My most complex setup generated the servo pulses at 48.8Hz and worked flawlessly.

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 5:17 pm

Burngate wrote:A servo is merely a motor with feedback, so it depends very much on how that feedback works as to what it does.

As far as I can see, most servos on sale seem to be fitted with a pot for sensing position.
If it also has a spring to return it to "home", then it will go back.
Also, if you remove the input signal the feedback electronics may assume you want it to return to "home".
Or it may not.

Of course you may have a servo that senses speed rather than position, so it will go until you tell it to stop.
I think that the spring thing might be the problem. No worries. Hmmm, I might unscrew it, to see the inside. Good idea or bad?
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

achrn
Posts: 373
Joined: Wed Feb 13, 2013 1:22 pm

Re: Let me get this straight about servos & motors...

Fri Nov 08, 2013 6:55 pm

mrpi64 wrote:Hmmm, I might unscrew it, to see the inside. Good idea or bad?
You can if you want.

You'll find a plastic gear-train, a small dc motor and a small circuit board (unless it's an expensive and/or special servo). The circuit board has a feedback system that compares the output from a potentiometer to the incoming pulse train. Pay attention to what you're doing and it should still work when you put it back together.

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Let me get this straight about servos & motors...

Mon Nov 11, 2013 11:09 am

achrn wrote:
mrpi64 wrote:Hmmm, I might unscrew it, to see the inside. Good idea or bad?
You can if you want.

You'll find a plastic gear-train, a small dc motor and a small circuit board (unless it's an expensive and/or special servo). The circuit board has a feedback system that compares the output from a potentiometer to the incoming pulse train. Pay attention to what you're doing and it should still work when you put it back together.
Ok. One final question- if I physically turn it when it's not connected to anything, will it try to reset itself when a signal is given.
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
joan
Posts: 14089
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Let me get this straight about servos & motors...

Mon Nov 11, 2013 11:45 am

The servo will move to the commanded position (determined by the pulse width). That is unless you have forced it to turn too far and have stripped its gears.

http://en.wikipedia.org/wiki/Servo_%28radio_control%29

achrn
Posts: 373
Joined: Wed Feb 13, 2013 1:22 pm

Re: Let me get this straight about servos & motors...

Mon Nov 11, 2013 11:54 am

mrpi64 wrote: Ok. One final question- if I physically turn it when it's not connected to anything, will it try to reset itself when a signal is given.
I don't understand exactly what you are asking.

If you connect the power and ground lines and leave the PWM signal wire floating, I don't know what it will do - it probably depends upon the detail of the circuit embedded within it and possibly varies according to manufacturer. My guess is that it will either stay stationary, or move to one limit of travel, or jitter randomly. Since that about covers all options it's not a useful guess. Try it and see, and be ready to disconnect the supply if bad things happen.

When you do connect a PWM signal, it will move to the position indicated by the signal, irrespective of what it was doing or where it was beforehand. The PWM signal indicates an absolute position - it doesn't matter what happened previously, every time the servo receives a PWM signal it tries to move to the position implied by the signal. It may get another pulse before it gets there, but it just starts again - trying to get to the position described by the latest pulse.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Let me get this straight about servos & motors...

Mon Nov 11, 2013 1:30 pm

One thing to consider - the servos I've seen can be turned by hand with the power off (be careful not to damage them though.) However when the model is switched on, the software or controller has to start with the servo set to go to some position. If the servo isn't already at that position, it will jump rapidly to it.

So when switching on, you might see a twitch of the servos as they all jump to their start positions. This may or may not be a problem for you. (Very complicated to get around this problem reliably, such as in an industrial robot arm or something.)

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 8:31 am

Ok, so I twist it with my hand. I connect it to an Arduino, and tell it to turn to 45 degrees. I give it half a second to do that. In the remaining time after it has reached it's goal, it suddenly starts turning back towards its starting place. Until the Arduino tells it to turn back to 40D.
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

achrn
Posts: 373
Joined: Wed Feb 13, 2013 1:22 pm

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 8:50 am

No, because you can't just tell it where to go once. You need to tell it where to go 50 times a second, and keep telling it. If you send one PWM pulse and nothing more (ie stop telling it where to go), its performance is undefined and anything might happen.

The servo hardware needs a train of pulses, at about 50Hz. If you want it to go to 45 degrees for half a second you need to send the appropriate width pulse, then send it again 1/50 second later, then send it again 1/50 second after that and carry on for half a second. If you then stop, the behaviour is undefined, but if you want it to move to a different defined location, you need to send the relevant pulse, then 1/50 second later the relevant pulse again, and so on.

Just try it. It's probably quicker to try it than post the message here and wait for replies.

In my opinion, however, this sort of thing that relies on a simple, repetitive, timing-critical operation is better done on something other than a pi. An arduino might be a bit better, but when I implemented it myself I did it in assembler on PIC, because then you get control of your timing at a clock-cycle resolution - http://www.astounding.org.uk/ian/hovercraft/mixer.html If you want to control servos it might be better to put some dedicated hardware between pi and servo to do the timing.

mikerr
Posts: 2770
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 9:17 am

I' d stop thinking about forcing a servo by hand - plastic gears are easily broken that way.

User avatar
joan
Posts: 14089
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 9:24 am

achrn wrote:...
In my opinion, however, this sort of thing that relies on a simple, repetitive, timing-critical operation is better done on something other than a pi. An arduino might be a bit better, but when I implemented it myself I did it in assembler on PIC, because then you get control of your timing at a clock-cycle resolution - http://www.astounding.org.uk/ian/hovercraft/mixer.html If you want to control servos it might be better to put some dedicated hardware between pi and servo to do the timing.
There are plenty of modules/libraries on the Pi which provide accurate pulses. In my opinion they can be better than an Arduino.

Good job on the hovercraft.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 9:25 am

I always thought that, on an Arduino or whatever other controller, there is always a background thing running that re-sends the servo pulse every 50ms. So you set the servo position you want, and can set it any time, but the controller automatically sends the refresh pulses for you. (I've only used servos on a picaxe, but most other controllers should do the same.)

These days some fancy modern servos might be capable of remembering the last pulse and holding that position, if pulses stop. The constant pulses are really needed because in the early days the electronics were pretty primitive and everything was based on analogue electronics, which have no memory to speak of.

And yes as mikerr says, don't ever try to stop a servo while powered (as I said before). The gears can be damaged or the electronics, cramped in that tiny case, might even overheat. They can usually be turned by hand, carefully, with the power off - but don't do that unless necessary, like when bolting them into place.

achrn
Posts: 373
Joined: Wed Feb 13, 2013 1:22 pm

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 11:32 am

Ravenous wrote:I always thought that, on an Arduino or whatever other controller, there is always a background thing running that re-sends the servo pulse every 50ms. So you set the servo position you want, and can set it any time, but the controller automatically sends the refresh pulses for you. (I've only used servos on a picaxe, but most other controllers should do the same.)
That clearly depends on how the 'background thing' has been created. If it's just a basic bare microcontroller that doesn't have PWM generators, clearly not. If it's a sligfhtly more capable one that has PWM implemented in the hardware (and you're using it), clearly yes. With a pi, presumably it does if you're using a specific PWM library but not if you're bit-banging GPIOs for yourself.
Ravenous wrote:These days some fancy modern servos might be capable of remembering the last pulse and holding that position, if pulses stop. The constant pulses are really needed because in the early days the electronics were pretty primitive and everything was based on analogue electronics, which have no memory to speak of.
My understanding is that the whole discussion has an over-arching caveat along the lines of "assuming you're talking about ordinary / cheap / old (pick any one) servos". I agree a modern digital servo with embedded microprocessor might do almost anything. If I were implementing it I might have it hold last requested position for a short while, then a slow move to a defined safe (or park) position. Or I might not. What the manufacturer implements on actual servos bought in a shop, I have no idea.

Ravenous
Posts: 1956
Joined: Fri Feb 24, 2012 1:01 pm
Location: UK

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 1:30 pm

Quite right. The "Background thing" I vaguely mentioned is because if Mrpi is going to use an arduino (servo library) or raspi (servoblaster or alternative) then the library will handle the repeat pulses for him. It's only necessary to set a value when a change is required (and perhaps an initial angle when the program starts up - the servo may jump at switch-on, which is what I think he wanted to know).

In the case of a bare microcontroller like your mixer example (nice hovercraft by the way!) the programmer needs to take care of all those pulses by himself and it all gets a bit college-level. :?

I've also heard that some servos go a bit inaccurate if the pulses aren't arriving every 50 milli seconds, while some are the opposite and tolerate pulses that go astray for quite some time. Most of this shouldn't matter if decent servo software is available of course...

User avatar
mikronauts
Posts: 2709
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: Let me get this straight about servos & motors...

Wed Nov 13, 2013 3:22 pm

No.

If you stop sending the control pulse:

- a standard servo will stay in the last position it was in (unless weight on the servo horn drags it down)
- a continuous rotation servo will stop turning
mrpi64 wrote:Do servos normally return back to their original position without prompt?
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

JohnAdriaan
Posts: 9
Joined: Wed Nov 02, 2016 11:50 am

Re: Let me get this straight about servos & motors...

Wed Nov 02, 2016 11:53 am

Sorry to resurrect an old thread, but above there are two different timings specified:

One set of posts say 50 Hz (which is 20 ms), while others say 50 ms (which is 20 Hz).

I also note that different servos use different timings, and that the timings are not absolutely critical - but which is the most common?


Return to “General discussion”