Professional Documents
Culture Documents
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.
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.)
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.
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.