PWM DC Motor Speed Control



Introduction

Like me, you have a simple DC motor (5V or 12V) you have lying around or bought from Radio Shack. You want to This PWM tutorial is motivated for my desire (as a future educator I hope) to teach control systems theory with a hands-on approach. Here, I present a system (a DC motor) that we wish to control (regulate its speed, direction and turning it on or off). The key word here is regulate. You can imagine controlling motor speed by varying the input voltage across the motor leads. Equipped with a motor encoder or tachometer, you might experimentally be able to make a table of RPM values vs. input voltage. This approach works. Case closed right? Wrong. Suppose you have disturbances. For instance, suppose you use your DC motor to drive a mobile robot. You determined a table of values based on the robot running across a smooth floor. As long as you run on the floor, you may get the anticipated RPM for a given input voltage. Suppose suddenly your robot travels on a carpet. This is a disturbance. More technically, you motor must overcome a larger torque associated with overcoming the friction between the wheels and carpet. Another example, suppose the floor becomes inclined. Again, differing torque conditions will require that you either generate a new table of values taking torque into consideration, or change you general approach. As mentioned before, the key word is to regulate the speed. The above approach is called open-loop control. As long as certain conditions (no floor inclines, smooth floors), this approach may work. A better approach may be to have an encoder or tachometer that gives us real-time RPM information. If, while the robot's speed should change because of disturbances, we change the voltage accordingly. In other words, we use feedback to regulate speed. This is called closed-loop control. I mentioned "changing the voltage accordingly" above. What is "accordingly"? Good question. There are plenty of undergraduate and graduate courses, stacks of books, journals and papers on linear and non-linear control systems that suggest what "accordingly" means. For now, keep this issue in the back of your mind and I will address it partially later in this tutorial, and perhaps more fully in another tutorial. The above digression was needed to motivate the need for real-time RPM information for feedback in order to regulate motor speed in the case of changing torque conditions (inclined floor, carpet vs. smooth floor). This tutorial will use a toy DC motor (the type at Radio Shack) as the system. It will present a circuit that will allow you to turn on/off the motor, reverse direction, and regulate speed. All parts can be bought from Radio Shack except for the 74LS121 monostable multivibrator chip. This is a common and cheap (about a buck) chip found in many semiconductor chip stores like Active Electronics, Jameco or Digikey. As you might know, Radio Shack can be a bit pricey compared to mail-order houses. Further it seemed silly to me to tell you to buy everything from Radio Shack and just get the 74LS121 chip via mail-order... you pay more for shipping then for the part! For that reason, I have included part numbers for all components from Jameco except for common resistors and caps. Jameco I have found to be competitively priced, in-stock and serves for this circuit, as a single-source vendor. The motor speed controller circuit is based on pulse-width-modulation (PWM). It uses a +5, -5 and +12V power source. It can be used as a stand-alone system. In other words, you can build it, attach it to a motor-driven chassis, tune a potentiometer for desired speed, and presto you have a mobile robot that will maintain this set speed over carpets over inclined floors. The circuit also has the flexibility to be interfaced to a computer, either a PC or embeddable microcontroller. The purpose of a computer is to be able to develop via software a way of "accordingly change voltage". The computer would read in current motor RPM, calculate via some prescribed mathematical control law, the appropriate voltage, and then send out this voltage to the motor circuit. For such purposes, we would need a way of inputting and outputting such information into the computer. That is why I developped the 8255 PPI PC Interface card. In a latter tutorial I will show how this is done. For now, the stand-alone system will serve our purposes, while keeping in mind this attractive flexibility of computer interfacability. Enough said! Let's get busy building a circuit! The rest of this tutorial is broken down as follows: