triangle wave vs pwm led brightness control

Discussion in 'General Electronics Chat' started by Macnerd, May 22, 2014.

  1. Macnerd

    Thread Starter Member

    May 22, 2014
    37
    1
    I'm a beginner when it comes to electronics.

    I just retired & I'd like to take up electronics as a hobby.

    I want to build an LED fader. I've seen faders on YouTube using triangle waves. Most of the LED faders that I've seen on YouTube use PWM.

    So, I've got some questions. Remember that I'm a newbie.

    If a triangle wave is graphed on an XY axis, X would be time but what would Y be? Why is the LED brightening & fading when a triangle wave is applied? Is the voltage changing or is the current changing?

    Why do most of the videos on YouTube use PWM to change the brightness of the LED instead of triangle waves?

    Basically, which would be better to change the brightness of an LED - triangle wave or PWM & why?
     
  2. Veracohr

    Well-Known Member

    Jan 3, 2011
    552
    76
    Y would correspond to voltage or current. Each LED would have a resistor in series with it, and a higher voltage results in higher current resulting in brighter LED.

    PWM is used more often because it can be controlled directly in the code of a microcontroller. If you're using a microcontroller, a triangle wave would require integrating the square wave coming out of the microcontroller, increasing component count.
     
  3. Alberto

    Active Member

    Nov 7, 2008
    169
    36
    In the Y axis you have voltage. In a triangular wave you have a voltage that start at zero and increase up to the maximum heigt of the triangle than it decrease with the same Slope to zero to restart again.

    You can turn a triangular wave into a pwm using a comparator and a pot. You fed the triangular wave to one input of a comparator, while on the other inputs you connect the pot wiper while the other two terminal of the pot will go one to ground and one to V+. You turn the pot and in the output of the comparator you will have your pwm ( with the pot you will control the Duty CYCLE, while the frequency will remain the triangular wave frequency)

    Cheers

    Alberto
     
  4. Sensacell

    Well-Known Member

    Jun 19, 2012
    1,134
    268
    The triangle wave idea is fraught with subtle problems- mostly the nonlinearities at low brightness levels that make for unsatisfactory visual results.

    PWM is more predictable, you can get good results with simpler circuitry.
     
  5. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
  6. Macnerd

    Thread Starter Member

    May 22, 2014
    37
    1
    Thanks for the reply.

    Eventually, I want to use a microcontroller. In the beginning, though, I'd like to try using ICs. You know, shift registers, 555 timers, logic gates, etc. The problem is that there are so many microcontrollers to choose from, PIC, Arduino, FPGA, etc. I wouldn't know which one to choose. Besides, I'd have to learn about the microcontroller & how to program it.

    OK. You state that the Y axis is voltage or current. An LED won't turn on above a certain voltage. You are probably right. A PWM circuit would probably be better.

    I don't completely understand how an op amp works. I know that there are 2 input voltages. So the output is either the sum or difference, right? Since the op amp compares 2 voltages, I would think that a regulated power supply would be required. If one uses a battery, wouldn't the output waveform change as the voltage drops on the battery?
     
  7. BobTPH

    Active Member

    Jun 5, 2013
    789
    114
    You are clearly not getting it. The triangle wave is not applied to the LED, it is used to construct the PWM signal. The voltage applied to the LED is either 0 or the full operating voltage. It is the percentage of time that the LED is on that controls the (apparent) brightness. Read the article linked by Bill.

    Bob
     
  8. wayneh

    Expert

    Sep 9, 2010
    12,157
    3,064
    No, without feedback the output is either the maximum or the minimum voltage that the op-amp is capable of with its power supply. Max or min depends on the relationship between the two inputs, which is higher voltage. Non-inverting input higher means max voltage out. Inverting input voltage higher means min voltage out.

    With feedback, the voltage can be controlled to some level between the rails. There are many possibilities including voltage follower (gain of one), or amplifier (gain>1).

    I'm not sure exactly what you are asking but yes, the range of voltage the op-amp can produce is determined by the power supply and the specs of the individual op-amp. The op-amp output range can only be smaller than the power supply range, although some are capable of "rail to rail" operation.
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,395
    1,607
    How op amps work is several topics to themselves.

    Yes they work by amplifying the difference of the two inputs.

    They are very good at ignoring noise on the power supply pins... As long as that doesn't approach the output voltage, less so with "rail to rail" types.
     
  10. Macnerd

    Thread Starter Member

    May 22, 2014
    37
    1
  11. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
    I've done it with a 555 and a couple of transistor. Chapter 12.
     
  12. BobTPH

    Active Member

    Jun 5, 2013
    789
    114
    If you are referring to my post about how the triangle wave is used to control the LED, you must have missed this:

    Which is exactly what I said. The triangle wave is used to make the PWM singnal.

    Bob
     
  13. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
    Actually you don't have to use a PWM signal, the 555 circuit I referred to 2 posts back was pure analog.
     
  14. Macnerd

    Thread Starter Member

    May 22, 2014
    37
    1
    Which is exactly what I said. The triangle wave is used to make the PWM signal.

    I'm an electronics newbie. So, the input to the transistor is a triangle wave & the output of the transistor is a square wave. Right?
     
  15. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
    You can do either, but some reading is required. The chapters I pointed you to explain it in great detail.

    A triangle wave can be used to make a PWM signal, or drive the LED directly. It is not the only way to make PWM however. PWM is fundamentally digital, so the output of the transistor should be a square wave. Things like resistors for the LED are still required.

    The secret to projects and learning is to break it down. Show schematics, they are the true language of electronics.

    If this is a project define what you want to do better.

    The infamous Chapter 12 has examples of PWM LED faders, as well as analog (triangle wave) faders.

    I like to explain things, which is why I wrote the articles. Ask questions, no one is going to make fun of you for a beginner question on AAC, this is pretty well enforced.

    BTW, the link on post #10 was an analog fader.
     
  16. Macnerd

    Thread Starter Member

    May 22, 2014
    37
    1
    Alrighty, then. I'd say that you guys have convinced me that PWM is a better way to control the brightness of an LED than a triangle wave. When I get around to doing my experiments with LEDs, I'll use PWM. So, for me, this concludes this discussion. Thank you for answering my questions. You guys can continue to discuss this if you so desire.

    I'm sure that I will have more electronics questions in the future.

    Thanks again.
     
  17. Wendy

    Moderator

    Mar 24, 2008
    20,766
    2,536
    Whatever works for you. Parts count is always an issue.
     
Loading...