PWM

Dec 05, 2009 12:06

I ordered some scuba gear during the sales last weekend. One of the items I purchased came with a free 1W LED flashlight (the yellow one on this page).

Yesterday at work-just for fun-I hooked the two lines going to the LED to my oscilloscope. Below are a couple of the screenshots I took of the signal.

The light has three brightness settings. This first screenshot is the "middle" setting. To vary the perceived intensity of the light, the LED is very quickly turned on and off. In this shot, you can see the the voltage is "high" for ~50% of the time, which means "half intensity." The yellow line is the analog probe's signal, and the red line at the bottom is the digital logic value (1 or 0, on or off).



In this screenshot, you can see that the voltage is "high" for only 25% of the time: that's the lowest brightness setting.



This technique is known as "pulse width modulation" or "PWM." You probably see it happening all over the place, and don't even realize it. Lights that fade on and off are probably using PWM.

For many circuits, you can use PWM to simulate analog output voltages on-the-cheap. For example, if your microcontroller can output 5V digital signals, you can simulate a 2.5V signal by having the output pin be "high" for half the time, and "low" for half the time (5V * 50% = 2.5V). For 1.25V, have it "high" for 25% of the time, and "low" for 75% of the time (5V * 25% = 1.25V). The percent of time the signal is "high" is called the "duty cycle."

Yeah. This has been covered a million times on the net and in books. But, I liked my screenshots, and decided to post them.

circuits, embedded, nerd, computer

Previous post Next post
Up