One of the most common problems in building small robots and other electromechanical projects is that off-the-shelf DC motors just run too fast for many applications. Sometimes a mechanical fix like a gear or capstan drive is the solution, but many times you’ll want to skip the additional noise, space, and precise construction that mechanical drive-trains entail. In these cases, a “direct-drive” arrangement, in which the motor shaft is directly coupled to the load it turns, is likely best. And you’ll find yourself in need of an electronic speed controller.

second-build-title-edges-clear

Enter the Dial-a-Speed, a DIY one-size-fits-most speed controller for small DC motors. It’s built in a compact physical package around a full-size potentiometer, includes built-in back-EMF protection, and has on-board screw terminals for easy motor and power connection. The Dial-a-Speed accepts 5-12V DC, can be easily panel-mounted in most enclosures, and will provide effective speed control of any continuous-rotation motor or fan in the RadioShack catalog as of this writing.

RadioShack motors and fans tested with Dial-a-Speed.
PRODUCT VOLTS (DC) MAX (RPM) MIN (RPM)
 #273-2569-18V Hobby Motor  9 / 12 11,030 / 14,300  176 / 795
 #273-1066V Micro Motor  6 15,500  1,191
 273-0467.5V Micro Motor  7.5 15,900  1,259
 #273-0479V Micro Motor  9 20,200  2,641
 #273-2581.5–3V Gear Motor  5* 17,900  2,462
 #273-2231.5–3V Hobby Motor  5* 16,700  2,798
 #273-24012V Micro Fan  12  6,640  115
 #273-24312V 3″ Fan  12  2,432  130
#273-23812V 4″ Fan  12  2,611  100
*Technically, these motors, which are only rated to 3V, are overdriven at 5, which is the minimum needed for the Dial-a-Speed to work. However, I’ve had no failures or other problems running them at 5V. If you want to use one of these motors with your Dial-a-Speed and are concerned about damaging it, it would be simple enough to add a resistor and/or diode network between the Dial-a-Speed and the motor itself to step 5V down to 3 (or even lower) as needed.

How Does it Work?

This is a pulse-width modulation (PWM) speed controller, using a 555 timer IC wired in astable mode to control an N-channel power-enhancement MOSFET that actually switches the motor on and off. It is based on a circuit posted by Rick Bickle of the Dallas Personal Robotics Group, with minor modifications for use in a shared power supply configuration.

shackcelerator-schematic-02

What does all that mean? Basically, instead of a continuous stream of current, the circuit sends power to the motor in little pulses, at a more-or-less constant frequency (around 50 times a second). The length of these pulses (aka their width) can be changed (aka modulated), which causes the speed at which the motor turns to change, too. The longer/wider the pulses, the faster the motor goes.

Square wave with, e.g., 60% duty cycle.  The term "pulse-width modulation" refers specifically to varying the duty cycle without changing the frequency of the underlying wave.
Square wave with 60% duty cycle. “Pulse width modulation” implies changing the duty cycle without changing the frequency of the underlying wave.

If you were to plot the voltage going to the motor against time, perhaps using an oscilloscope, it would look more-or-less like a square wave, illustrated above. When describing square waves, the amount of time spent in the “high” voltage state is called the mark time, and the amount of time spent “low” the space time. The duty cycle is a percentage expressing how much of each wave cycle is “mark time.” For example, if your pulses are coming 1 a second, and your mark time is 0.6 seconds, then the duty cycle is 60%. This circuit is cleverly designed to offer a wide range of control, and can produce square waves with duty cycles ranging from less than 5% to more than 95%, depending on where you set the dial.

Project Steps

Prep the pot.

The potentiometer comes with a long shaft in case you want to mount it behind a thick panel. Chances are, you’ll want to cut it down a bit. Figure out the best length for your application and cut the shaft off with a hacksaw. 3/8″, measured from the top of the threaded portion, is a good length with this knob. You may also want to drill or file a flat spot for the set screw so the knob won’t spin on the shaft. Also cut off the potentiometer’s free-hanging ring terminals now; you’ll be soldering directly to the rivets.

Twist a pair of 1N4001 diodes together in series to make a Y-shaped junction, as shown. Note the orientation of the silver stripes. Solder the twisted leads together and form them into a little loop. Solder a ~2″ length of green hookup wire to the loop.

Solder the free ends of the diode junction to the potentiometer’s outer terminals as shown. Solder a ~2″ length of black hookup wire to the center terminal. Apply heat-shrink tubing as necessary to make sure the diodes don’t short against the center lead.

Mount the heat sink.

The transistor that actually switches the motor current may get hot when running at high power, under heavy loads, or for extended periods of time. This is unlikely to be a problem for low-voltage DC applications, but we’ll err on the side of caution and attach a heat sink to keep the transistor cool.

