What is the simplest way to generate PWM without a Microcontroller?

I recommend the (GASP!) 555 Timer in "astable" mode. You'll find everything you need in the link, but I copied them here just for you!

Astable mode gives you a variable PWM frequency, and allows for an adjustable duty cycle as well (high-time and low-time equations in the link).

The circuit:

555 Timer, astable mode

Note: I'd add an electrolytic cap across Vcc (positive lead) and GND (negative lead) to reduce the effect of dips in power supply voltage.

The PWM frequency:

Output frequency of 555 Timer in astable mode

Some defense for my answer compared to others in this post. Most other answers require an intermediate waveform to generate a variable PWM signal, such as the common triangle wave/comparator method. I don't see much point in constructing triangle wave generator (a significant circuit in-and-of itself) just as an intermediate step to solve your problem.

The 555 is a great analog chip and does just what you need. I wish people didn't hate on them as much.


The Ye Olde Phashioned way to make PWM with analog controlled duty cycle is to compare the analog control signal to a triangle wave. You make a triangle wave generator that runs at the desired PWM frequency. This is fed to the negative input of a comparator and the analog control signal to the positive input. The result is either full high or full low, but the duty cycle is linearly proportional to the control signal. Early class D audio amps worked on this principle, for example.

In a lot of cases the PWM didn't need to be super linear, so the triangle wave doesn't have to have perfectly straight edges. Allowing them to be a little exponential can simplify the circuit.

Added:

Mark Rages pointed out that when you say "servo motor", you could be referring to the little position-controlled hobby motors used on model planes and the like. My answer applies to controlling a motor assuming you have a analog voltage proportional to how hard you want to drive the motor. It does not apply to these "hobby servos". Those aren't controlled by PWM in the common sense of that term, but by the width of pulses that usually need to be from 1 to 2 ms repeated every 20 to 50 ms or so. If this question is really about hobby servos, then it should be fixed to make that clear.


Triangle wave. Comparator. Control threshold. That's the basic way to do it.

If you want to control a hobby servo, however, this is not the best way. The duty cycle varies between 5% and 10% (1ms to 2ms pulse width in a 20ms period), which is short, and most likely you want to control it with some precision. On a 5V\$_{PP}\$ triangle you have to vary the comparator's threshold between 4.5V and 4.75V. Any deviation and you won't be able to control the servo over its full range. That requires precision components. Also, the triangle wave generator needs 2 opamps, and then there's the comparator.. There's a better way.

enter image description here

First generate a 50Hz square wave. Most simple way:

enter image description here

For the 74HC1G14 a 250k\$\Omega\$ resistor and a 100nF capacitor will give you a 20ms period.

Feed the square wave into a MMV (Monostable MultiVibrator). You can do this with an LM555, or use a logic device like the 74HC123A. If you use the latter the pulse time is defined by \$R_{EXT}\$ and \$C_{EXT}\$:

\$ T = R_{EXT} \times C_{EXT} \$

Time in \$\mu\$s, R in k\$\Omega\$, and C in nF.

To get a pulse width varying between 1ms and 2ms you use C = 100nF, and R = 10k\$\Omega\$ in series with a 10k\$\Omega\$ potmeter.

I could have done this with two LM555s, but I'd need more external components.

edit (about microcontrollers)
I agree with Olin (see comments) that excluding a microcontroller is short-sighted (Olin said "silly"). There was a time when developing for a microcontroller was complicated, but today that's no longer true. You can also have a programming interface for a few euros. The solution would then look so easy that no non-controller solution can compete with it: you take an ATTiny5 (Olin takes a PIC10F220) in a SOT23-6. Connect a decoupling capacitor to the power connections and the potmeter to the ADC input. That's it! 3 (three) components. Converting the ADC reading to a pulse width output is so easy that it's almost ridiculous, even for a beginning programmer.

Once you get started with them you'll find that microcontrollers often offer a more simple and more flexible solution than with other ICs or discrete components.

a note
From your other question I see that you do use microcontrollers. Why do you want to avoid them here?

Tags:

Pwm