You are on page 1of 8

How to Make a PWM Circuit without a

Microcontroller
Pulse-width modulation is a digital technique for varying the amount of power delivered to an
electronic component. By adjusting the amount of power delivered to a motor or LED, the speed or
brightness (respectively) can be controlled.
To me, the simplest and most flexible PWM is generated by a microcontroller. However, some people
arent comfortable programming a microcontroller. So, the electronic circuits in this article use only
off-the-shelf, readily-available components such as logic chips, diodes, resistors, transistors, and
capacitors.
This article begins with a schematic of an inverter-based circuit that outputs a variable duty-cycle
square wave. Additional schematics take that output wave and control a sample DC motor driver and an
example 7-segment LED display.
The resistor-diode-capacitor combination that generates the PWM has been around for a while.
Personally, I first ran across it a couple of years ago on Eddy Wrights website. And, I recently noticed
that DPRG includes it in their motor driver tutorial by Rick Bickle.

Creating an Adjustable PWM


A pulse-width modulation signal begins with a voltage that goes up and down repeatedly. The classic
method of creating the oscillation is with a resistor-capacitor (RC) circuit. This circuit uses RC timing
with a diode twist to alter the ratio of the on-pulse time versus the off-pulse time (called duty cycle).

Schematic of a variable duty-cycle PWM circuit based on a 74AC14 inverter logic chip.
IC1: A 74AC14 Hex Inverter with Schmitt-Trigger Inputs.
The 74xx14 number is the industry standard number for a package of six inverter gates attached
to specific pins.
The AC part of the number is the technology (semiconductor material type, mask size, and so
on) used to make this chip. In this case, AC stands for Advanced CMOS. That indicates
that the chip works from 2V to 6V and outputs up to 25 mA per pin.
Hex means six. There are six inverter gates in the package. We only need two of the six
inverters. The rest can be used for whatever you want. Connect their inputs to GND if you dont
use them.
Inverter means that whatever is fed to the input pin, the opposite value (inverse) will be
output.
Schmitt-Trigger Inputs are special inputs designed to efficiently convert slowly changing or
analog signals.
C1: A 0.1 F capacitor smooths the power supplied to IC1. If this capacitor were missing, the chip
would probably still work, but there might be intermittent glitches on the inputs or spikes on the
outputs.
C2: This 0.1 F capacitor is going to be filled up (charged) and drained (discharged) repeatedly to
make the pulse wave. Increasing the capacitance decreases the frequency of the wave. Decreasing the
capacitance increases the frequency of the wave.
R2: A 10 k variable resistor (trimmer potentiometer). This is variable resistance (rather than fixed) to
alter the on/off times of the output wave. Increasing the total resistance value increases the frequency of
the wave. Decreasing the total resistance value decreases the frequency of the wave.
D1 and D2: Two diodes. 1N914 or 1N4148 diode is preferable. D1 creates the charge path. D2 creates
the discharge path. Without these diodes, the pulse wave would still appear, but the on and off times
couldnt be varied since the capacitor would be charged and discharged using the same path through the
resistor. (An in-depth explanation appears on the next page.)

Implementing the PWM Circuit on a Solderless Breadboard


You probably already have many of the parts for the pulse-width modulator. However, unless you
purchased and implemented the 38-kHz object detector from my book, Intermediate Robot Building,
you'll probably need to pick up a 74AC14 from DigiKey or Mouser Electronics.
(A 74HC14, 74LV14, 74AHC14 would probably work, but none will exactly match the voltage ranges
or output strength of the 74AC14. Other versions of this chip are even less compatible. Stick with the
74AC14 to save yourself grief while youre learning.)

Variable duty-cycle pulse-width modulation circuit board implemented on a solderless breadboard.


The solderless breadboard circuit looks slightly different than the schematic, but it is actually the same.
Capacitor C1 is installed, but outside of the photograph. The trimpot (R2) is a little bit high on the
board so that you can see all of the wires and connections.
Notice in the photograph and in the schematic that the final pulse output wave comes from the second
inverter, not the first. The output of the first inverter is fed into the second inverter to make a clean
copy.
Attaching a load (LED, motor driver transistor, etc) to the copy will not alter the operation of R1, D1,
D2, C2. However, if we hadnt made a copy, and we had attached a load to the output pin of the first
inverter, than the frequency and duty cycle of the PWM would be altered by the load.
Put more simply, we made a copy of the signal so that we wouldnt mess up the original signal when
we connected the wave to other circuits.
Lets learn how the heart of the circuit works...
To understand how the 74AC14 PWM circuit
works, lets zoom in on the section of the
schematic containing the trimpot, diodes,
capacitor, and the first inverter logic gate.
Capacitor Charge Cycle

Partial schematic showing the charging path of a variable duty-cycle PWM circuit.
1. The capacitor is empty (discharged) when the power is first applied to the circuit. Because the
capacitor is low, and because the capacitor is connected to the input pin of the inverter gate, the
input is low.
2. An inverter gate produces an output that is opposite of the input. Because the input is currently
low, the output is high.
3. The conventional current flows from the output of the inverter gate through the left half of the
potentiometer (R2) and then through diode D1. The current cannot flow through the right half of
the variable resistor (R2) because diode D2 blocks the path (notice the direction of the diode
arrow). Diodes are one-way valves.
4. The current flows into the capacitor (C2); charging the capacitor. If the potentiometer is dialed
to the far left, the resistance will be small and the capacitor will charge quickly. If the
potentiometer is dialed to the far right, the resistance will be large and the capacitor will charge
slowly.

Capacitor Discharge Cycle

Partial schematic showing the charging path of a variable duty-cycle PWM circuit.
1. Eventually, the capacitor fills up (is charged). Because the capacitor is now high, and because
the capacitor is connected to the input pin of the inverter gate, the input is now high.
2. An inverter gate produces an output that is opposite of the input. Because the input is now high,
the output is switched to low.
3. The high capacitor (C2) now begins to discharge into the low output pin of the inverter.
4. The conventional current flows from the capacitor (C2), through diode D2, and then through the
right half of the potentiometer (R2). If the potentiometer is dialed to the far right, the resistance
will be small and the capacitor will discharge quickly. If the potentiometer is dialed to the far
left, the resistance will be large and the capacitor will charge slowly.

How Pulse-Width Modulation Works


The repeated charging and discharging of the capacitor occurs because the inverter gate output flips to
the opposite of the state of the capacitor. When the capacitor is empty, the inverter output charges the
capacitor. When the capacitor is full, the inverter output discharges the capacitor.
If this were the only feature of this circuit, the output would be on half of the time (when charging
the capacitor) and off half of the time. This would provide 50% power (only on half the time) to
whatever was connected.
The trick is that the resistance of the on path is different from the off path due to the diodes. That
means you can dial the trimpot to make the on time take more or less time than the off time. As
such, you can supply an output signal that is on from almost 0% to 100% of the time.
Obviously if the outputs are on only 10% of the time, the attached device is only going to be on
only 10% of the time. In this way, the total amount of power delivered to an attached device can be
varied by simply turning the potentiometer to alter the on/off times (duty cycle).
It may help to see the actual outputs on an oscilloscope...

You might also like