Best way to drive a LED with an NPN (for an LFO)

Started by drolo, April 08, 2014, 12:24:39 PM

Previous topic - Next topic

drolo

I can't seem to find some clear info about the differences between doing this:



and this:



Are there any differences/drawbacks when using this after an LFO? (in my case a PWM signal)

Subsidiary question: How should the resistor going to the base of the transistor be sized?

mth5044

You typically see them with the emitter grounded - I'm not too sure why though.

I use 100k on the base when using 2N3904's with a PICAXE.

armdnrdy

#2
You can also put the current limiting resistor between +9V and the collector and the LED between the emitter and GND.

Are there any differences/drawbacks when using this after an LFO? (in my case a PWM signal)

There shouldn't be...the LFO is isolated from the LED by the transistor which should use very little voltage and current.

Subsidiary question: How should the resistor going to the base of the transistor be sized?


I usually start with a 10K, but the size might vary depending on the LFO.
I just designed a new fuzz circuit! It almost sounds a little different than the last fifty fuzz circuits I designed! ;)

Seljer

#3
First one is common collector circuit, its basically a emitter follower i.e. a buffer. The voltage over the LED+resistor is basically whatever the input is minus the voltage drop over the base-emitter junction (say 0.6V). Its got a high input impedance an won't load down the preceding stage too much. The base resistor doesn't have a profound effect (it even works fine without it) unless you make it so big that minuscule current running over it start making a voltage drop.

The relation is output voltage : input voltage  = roughly 1:1 (minus that base-emitter drop)


The second circuit is a standard common emitter amplifier. It amplifies the current coming into the base. The relation here is output current = input current * gain. If you hook up a voltage source to the input, the base resistor converts the voltage into a current. In this circuit the LED starts emitting light as soon as the input voltage overcomes the 0.6V base-emitter junction of the transistor and a current starts flowing over the resistor into the base.


Heres a little circuit simulation of what happens with the LED current in both circuits as the input voltage rises




In the first circuit whatever you're driving it with has to take into account that you need about 2V before the LED starts conducting and lights up. The second one lights up much quicker.

I'd go with the second circuit. If you have a 5V PWM signal it'll let you fully exploit the 9V power supply for powering the LED. If saturated the voltage drop over the transistor will be negligible. About 10kiloohms on the base should be more than enough to make sure the transistor is fully open and the only thing limiting the current is the resistor in series with the LED.
If you want a more linear response between input voltage and LED current increase the size of the base resistor, this basically flattens the curve and by making it saturate at a later point (probably something between 50kiloohms and a couple of 100kiloohms).

GibsonGM

What we're looking at is essentially high side vs. low side switching....for other applications, there can also be some things that need to be considered regarding external components.  Some of this is touched on here: http://jeelabs.org/2012/11/11/low-side-switching/    A web search will find tons of information on which is best to use for specific applications.

What we really want is something more linear, I believe.

For an LED being used for our purposes, Seljer has really hit on the most important elements to us, and I'd go with what he's saying.  #2 is far more linear, more suited to what we'd be doing with the LED.
  • SUPPORTER
MXR Dist +, TS9/808, Easyvibe, Big Muff Pi, Blues Breaker, Guv'nor.  MOSFace, MOS Boost,  BJT boosts - LPB-2, buffers, Phuncgnosis, FF, Orange Sunshine & others, Bazz Fuss, Tonemender, Little Gem, Orange Squeezer, Ruby Tuby, filters, octaves, trems...

armdnrdy

Thanks for the clarification Simon!

I always use the second configuration for an LED driver.
I just designed a new fuzz circuit! It almost sounds a little different than the last fifty fuzz circuits I designed! ;)

R.G.

Let's think about circuits for a minute.

An NPN is a device that amplifies the current inserted into its base by the HFE of the transistor. The collector is a fairly constant current source that may be at any voltage required by the load and permitted by the power supply and Mother Nature's other Laws. (For the inevitable reviewers, yes, I know that there are fancier views of how transistors work but let the guy get straight with the simplified version before confusing him.)

The grounded-emitter setup is in effect, a current amplifier with no feedback.

If you put an impedance in the emitter-to-ground, putting a voltage on the base raises the base, increasing the base-emitter current, which raises the emitter, which counteracts the rise in base voltage, producing the emitter follower. The EF is a 100% negative feedback setup which acts like a variable voltage source following (well duuh!) the base.

