> PC Generated Pulse Width Modulation (PWM) For DC Motor Speed Control

Figure 1 is a photo of a DC motor controller you can construct in a weekend or two. Motor speed is controlled using pulse-width-modulation (PWM). The key feature of this tutorial is that your PC is used to generate the PWM signal. Thus you can program your PC to contol motor speed in software.


PWM is a common technique for speed control. A good analogy is bicycle riding. You peddle (exert energy) and then coast (relax) using your momentum to carry you forward. As you slow down (due to wind resistance, friction, road shape) you peddle to speed up and then coast again. The duty cycle is the ratio of peddling time to the total time (peddle+coast time). A 100% duty cycle means you are peddling all the time, and 50% only half the time.

PWM for motor speed control works in a very similar way. Instead of peddling, your motor is given a fixed voltage value (say +5 V) and starts spinning. The voltage is then removed and the motor "coasts". By continuing this voltage on-off duty cycle, motor speed is controlled.

The concept of PWM inherently requires timing. The classic 555 timer chip and some potentiometers can be used to generate PWM. The pots are manually adjusted for the desired duty cycle. However, if you use a PC, you can automatically change the duty cycle and have your PC control your motor's speed.

One potential application of automatic motor speed is regulating room temperature. Your PC can sense the current temperature (using an analog-to-digital converter) and then automatically increase/decrease the fan's speed accordingly. By using your PC you are no longer burdened to manually adjust the fan's speed as the room heats or cools.

There are many commercial PC motor speed controllers however they tend to be very expensive (hundreds of dollars). This tutorial shows you how to breadboard your own for a fraction of the price. The parts are widely available and inexpensive. The key component is the 8254 timer/counter chip (apx. $4) breadboarded on a ISA protoboard card (apx $15). This card plugs into your PC just like a modem or sound card. A complete tutorial on the 8254 Timer/Counter Card exists on the Boondog website. You need to construct this 8254 card prior to building and programming your DC motor control circuit.

This rest of this PWM tutorial is broken down as follows: