How does a servo work (PWM or PPM)?

Avoiding references to PWM controlling servos should help reduce confusion with the output from analogWrite, so I will continue to evangelize the use of PPM to refer to servo signals.

And after that battle is won (if ever), maybe we can take on my next biggest complaint with Arduino vocabulary. Why in the world did someone chose the word analogWrite for the function that outputs a PWM output signal? Why was it not properly called pwmWrite?

Yes I know if one, using external components, low pass filters a PWM output signal, one can extract a analog voltage, but I'm sure the confusion and misunderstanding for newcomers to the Arduino world, often just learning hardware and software fundamentals, makes for additional road bumps in their learning curve.

No, Joe, it doesn't really output an analog voltage, but it kind of can, if you do some stuff and don't think too hard about it. :wink:

I recommend that for version 18 they announce that they have decided to eliminate the analogWrite command, but also announce that they will then replace it with a new and improved pwmWrite command. :wink:

Lefty

Hi Lefty,

I think there is a good case for keeping the name analogWrite even though pwmWrite would be more technically correct.

Arduino is primarily aimed at non technical users – people that want to do things with Arduino but are not engineers and are much more interested in the ends than the means.

For tasks like varying the intensity of an LED or moving the pointer of an analog meter, a function named analogWrite is more expressive than the more technically correct term.

I must strongly disagree. Establishing a meaningful and COMMON nomenclature is always a must for being able to communicate properly

Aniss, my point was that it is usually the case that understanding something is much more important than knowing its correct name.

However I'd still very much appreciate some input on the other part:

I would amend your summary on servos as follows:
4) A motor controller (typically an H-bridge)
5) a servo feedback circuit that reads the output position from the pot and drives the motor controller to correct deviation from the commanded position.

Mem and I may have to agree to disagree on the PPM vs PWM debate. I'm pretty sure the PPM references he supplies are talking about the radio side of things, which is not quite the same as the servo side.
I see the servo signal and "duty cycle modulation" as two different sub-cases of PWM, with PPM definitely involving a fixed-width pulse.

  1. A DC motor
  2. Some gears
  3. A potmeter
  4. A motor controler (also reffered to as a speed controller?)

The motor controller receives a signal (in our case from the Arduino) which tells the servo to move to a specific position. It then reads the current position from the potmeter and determines how much and in which direction the DC motor should be moved and sends an appropiate signal to the DC motor.

That sounds pretty close to me. A "speed controller" in the usual sense is a different beast. While some servos may vary the speed of the motor based on the amount of "error" from the desired position, most just generate a (nearly digital) "direction" signal (sign bit of the error, sort of.) that makes the power transistors in the H bridge have an easier job. (hmm. The newer "digital" servos may do a better job here, perhaps even generating PWM to the motor terminals to vary speed. But using transistors in linear analog mode to control motor speed is HARD.)

There was an old linear IC that used to be used in the guts of many servos, and the datasheet had a really good explanation of how the error signal was generated and used to control a motor. But I don't remember the part number, can't find it even in my historical databooks, and web searches are hopeless polluted by explanations of how to generate/use the PWM/PPM signal we've been talking about.

I'm pretty sure the PPM references he supplies are talking about the radio side of things, which is not quite the same as the servo side

They're exactly the same - in the Old Days an R/C receiver's decoder was simply a TTL counter, with the serial pulse stream from the RF connected to the counter's input and an RC circuit attached to the reset pin.
The servo PPM control pulses from the transmitter were sent sequentially in a frame with a long inter-frame gap; the gap was long enough for the RC circuit to trigger the counter's reset and so resync the link.
The output pins of the counter were connected directly to the servo control pins.

There was an old linear IC that used to be used in the guts of many servos, and the datasheet had a really good explanation of how the error signal was generated and used to control a motor. But I don't remember the part number, can't find it even in my historical databooks, and web searches are hopeless polluted by explanations of how to generate/use the PWM/PPM signal we've been talking about.

I think your talking about the Signetics NE544 chip.