First, bend the three MOSFET legs up toward the transistor body until they are at a 90-degree angle to the flange (the metal back plate with the hole in it). Cut a piece of double-stick foam tape to fit the front surface of the body and stick it in place.

Strip the end of a ~1″ length of green hookup wire, crimp on the uninsulated ring-tongue lug, and solder it in place for good measure.

Pass the 4-40 machine screw through the #4 split washer, then through the ring-tongue lug, then through the MOSFET flange, and finally into the threaded hole in the heat sink. Tighten down the screw, bend the ring-tongue lug so that the green lead points in the same direction as the bent transistor legs, and cut the green lead to the same length as the bent legs. Strip about 3/16″ of the insulation from the end.

Mount the IC.

Position the 555 timer as shown on the PCB. As viewed from the solder side of the PCB, with pins 1 and 8 uppermost, bend pin 7 to the left, and pin 4 down. Making these bends now will make it easier to complete solder-side connections during later assembly. The rest of the pins can be left unbent.

Solder all 8 pins in place.

Cut a piece of double-stick foam tape to fit the back of the IC and stick it in place. During final assembly, the two pieces of foam tape will be stuck together to hold the MOSFET in place during soldering, and to insure correct spacing of the heat sink above the PC terminals.

Install the PC terminals.

Insert one PC board terminal above the IC, and one below, as shown. The upper PC terminal butts right up against the chip near pins 1 and 8. The lower terminal is spaced one row away from pins 4 and 5.

NOTE: I have built several of these devices, and in some cases the holes in the PCB are large enough to accept the PC board terminal pins, and in some cases they are not. If the holes on your PCB are too small for the PC board terminal pins, don’t fret—it’s easy to expand the holes as needed with a small drill bit or a sharp hobby knife blade.

Solder the PC board terminals in place. Their pins are a bit long; you can trim them shorter with side- or end-cutters now, if you like, or wait until later and trim all the long legs, leads, and pins at once.

Add the snubber diode.

DC motors, like all inductors, tend to resist changes in the current passing through them. When current to an inductor is switched off, it will produce a counter-electromotive force (CEMF) which manifests as a strong, brief current of opposite polarity to the input voltage. These high voltage pulses introduce undesirable noise to a circuit’s power supply and can cause erratic behavior or even damage components. And because this circuit works by switching motor current on and off many times per second, CEMF is potentially a very serious problem.

Fortunately it is easy to control inductor CEMF with a “snubber” or “flyback” diode. The diode is “reverse-biased,” making it “invisible” during normal circuit operation. But when current to the inductor is switched off, it is positioned to conduct CEMF in the direction opposite normal current flow, from the negative terminal to the positive terminal, feeding it back into the inductor where it harmlessly dies out.

Our circuit includes a built-in snubber diode wired across the terminals where the motor will be attached.

Bend the leads of a 1N4001 silicon rectifier diode and fit it into the PCB right below the 555 timer, making sure that the silver strip on the diode body is closest to pin 4, as shown.

On the solder side of the board, bend the two leads down towards the leads of the adjacent PC board terminal, as shown. Solder the diode leads in place where they come out of the board, and also where they contact the two leads of the PC board terminal. Trim away any excess lead. Reflow the solder at IC pin 4, and make sure there is a good electrical connection between it, the adjacent diode lead, and the corresponding PC board terminal lead.

Mount the ceramic caps.

The circuit includes two 0.1μF ceramic capacitors wired in a configuration common to most astable-mode 555 timer circuits. The first, between pin 5 (CTRL) and ground, prevents stray inductances or power-supply noise from presenting at pin 5 as false control voltages and thereby causing erratic behavior in the IC. The second, between pins 2/6 and ground, is repeatedly charged and discharged during the chip’s timing cycle. Its capacitance establishes, in part, the frequency of the PWM output.

Install the two capacitors in the PCB as shown. Bend each one away from the 555 timer at an angle of about 45 degrees to leave plenty of clearance for the MOSFET and heat sink when they are installed later.

Solder the capacitor legs in place where they exit the PCB, then bend and solder as necessary to make the connections shown in the photograph.

The lead at IC pin 2 is bent towards the chip, making contact with pin 2, and then across and under the chip body to contact pin 6, forming a solder-side jumper between them. The other lead of this capacitor is bent up to the adjacent PC terminal pin (which will be connected to power supply GND), and then back down to contact IC pin 1.

The lead at IC pin 5 is bent up to contact pin 5. The other lead of this capacitor is bent over and trimmed to just reach the copper pad immediately below and to the left of IC pin 5.

Install the big filter cap.