The first setup, the emitter follower, produces a voltage on the emitter that follows the base. Nothing happens until the base gets higher than one Vbe plus the forward turn-on voltage of the LED, and after that the voltage at the emitter rises, following the base, and a current flows through the resistor and LED that is (Vemitter-Vled)/R. The base current needed to support this is only (Vemitter-Vled)/R divided by the HFE, and may be quite small, as that is what emitter followers do.

So for the first, EF, circuit, the base signal needed is a large voltage drive, and nothing happens until it gets bigger than the LED turn on voltage plus the base emitter turn on voltage. Depending on the value of R, the base voltage change needed may be large or small. Large R gives you better control, but needs a big base signal; the advantage is that the base resistor can be as little as zero. Small R for the LED means quick turn on, quick saturation, but the base R needs to limit base current.

The second circuit is a current amplifier. Output current is base current in times HFE. Base current is the input voltage signal minus one Vbe turn on voltage divided by the base resistor, independent of what the load is doing, so you have good control of the base current. The output collector side conducts the collector current proportional to Ib times HFE up until something limits it - that limit being the LED and its resistor. You need the resistor, as if the resistor is too small, very large currents can flow and kill the transistor and the LED. With the resistor, the current is limited to [(Vpower supply)-(Vled)-(Vsaturation)]/Rled. With base currents larger than just barely enough to make this happen, the transistor acts like a switch, not an amplifier, and the LED turns on and off, not proportional brightness.

The EF circuit is good if you want to modulate the LED brightness and tinker with the base voltage to do it. The grounded-emitter circuit is good if you just want to switch the LED on and off.

There are better ways to do proportional brightness on the LED than the EF circuit IMHO, so I never use it. If I want proportional brightness, I use an opamp or a current mirror.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

drolo

Thanks all for your answers.

I did a bit of simulation after reading your comments and am slowly understanding this better.
At first I thought that Seljer and RG's recommendations were contradictory but upon a bit of re-re-re-reading and some testing, I get it now.

The common Emitter (green curve) indeed acts as a switch but when I increased the base resistor I could get it more or less linear (except for the bottom bit under Vbe)



With the Emitter follower (blue curve) I could not get it linear no matter what I tried.

I was able to get the missing bottom part with adding a resistor between c & b :



That looks better already



let's see how this will translate into phasy goodness :-)






R.G.

Quote from: drolo on April 08, 2014, 06:17:38 PM
The common Emitter (green curve) indeed acts as a switch but when I increased the base resistor I could get it more or less linear (except for the bottom bit under Vbe)
With the Emitter follower (blue curve) I could not get it linear no matter what I tried.
Again, let's do some thinking. The bottom line is that both are linear (ish) when you get them out of the range of input signal and operation where either the base-emitter can't turn on, the LED can't turn on, or the transistor saturates. It's just that the base-emitter junction turns on at a much smaller voltage than the LED, and the LED forward voltage is a Big Deal to how early the emitter follower turns on. So the nonlinear part is big compared to a 9V supply.
Quote
I was able to get the missing bottom part with adding a resistor between c & b :
That looks better already
... and you have reinvented the voltage-feedback amplifier stage! This stage is used where you have to make the very most of a limited power supply or swing the maximum of the available power supply.

Here are some other options.

It will sound a little silly, but any part in the feedback path of an inverting opamp stage is conducting a current equal to the voltage fed to the resistor on the (-) input divided by the resistor. This is very, very, very linear. It seems odd to use an opamp to do this, I know, but it works very well indeed.

Another dodge is a current mirror. It's easy enough to make an opamp stage or even an NPN transistor stage suck a linear amount of current from the (+) supply. That is in fact how linear amplification works with NPNs. You can make the NPN's load be a PNP current mirror from the + supply, and "reflect" that current from the NPN collector into a current into a resistor - or LED! - or whatever to ground. And even better, you can gang up several PNPs and have multiple, independent, but matching currents into various loads to ground.

Finally, the concept of linear swing is suspect. Linear is OK for small excursions, but as I once read, what your ear really wants is an exponential swing.

Ahah! Semiconductor physics to the rescue! The current in a semiconductor junction is an exponential function of the voltage across it. All you have to do to get an exponential current from a linear input is to drive a junction with a current limited voltage. The current limit is to keep things from becoming light emitting (you know, light emitting resistors, light emitting capacitors, etc.  :icon_biggrin: ) if the voltage wavers up a bit too much.

So if you can drive a current mirror input with a voltage sourced signal from 0V to the forward voltage, the junction current, and hence the output current, is an exponential function of the input voltage, and if you're using the current for driving LEDs, the LED light output is approximately exponential.