Here is a article that has some of the data sheet info for the NE544 embedded.

http://www.seattlerobotics.org/encoder/200009/Servos.html

Put me down for calling it PPM :sunglasses:

Lefty

Hi Mem,

Point understood!

However I've been programming for many years (for fun and professionally) but frankly 6-8 weeks ago I barely knew what a circuit, microcontroller or a servo was. And it's been a very slow and painful process learning about these things. Not least because people use different terms for the same concept OR the same term for different concepts.

In that sense I very much agree with lefty that "analogWrite" should be called "pwmWrite". Simply because that's more correct but MAINLY because the term "analog" is allready reserved for an entirely different concept. The current mixup made it a lot harder (for me atleast) to understand the whole ordeal.

Besides even if 2 persons both understand a given concept it's still difficult to talk about it if they don't share a common nomenclature. If working as a programmer/systems developer has taught me anything it's that nomenclature is important, if not a must, for meaningful communication..

Hope you see my point too :slight_smile:

Thanks again for your input

Aniss

And just one more noob question...

The "servo feedback circuit" (that Mem mentioned) is that the same as/another term for/related to a PID loop/controller?

PS: Regarding PPM vs. PWM: I think I'll just reffer to it as SERVO SIGNALS from now on.. as a guy on the other forum suggested :smiley:

Hope you see my point too

I do see your point about using correct termonology, and if Arduino was primarily aimed at programmers/system developers then I would wholeheartedly agree.

But arduino is a platform intended for artists, designers and hobbyists. And although it is also highly attractive to trained software engineers like you and me, we should to be tolerant to the bending of some technical terms in the interests of making the technology more accessible to non-technical people.

I also take the point about potential confusion over the differences between analog inputs and analog outputs. But whatever you call the output function, the differences between changing the intensity of an LED and reading the intensity of a light source still needs to be adequately explained – things don't get any clearer to the non-technical person by renaming the function pwmWrite.

I can see many reasons why the analogWrite should not be changed to pwmWrite:

  1. (as mentioned in an earlier post) analogWrite is more expressive of the affect when driving things like LEDs. PWM has little or no meaning to non-technical people.

  2. It would increase the likelihood for confusion over its suitability for driving servos (particularly if people persist in referring to servo control signals as PWM).

  3. Even if there was a better name for analogWrite, so much material refers to that name (25,000 hits on google) that changing it would create considerable consternation.

On further thought, I think the main problem with PWM vs PPM is with the "M"; properly speaking, the servo control signal is not "modulated", it is merely "encoded." Especially as used by microcontrollers.

westfw, if you want the most technically correct term and I want the term that causes the least confusion among Arduino users, can we at least agree not to use PWM in relation to servo encoding signals on the grounds that the encoding is not based on modulating the proportion of on time to off time and has nothing to do with the PWM output from analogWrite and the current Arduino servo library does not use hardware PWM to produce the servo pulses.

Hi again Mem,

Just to round of the discussion..

Had some time to research the concepts "duty cycle" and "modulation" and I finally understood your explanation:

www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1253149521/6#6

I see you have a point that PWM may not be the appropriate term for describing servo signals/pulses. However I still don't see that PPM is any less wrong (as I've understood PPM). But let's leave it at that. I learned my lesson and it would seem that most people (on other forums) all agree to call it PWM anyway. Personally I'll call it servo signals/pulses from now on :slight_smile:

And you're right that it would cause too much confusion changing the name "analogWrite" since it's allready well established. But I still think it was a bad idea to call it that to begin with. And I don't think it's helping non-tecnical users to (mis-)label it "analog". For several reasons:

  • On the Arduino I/O's it still says PWM.
  • Non-tecnical people mostly don't really know what "analog" means anyway.
  • Even non-tecnical users may one day want/need to understand a bit more about how the "black box" (=Arduino) works. I suspect they (like me) may be confused by the (mis-)labeling.

