1
\$\begingroup\$

I am programming a PWM controlled breathing LED with RPi.GPIO Library in Python on my Raspberry Pi 2. The problem is I understand what the frequency does and what the duty cycle is but not how these play together.

Can somebody explain PWM to me? :) Thank you so much

\$\endgroup\$
3
  • 2
    \$\begingroup\$ There are TONS of information on PWM like everywhere. Do a little reading. \$\endgroup\$ – Eugene Sh. Mar 14 '16 at 19:44
  • \$\begingroup\$ See Sparkfun's PWM tutorial. \$\endgroup\$ – uint128_t Mar 14 '16 at 19:45
  • 2
    \$\begingroup\$ If you understand what the frequency does, and what the duty cycle does, then you understand it all, no need for the question. Perhaps you'd explain in the question what you think the frequency does, and you think the duty cycle does, and then we can correct any misapprehensions. \$\endgroup\$ – Neil_UK Mar 14 '16 at 19:47
4
\$\begingroup\$

To a first approximation, frequency does not matter at all, provided it's fast enough to avoid the appearance of blinking. All that's important is the average power of the LED, which depends only on the duty cycle.

In practice, there are switching losses that increase with frequency. Each transition from high to low requires some amount of energy, such as to charge or discharge the gate capacitance of a MOSFET. There is also a transitional period where the transistor being switched is neither fully off nor fully on, and thus dissipates more power than it would at either extreme. With increased frequency, this energy cost is paid more times per second, thus losses go up.

Furthermore, parasitic components (the inductance of traces and leads, and their capacitance, among other things) becomes increasingly significant with increasing frequency, making design more challenging. At some point the circuit stops being a blinking LED, and becomes a radio, giving rise to a whole new world of design problems.

\$\endgroup\$
3
  • \$\begingroup\$ +1 for "stops being a blinking LED, and becomes a radio" \$\endgroup\$ – tcrosley Mar 15 '16 at 0:56
  • \$\begingroup\$ Ah thank you. I thought something in that direction with the importance of frequency. If I change my duty cycle faster than the frequency is then some DC changes get lost. But what I didn't understand was when I turned the frequency up from 1 to 10kHz that the LED just showed off - 50% - 100%. \$\endgroup\$ – steveroch-rs Mar 15 '16 at 16:04
  • \$\begingroup\$ @steveroch-rs Perhaps when you are adjusting the frequency, you are in fact changing the duty cycle also, due to some unconsidered aspect of your circuit. Looking at the voltage across the LED versus the output of your PWM generator with an oscilloscope would be a good thing to do: verify that they are both clean square waves with similar duty cycle. \$\endgroup\$ – Phil Frost Mar 15 '16 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.