Remember that capacitors pass transient and alternating currents, but do not pass continuous DC current. This relatively large electrolytic capacitor is installed between Vcc and GND to prevent high voltage spikes and other transient power supply noise from interfering with or damaging the IC by passing them harmlessly to ground. It is essential when the IC and motor are operating from a common power supply, as in this case.

Straighten the leads on the capacitor, then orient it with the positive end “up” (nearest pin 8) and the negative end “down” (nearest pin 5) and bend the leads as necessary to pass them through the PCB holes where indicated.

On the solder side, bend the capacitor’s positive lead in to contact pin 8, and then up to contact the nearest PC board terminal pin as shown. Bend the negative lead “up” and trim it to just reach the nearest copper pad. Make sure the solder joint here connects the electrolytic capacitor’s negative lead to the free lead of the pin 5 ceramic cap, as shown.

Connect the pot.

Cut the black lead from the potentiometer to a length of about 1.25″, and the green lead (to the diode junction) about 0.1″ shorter. Strip about 3/16″ of the insulation from the end of each lead.

Insert the stripped end of the black lead through the PCB immediately adjacent IC pin 3, and the green lead immediately adjacent the ceramic capacitor leg at IC pin 2.

On the solder side of the board, bend the black lead over to contact IC pin 3, and the green lead over to contact IC pin 2. Solder both leads in place.

Install the MOSFET.