So.. since "analog" is wrong and PWM is too tecnical perhaps "virtualAnalog" (or something like that) would have been the best choice. But it is off course irrelevant cause it's too late to change it.

Thanks for helping me better understand how a servo works (TO ALL). Now I'll move on with my endlessly expanding research todo list and read up on newly added concepts like: servo feedback circuit, H-bridge and PID-loop/controller...

Best wishes

Aniss

I know it's a dead horse and that there is no way the Arduino platform would ever change the wording from analogWrite() to pwmWrite().

However it's just not right and can't be helpful to newcomers to have two commands analogWrite() and analogRead() that have drastically different electrical characteristics. It isn't so difficult to learn for someone just starting to program, as much as if they are also new to electronics fundementals.

Now, where can I obtain a new horse. :wink:

Lefty

To be clear

  • PPM (pulse position Modulation) is a method of controlling multiple servos.
  • PWM( pulse width modulation) is the method by which a single servo is controlled.

-ppm is used to divide the clock of a timer into chunks that are used for each servo. Within each of those chunks of time you vary the time of an on pulse(pulse width) to tell that servo where to move.

-PWM is an incorrect term because you don't have to send a constant signal to a servo. I can send a 2.0ms pulse and then wait ten seconds before sending the next pulse and it won't hurt the servo. After a certain amount of time a servo just shuts off until i send it another signal. If i want it to stay on i have to send it pulses every "x" seconds which for rc servos happens to be 20 ms. If i do send signals every 20 ms then i am using PWM but if i send the signals at different times it isn't.

-ppm is absolutely incorrect terminology for controlling a single servo. It describes how to control when servo signals are sent when multiple servos are used.

-- The correct terminology then would be a PWM signal at 50HZ(20ms) with pulse widths varying from .5 - 2.0 ms controls a single servo and keeps it turned on. <-- this seems a little complex so i'll stick with PWM and analogwrite for now

One issue with your posting:

I can send a 2.0ms pulse and then wait ten seconds before sending the next pulse and it won't hurt the servo.

This is not how R/C type servos are designed to operate, they are not designed to be shutoff between normal 20ms updating of pulses. You will find that once you stop sending pulses to a servo it loses all 'holding' torque and if you had a heavy enough torque load on the servo horn the position could change without any correction until another pulse is sent.

Without power or a continuous 50hz signal update the only holding force is the servos gear train resistance relative to the 'live load' force.

Lefty

To be clear ? PWM( pulse width modulation) is the method by which a single servo is controlled.

“PWM of a signal or power source involves the modulation of its duty cycle” ( Pulse-width modulation - Wikipedia )
Are you aware that a servo can be operated correctly over its full range without altering the duty cycle of the control signal?
If servo control can be achieved without modulating the duty cycle then PWM would seem a poor choice for describing its encoding.

Perhaps this discussion should be continued in bar sport, I think this thread is losing its relavance to hardware interfacing :wink:

He he..this PWM/PPM discussion just refuses to die. As much as I'm glad I posted the topic (I needed to understand it better) I'm kinda regretting that I posted it together with my OTHER general servo questions. These seem to be lost in the PWM/PPM ordeal.

For instance I'm still trying to figure out this:

what kind of signal is sent from the motor controller to the DC motor?

Is it an analog signal (=the voltage being regulated up and down), PWM or a 3rd option that the servo's motor controller uses to control the DC motor?

Most of the low cost (analog) servos I have looked at drive the motor with pulses that are (more or less) proportional to the error (the difference between the current physical position and the commanded position) with the polarity as needed to move the motor in the direction that corrects the error. Motor pulses are usually only generated immediately following a command pulse.

In the prior posting I showed a link that discusses a popular servo controller chip that was used for decades internally for many hobby servos: Technical Reference Info for Servos

While no longer being used, I'm sure most of the inexpensive servos are still using the same general design just with smaller chips.

In figure 1 of the embedded data shows the motor connection on the right hand side. It is being driven by a H-drive bridge. The artical discusses the operation of the servo controller in some detail.

Lefty