Fun with PWM (Pulse Width Modulation)

Reader Contribution by Ben Nelson

<p>I know, I can already hear you thinking it…</p>
<p>”What is PWM and why is there a disco ball on an Eco web page!?!?”</p>
<p>Well, I’ll be the first to admit that this has nothing whatsoever to do with raising chickens, composting, baking your own bread, or anything else you might typically be thinking of.</p>
<p>However, it has a LOT to do with DIY, a culture of continuous learning, thrift, and ingenuity. </p>
<p>
<span style=”line-height: 22px; font-family: Georgia, ‘Times New Roman’, Times, serif; color: rgb(17, 17, 17); font-size: 14px; “>
<embed width=”425″ height=”350″ style=”padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ” src=”http://www.youtube.com/v/yycfeYwLfs8″ type=”application/x-shockwave-flash”>
</span>
</p>
<span style=”line-height: 22px; color: rgb(17, 17, 17); font-size: 14px; “>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>At home, I have a small LED light that is designed for use under cabinets. I use it mostly to illuminate one side of my aquarium, and I occasionally pull it out to use it as a light for filming video.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>The problem is that it is quite a bit brighter than the other LED light I have on my aquarium, and for video use, it would be nice to be able to adjust the brightness of the light as well.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>However, LEDs just CAN NOT be dimmed with a regular old light switch dimmer the way an incandescent bulb can. I had heard that they can be dimmed through PWM – pulse width modulation. I was already familiar with the term, as that’s the same technique used to control the speed on the motor of my <a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://300mpg.org/projects/electro-metro/” target=”_blank”>homebuilt electric car</a>.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>So, when I was in at the <a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://milwaukeemakerspace.org/” target=”_blank”>MILWAUKEE MAKERSPACE</a> I asked my buddy Tom if he had any suggestions for me to start learning electronics by building a simple PWM dimmer for my fish tank LED light. As a hobby, he has built a fair number of robots, and pointed me to the <a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://www.dprg.org/” target=”_blank”>Dallas Personal Robotics Group</a> web page, where they had a number of tutorials posted. Sure enough, they had a<a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://www.dprg.org/tutorials/2005-11a/index.html” target=”_blank”>tutorial on building a simple motor speed controller</a>, using a 555 timer chip. It also included a very nice explanation of Pulse Width Modulation. It’s really a simple thing that is sometimes hard to describe. I don’t think I have ever heard it explained so clearly as in the DPRG tutorial.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>
<a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://300mpg.org/wp-content/uploads/2011/12/DPRG-web-page.gif”>
</a>
</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>Part of the fun of the Milwaukee Makerspace is just having lots of odds and ends around handy, instead of having to take a trip out to the hardware store or electronics warehouse. A 555 timer, a few resistors and capacitors, and a bread-board were I all right there, ready for me to prototype this simple circuit. Even with nearly no electronics experience, it was pretty easy for me to follow the tutorial and connect up the 555 and other components into a working circuit.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>
<a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://300mpg.org/wp-content/uploads/2011/12/DSC_0559.jpg”>
</a>
</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>After some playing around with it, I found that this circuit could not only control the speed of a DC motor, or dim an LED light, but somebody else suggested I hook a speaker up to it. Sure enough, I could generate various frequencies of sound as well! (Although since it’s a square-wave, none of them sounded very nice!)</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>So, the next time I was going past Radio Shack, I stopped in and picked up some “Perf-Board”. It’s sort of the step between a breadboard and a custom circuit board – just a board with a bunch of holes in it, all evenly spaced, ready for you to insert electronic components and solder them together.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>I then recreated my original breadboarded circuit on the perf-board and soldered it all together.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>
<a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://300mpg.org/wp-content/uploads/2011/12/DSC_0560.jpg”>
</a>
</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>I also grabbed a used plastic case from the Makerspace parts pile to use as an enclosure for the circuit-board. A bit more scrounging meant that I had a power connector for it that matched the power supply for the LED light. I’d be able to use the same power supply whether I was using the LED with or without the dimmer.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>A bit more soldering (only ONE soldering iron burn!) and installing the board in it’s case, and I now officially had a PWM Light Dimmer for my aquarium!</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>But here’s where it gets more interesting. I really built this not so much out of need for a dimmer, but as a learning experience to find out where theory and practice come crashing together in the real world. After assembly, I already noticed a few ways to improve the final version of the device. (I’m still thinking of this as a proto-type or first run!)</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>Ideas for future improvements include:<br style=”padding: 0px; margin: 0px; “>1) A power indicator light. If the PWM is turned all the way down, it’s hard to tell if the device plugged into the dimmer is even on or not.<br style=”padding: 0px; margin: 0px; “>2) A volt-meter display. It’s pretty neat to be able to see that the perceived output voltage of the dimmer is. I have several 12V devices that I would like to run from a large 14.4V battery. With a volt-meter built in, I could set the dimmer to send exactly the correct output.<br style=”padding: 0px; margin: 0px; “>3) Battery Operation. The surplus case that I used as an enclosure already has a removable cover. It shouldn’t be tough to fit some AA batteries in there to make the whole thing run without requiring a power cord to the wall.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>Recently, we through a birthday party for a friend of ours. She requested a Disco Ball at the party. My sister found a disco ball at the clearance table at a store, but no matching disco ball motor.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>Aha! Here’s my chance to not only save a few bucks by not PURCHASING one, but also learn about motors and gear reduction! Next time I was in at the Makerspace, I dug through the bin of scrap motors on the “Hack Rack”. An AC motor? No that’s no good, it has to run on batteries.. Stepper motor? I have no idea how to run one of those…. Hmmm. What’s this? I eventually found not one, but two motors, both connected to to some gearing and a pair of tiny square drive axles. The motors were marked as 24V DC, and I knew that if I drove them at a lower voltage, they would still work, but not spin as fast. I tested them both with a benchtop power supply and saw that they worked. The one was geared to a much faster speed than the other.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>I later tried running both directly from a 9V battery, as it is the simplest power supply I could think of. The one motor, through the gear reduction, would spin the driveshaft at exactly 2 revolutions per minute at nine volts. That’s almost PERFECT disco ball rotation speed!</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>I bent a paper clip through a connector on the end of the drive shaft to hold the ball, and added a carbineer to hold the motor to the ceiling. POW – top-notch disco ball rotation!</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>
<a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://300mpg.org/wp-content/uploads/2011/12/DSC_0536.jpg”>
</a>
</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>For the party, I let it run on just the 9V battery. It got left on overnight, and was still running the next afternoon. What a nice, efficient motor!</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>But what if I wanted to spin that ball a bit faster or slower? Either motor was designed to run up to 24 volts. My PWM “dimmer” was really a motor controller anyways after all. That was all set up for 12V. I connected the dimmer to the more quickly geared motor, hung it up, and strung the disco ball from it. Sure enough, by varying the potentiometer on the dimmer, I could make the ball spin from way too slow to nausea-inducing quick!</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>I even noticed that at very slow speeds, the motor made a little bit of a high-pitched whine. Remember how I said an audio speaker could be hooked up to generate a tone? At slow speeds, the pulses of the motor controller can actually be heard – the frequency is within the range of human hearing. The first time I ever heard a Chevy Volt, I noticed that it made a quiet, yet distinct noise right as it accelerated away from a dead stop. That’s the sound of the car’s electric motor controller picking up frequency as the car increases speed.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>So there you have it. From dimming a light, to spinning a ball, to driving an electric car, Pulse Width Modulation is a simple, yet useful, trick that’s all around us. If you would like to build your own basic light dimmer/motor controller, check out the info at: <a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://www.dprg.org/tutorials/2005-11a/index.html” target=”_blank”>http://www.dprg.org/tutorials/2005-11a/index.html</a>
</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>But why stop there? Once you have some mad soldering skills, what’s to stop you from building a bigger version of a motor controller, maybe something that can push a full size car around? Check out the Open Revolt controller – a motor controller anyone is welcome to build!<br style=”padding: 0px; margin: 0px; “>
<a style=”padding: 0px; margin: 0px; color: rgb(35, 97, 161); text-decoration: underline; ” href=”http://www.instructables.com/id/Homemade-100-HP-Motor-Controller-for-an-Electric-C/” target=”_blank”>http://www.instructables.com/id/Homemade-100-HP-Motor-Controller-for-an-Electric-C/</a>
</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>You can also watch Paul Holmes presentation about the controller from this summer’s Mother Earth Fair.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; “>
<a title=”http://www.youtube.com/watch?v=G-3gVoSrcm0″ href=”http://www.youtube.com/watch?v=G-3gVoSrcm0”>http://www.youtube.com/watch?v=G-3gVoSrcm0</a>
</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>If you are anything like me, you like to learn new things, and find it fascinating how various areas of industry and science are all related. It’s far more fun to build and design something yourself then it is to just purchase somebody else’s junk.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>So what are you interested in? Can you find a tutorial on the subject? Perhaps a mentor? What’s stopping you? Go on out and do it!</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>See you next time.</p>
<p style=”padding: 0px; margin: 0px 0px 1.57em; font-family: Georgia, ‘Times New Roman’, Times, serif; “>-Ben</p>
<div style=”font-family: Georgia, ‘Times New Roman’, Times, serif; “>PS: Another great thing about PWM is the energy savings. If the LED is dimmed to half, it’s at a 50% duty cycle, meaning it really is on only half the time! Dimming a light suddenly means real energy savings! Try that in your off-grid cabin!</div>
<div style=”font-family: Georgia, ‘Times New Roman’, Times, serif; “>
</div>
<div style=”font-family: Georgia, ‘Times New Roman’, Times, serif; “>
</div>
<div>
<strong>
<em>
<font face=”Georgia, ‘Times New Roman’, Times, serif”>Ben Nelson is an enthusiastic amateur using low-tech DIY to save water, get off petroleum, and generally save the world. He built his own electric car and blogs at </font>
<a title=”300MPG.org” href=”http://300mpg.org”>300MPG.org</a>
</em>
</strong>
</div>
</span>