R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

PRR

> the differences between

Stop thinking in CMOS (where outputs pull all the way to the rails).

In RTL and TTL the "switching level" is low. 1.2V for TTL and lower for RTL?

There's no point in outputs going higher; they just have to come down sometime, and the more swing the less speed.

Real TTL will get close to 4V, but the specs say 3.5V.

With your cathode follower: 3.5V minus 0.6V minus 1.6V leaves only 1.3V across the current-setting resistor. Less if you use other colors than red. And all these voltages have part-volt errors (such as 4.0V vs 3.5V) so your actual resistor current, and LED current, is VERY uncertain.

With grounded emitter, the input threshold is 0.6V. You do need a base resistor (the emitter follower didn't). This commonly works on TTL's 1.2V thresholds (since low is often <0.2V), but for life-critical LEDs you should use a voltage divider into the base.

Your "+9V" points another problem (perhaps touched by the other responses). Even 5V CMOS only swings to +4.5V. These days your CPU is likely to be 3V.  So even with CMOS tech, your emitter follower leaves hardly-any voltage across your limiting resistor. Which is silly when 9V is available. Get the base turned-on by whatever few-Volt logic you have, then trust that Ic=Ie and string your resistor and LED from collector to +9V.
  • SUPPORTER

drolo

Thanks again for your insights Paul and RG

RG, i will surely look into current mirrors for a next build. For this one I had already a PCB made before realizing that using an EF was perhaps not the best method (even if the phaser actually sounds good). I am trying to find a way to accommodate the common collector method into my existing PCB (will try with a pnp and increase the base resistor). I would normally have used an opamp but I have 3 Vactrols to drive and thought it would be too much for one op amp, 3 bjt's were easier to layout and more compact than 3 opamps.

samhay

#11
This has made for interesting reading.
One thought, to follow up on Seljer's comments - do we actually always want a linear relationship between control voltage and LED current?

Our visual perception of 'brightness' is not linear, so as a first approximation, you may need e.g. 10x more current through an LED to make it look twice as bright. An exponential relationship may be more effective here.

What is the relationship between the LED current in a vactrol and the corresponding resistance of the LDR?
^(even if the phaser actually sounds good)
In this case, if it sounds good, and the LED is not seeing too much current, then it probably is good...

Edit - hit enter before I was finished.
I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

drolo

That's a valid point. LDR's are hardly linear ...

samhay

I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

drolo

Quote from: samhay on April 09, 2014, 05:25:58 AM
Indeed.
Is the phaser a new design?

Not really something new, just something I have been tinkering with.

An 8 stage phaser derived from the Mutron Phasor II (adapted for 9v supply) fed by a TAPLFO
Will post the results in a new thread soon

samhay

I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

duck_arse

Quote from: drolo on April 08, 2014, 12:24:39 PM

Are there any differences/drawbacks when using this after an LFO? (in my case a PWM signal)


a PWM signal would be a square wave, no? in that case, led only goes on-off-on etc. not very linear.
" I will say no more "

drolo

Quote from: duck_arse on April 09, 2014, 12:00:03 PM
a PWM signal would be a square wave, no? in that case, led only goes on-off-on etc. not very linear.

You're right, I was so absorbed thinking about the resulting waveform and getting the led current to follow it that I forgot it was PWM...

So in this application, does one have to consider the average voltage the PWM creates or just treat the transistor as just a switch that is fed 5V impulses?
Sorry if this seems evident but I'm still trying to wrap my head around this PWM stuff ...

mth5044

I'm trying to figure something similar out with the TAPLFO. If you look at the datasheet, I believe it's the first schematic, shows how to filter the PWM into a 0-5V analog voltage after the first two opamps. The second to filter to a 10Vp-p.

I have the TAPLFO with the first two opamps on my breadboard, but things seem to be amiss when the opamps aren't powered by +/-15V rails... Very amiss.

drolo

Quote from: mth5044 on April 09, 2014, 02:02:21 PM
I'm trying to figure something similar out with the TAPLFO. If you look at the datasheet, I believe it's the first schematic, shows how to filter the PWM into a 0-5V analog voltage after the first two opamps. The second to filter to a 10Vp-p.

I have the TAPLFO with the first two opamps on my breadboard, but things seem to be amiss when the opamps aren't powered by +/-15V rails... Very amiss.

I breadboarded the filter once but I'm not sure it was working correctly either. In my case, since I'm driving Vactrols luckily I don't need to filter :-)