triangle wave vs pwm led brightness control

Thread Starter

Macnerd

Joined May 22, 2014
67
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?
 

Veracohr

Joined Jan 3, 2011
772
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.
 

Alberto

Joined Nov 7, 2008
169
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
 

Sensacell

Joined Jun 19, 2012
3,432
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.
 

Thread Starter

Macnerd

Joined May 22, 2014
67
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?
 

BobTPH

Joined Jun 5, 2013
8,804
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
 

wayneh

Joined Sep 9, 2010
17,496
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?
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).

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?
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
 

BobTPH

Joined Jun 5, 2013
8,804
Oh contraire!

http://www.youtube.com/watch?v=ys8ly6rArkM

LED fading by using a LM358 op amp.
If you are referring to my post about how the triangle wave is used to control the LED, you must have missed this:

The circuit creates a triangle wave that is used to turn a NPN transistor on and off which drives the LED
Which is exactly what I said. The triangle wave is used to make the PWM singnal.

Bob
 

Thread Starter

Macnerd

Joined May 22, 2014
67
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?
 

Wendy

Joined Mar 24, 2008
23,415
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.
 

Thread Starter

Macnerd

Joined May 22, 2014
67
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.
 
Top