There are four solder connections to make for the MOSFET: the three leads from the transistor body and the green wire lead from the flange. The flange lead is electrically connected to the transistor body’s center (#2/drain) lead, which is soldered in for structural strength only. You could cut the center lead off the transistor body and the circuit would still function perfectly.

Remove the protective layer from the foam tape on the back of the IC and on the back of the MOSFET. Align the MOSFET over the PCB with lead #1 (gate) next to 555 pin 7, lead #2 (drain) next to 555 pin 6, and lead #3 (source) next to 555 pin 5. Insert the transistor leads through the PCB holes and the flange lead directly below the board mounting hole on the other side of the chip. Work gently and don’t force anything. Stop when the two sections of foam tape are pressed against each other.

On the solder side, bend the flange lead down to just reach the adjacent copper pad, and solder it in place. Then bend transistor lead #1 (gate) away from the IC, solder it in place, and reflow the solder at IC pin 7 to make sure it is electrically connected to the gate lead. Solder transistor lead #2 (drain) in place, without bending, and cut off any excess lead. This lead makes no electrical connections. Finally solder transistor lead #3 (source) in place, and reflow the solder on the adjacent capacitor lead to make sure it is electrically connected to the source lead.

Make solder-side connections.

Almost done. Complete the circuit by making 4 solder-side connections.

First, install a 1/8W 10K pull-up resistor between pin 7 and Vcc. This resistor keeps the voltage at pin 7 (and at the MOSFET gate) high during charging cycles; when capacitor C2 is charged, the IC discharges pin 7 to ground, switching the MOSFET off until the cycle starts over again.

Second, install a red power jumper between the top-left PC board terminal pin and the bottom-right PC board terminal pin, as shown. This carries power across the circuit to the motor, and also keeps the 555 timer’s RESET pin (4) voltage high.

Third, install a green jumper between the MOSFET flange lead and the bottom-left PC board terminal pin, as shown. This connects the motor to ground through the MOSFET, which is switched on and off to provide pulse modulation.

Fourth and finally, install a black jumper between the top-right PC board terminal pin and the MOSFET “source” lead (lead #3) to lower left. This connects the MOSFET to power supply ground; the circuit’s switching action alternately connects and disconnects the motor to ground, through this wire, via the MOSFET.

Put it all together.

Test the circuit before final assembly. Connect +6V DC to the PC board terminal nearest IC pin 8, and ground to the PC board terminal nearest IC pin 1. Connect the two leads of a small DC motor to the two PC board terminals at the other end of the chip. Turn on the power and verify that turning the potentiometer clockwise causes the motor to speed up, while turning it counterclockwise causes the motor to slow down. If your circuit does not work correctly, please refer to the troubleshooting checklist in the conclusion of this project.

It is a good idea to seal freshly-soldered PCBs to prevent oxidation of traces and connections on the solder side that can eventually degrade or inhibit performance. Clear nail varnish works well for this. Apply a coat with the bottle applicator and wait an hour for it to dry.

Clean the bottom of the potentiometer with rubbing alcohol and apply a piece of double-stick foam tape. Cut the tape to match the shape of the potentiometer body and, optionally, color the white edge black with a permanent marker for looks.

Strip all the insulation from a ~2″ length of 22 AWG solid-core wire and use a pair of pliers to loop it through the PCB hole opposite the potentiometer, forming a “lark’s head” knot or cow hitch. Leave about 1/2″ of bare wire protruding at each end of the hitch.

Remove the backing from the foam tape and fold the potentiometer over onto the solder side of the PCB, bending the potentiometer leads as needed. Line everything up carefully before pressing the PCB firmly into the foam tape.

Solder the ends of the wire hitch to the body of the potentiometer and trim off any excess lead. This will firmly secure the entire assembly. If you have problems making these solder joints, please refer to the troubleshooting section in the conclusion.

You may want to label the PC terminals for easy future reference. Use a small permanent marker and refer to the photograph if you get confused about which wire goes where.

Take it for a spin.

Depending on your intended use, you may want to mount the Dial-a-Speed inside the enclosure of another project. To do so, just drill a 5/16″ hole for mounting the potentiometer shaft and a 1/8″ hole to accept the alignment tab on its case. You can cut this tab off if you’d rather not mess with it, but I always like to use it because it keeps the potentiometer from rotating in its mounting hole when you turn it to the ends of its range. Here’s a full-scale PDF drilling template you can download, stick to your enclosure, and then drill through to properly line up the tab and the shaft holes. Once the holes are drilled, remove the nut and panel washer from the potentiometer, pass the shaft through the larger hole from inside the enclosure, align the indexing tab with the smaller hole, and then put the washer and nut back in place on the outside surface. Tighten the nut gently, put the knob on the shaft, tighten the knob set-screw, and you’re done.

You can also install your Dial-a-Speed in a standalone case (as I’ve done here) with two banana-plug jacks or other terminals on each side for the motor and power connections. If you’re curious, the fancy clear case shown in the photos is a 2″ golf-ball display cube from the hobby store. I chose it to show off the build for photography, but it has also come in handy from time to time, as a standalone device, for testing motors I’ve scavenged from old disk drives and other technoscrap.

In developing Dial-a-Speed, I extensively tested its performance with various motors. To do so, I mounted each motor in a panel and wrapped a small “flag” of reflective tape around the shaft. I connected the Dial-a-Speed to a small bench power supply and to the motor under test and let the motor run for 3 minutes to warm up. Then I used my DT-2234C+ digital laser tachometer to count the revolutions of the reflective marker per unit time. I took 10 measurements per motor, per test, and averaged these to produce the values shown in the table above. Fans were simply mounted in a vise for testing, with the reflective marker tape applied directly to the hub.

Conclusion

Potential applications for this circuit are many and varied. You could use it to build an adjustable magnetic stir plate for your kitchen, brewery, or laboratory. Or an adjustable fan or fluid pump. Or to make a zoetrope. Or use it for non-motor applications like dimming incandescent or solid-state (LED) lighting, controlling a heating element, or whatever else you can imagine. I'm going to use mine to upgrade my original Optical Tremolo Box for better low-speed control and to run on 9V DC, like the rest of my FX pedals. What will you do with yours? Please let us know in the comments below.

Troubleshooting

Once you have the PCB soldered to the potentiometer body, it is much harder to troubleshoot, so be sure to test and make sure the circuit is working before completing Step 11.

If the motor is not turning, first put a voltmeter across the motor terminals, turn on the power, and turn the knob fully clockwise. You should measure a voltage very close to your supply voltage. If not, try turning the knob fully counterclockwise to see if you have the pot wired backwards. If that fixes the problem, swap the potentiometer connections to IC pins 2 and 3, test again, and verify that full-clockwise now gives full-power. If turning the knob has no effect, things get a bit more complicated. If you have access to an oscilloscope, measure the waveform between 555 pin 7 and ground. If you see a square wave that varies when you turn the knob, the problem is with the MOSFET or MOSFET wiring. If you don't see a square wave at pin 7, the problem may be in the chip power supply or in one of the chip's timing components. Step through the circuit with your multimeter's continuity tester and look for broken and shorted connections.

If you have a hard time soldering to the potentiometer body, here are some tips that should make it a lot easier:

  1. Use the recommended 62/36/2 silver-bearing rosin-core solder, in the recommended 0.022" diameter.  It's RadioShack Part #64-013.
  2. Make sure your iron is hot enough. I use the RadioShack digital soldering station (#64-053) with the factory tip, set to 680º F.
  3. Clean the surface of the pot with a scouring pad, then pretin the ends of the wires and the body of the pot.
  4. Use a vise to hold everything in place while you solder. Let the joints cool before loosening the vise.

If turning the knob causes little or no change in your motor's speed, the problem may be with your potentiometer. If gentle pushing or pulling on the pot's shaft causes the motor speed to change dramatically, try replacing the pot. If that doesn't fix the problem, first carefully check the circuit with your multimeter's continuity setting, and reflow any solder joints that look grainy, dull, or incomplete.