Monday, 6 June 2011

PWM : Pulse Width Modulation

The Fading example demonstrates the use of analog output (PWM) to fade an LED. It is available in the File->Sketchbook->Examples->Analog menu of the Arduino software.
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of "on time" is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED.
In the graphic below, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.
Once you get this example running, grab your arduino and shake it back and forth. What you are doing here is essentially mapping time across the space. To our eyes, the movement blurs each LED blink into a line. As the LED fades in and out, those little lines will grow and shrink in length. Now you are seeing the pulse width.

Related Posts:

  • Auto Parkit fully-automatic parkade opens in LA Wouldn't it be nice to park your car at the end of a long day at the office without having to waste time (and fuel) driving in circles around a multi-tiered garage, or worry about putting your treasured ride in the hand… Read More
  • IRF ( MOSFETT ) IRF 540 merupakan salah satu transistor bipolar yang mana fungsinya adalah sebagai switching arus, dan selain itu juga IRF 540 ini juga berfungsi sebagi pembangkit PWM (Pulse Width Modulation) dimana putaran dankecepatan mot… Read More
  • Hybrid Humvee? US Army shows its diesel hybrid field vehicle Still think hybrids and green cars are meek and hipsterish? Plant your eyes on the US Army's Fuel Efficient ground vehicle Demonstrator Bravo. It's one of the burliest vehicles you've likely seen in years, and it's all… Read More
  • Tuk Tuk Factory launches all-electric e-Tuk Vendo When most people in the western world think of tuk tuks (if they even know what they are), they likely picture rather beat-up, primitive, noisy vehicles that zip around the crowded streets of exotic foreign lands. A Dutch… Read More
  • Brammo reveals pricing for Empulse electric motorcycles Brammo has revealed pricing and release details for its new Empulse and Empulse R electric motorcycles. Both models are specced at an impressive 100 mph (160 km/h) top speed and 100 mile (160 km) rang… Read More

0 comments:

Post a Comment