Maker Pro
Maker Pro

Education: Transistor as a Switch

haroldjclements

Oct 17, 2013
24
Joined
Oct 17, 2013
Messages
24
Hello forum,

I am after some education on using a Transistor as a switch. I have read a few help/tutorials pages, but I am just not getting it.
If you take the diagram below; this works exactly as I would expect. When there is a positive voltage on the base of the transistor, the switch is close allow the current and voltage flow from Vcc through the LED, Resistor, into the Collector, out the Emitter to ground. When no voltage is applied to the base, the no current is allowed to pass through the Collector to the Emitter. - As an extremely elementary explanation, I am happy with this.
LED_Collector.png
However, I would have throught that the same would be true if I reversed the position of the LED.

LED_Emitter.png
I don't understand why when a positive voltage is applied to base that the 5v does not flow from Collector to Emitter, thus light the LED - and act like a switch as per the first diagram above.

Any basic layman's explanation would be gratefully received.

In my example, I have used a single LED and a (slightly depleted) AA battery supplying the base current in my example, but the problem that I was trying to solve was that I have a common cathode RGB LED that is being controlled by PWM using an ESP8266, and I was hoping to repeat this circuit three times with three different pin-outs on the ESP connected to the base of the transistors.

Thanks in advance for your help,
Harold Clements
 
Last edited:

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,632
Joined
Nov 17, 2011
Messages
13,632
How about our ressource?


By the way, an additional resistor (e.g,. 100 kΩ) from the base to the ground (0 V) will ensure that the transistor is off when no input voltage is applied.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
The thing that you are missing is that it is the difference betrween the voltage on the base and that on the emitter, known as Vbe, that turns on the transistor. Vbe must be above about 0.6 V to turn it on.

In the first circuit, the emitter is at ground an the base is driven by the battery which puts a positive voltage on the base. This turns the transistor fully on.

In the second case, the LED and resisttor are between the emitter and ground. So, if the LED is to be on, the emitter has to be about 2V higher than ground, which means the base has to be at least 2.6V to turn the tansistor on. If you are using a 1.5V battery at the base, the LED cannot get enough voltage, and it will be off.

Raise the battery to 3V and it should turn on, though dimly becase the LED plus resistor will see only 2.4V instead of nearly Vcc like in the first circuit.

The answer to you problem is to use a PNP transistor. I will leave it as an excersise for you to figure out how to connect it and what signal would turn it on.

Bob
 
Last edited by a moderator:

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Also, 10Ω is way too low for the base resistor. This would generally allow enough base current to destroy the transistor. You are lucky you used a weak battery.

The correct value is one that would allow about 1/10 of the collector current to flow through the base,

Bob
 
Last edited:

haroldjclements

Oct 17, 2013
24
Joined
Oct 17, 2013
Messages
24
Thank you Bob, that was just the type of answer (or response) that I was looking for. So basically, with a NPN transistor, any devices connected from the Emitter to ground will only have < the voltage applied to the Base to be able to function?

Thanks for the PNP advice (and exercise... best way to learn).

Will also calculate the Base resistor correctly...

As always, I am very appreciative for your time and effort... Thank you

Harold
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
It is actually the voltage applied to the base minus about 0.6V since it takes that much to tirn on.

The circuit with the load between the emitter and ground is called a voltage follower since the output voltage follows the input voltage.

Bob
 

haroldjclements

Oct 17, 2013
24
Joined
Oct 17, 2013
Messages
24
So this is the circuit that came up with using a PNP transistor

PNP-LED (1).png
You have probably guessed my elementary problem. Regardless of whether I apply a positive current or take the base to ground, the LED lights. The only way I can turn it off is an open circuit to the base. Now I was expecting the PNP circuit to work in reverse - As in the LED would light when 0v (or tied to ground). I was also thinking that I would need some sort of NOT gate preceding R2 so that when I get the PWM signal from the ESP8266 it could invert.

Your help and suggestion is gratefully received...

Kind Regards,
Harold
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
Okay, if you need to interface to a signal that is active high, you will need an inverter for each color. You can use a CMOS hex inverter (CD4069), which has 6 of them in a single 14 pin IC.

Bob
 

haroldjclements

Oct 17, 2013
24
Joined
Oct 17, 2013
Messages
24
OK, but I am still unsure why, when I have positive voltage on the base, the LED lights. I expect it to be off.

Thanks again...
Harold
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
With a PNP transistor the voltage is still with respect to the emitter, and a negative voltage turns it on. In you example, the emitter is at 5V and the battery is at 1.5V so, it has -3.5V applied to the base resistor, which turns it on.

Bob
 

Cannonball

May 6, 2017
193
Joined
May 6, 2017
Messages
193
Hello to all.

Why not do away with the battery? Use a 10kΩ from the 5v supply to the base of the npn transistors. This should make either one of the npn transistor circuits work. Install the resistor from the base to ground in the pnp transistor circuit.
 

haroldjclements

Oct 17, 2013
24
Joined
Oct 17, 2013
Messages
24
Aa always I am so grateful that you are helping me ... Thank you.

So that means that if I am running an RGB LED (Red: 2v, Green: 3v, Blue: 3v) with all colours on full makes 8v. The PWM voltage from the ESP8266 is 3.3v. This means that the emitter will be a 8v, making base between -8v (ESP Output 0v) and -4.7v (ESP output 3.3v) meaning that the LED will never turn off.

Or do I have this completely wrong?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
The 3 LEDs are not in series, so their voltages do no add. Each of the anodes should be connected through its own resistor to the collector of a PNP transistor with the emitter to 5V, just like your schematic.

The base will be driven, through a resistor, by the output of an inverter, with the input connected to your PWM signal. The CD4069 should be powered 5V.

Bob
 

Cannonball

May 6, 2017
193
Joined
May 6, 2017
Messages
193
I was going by the schematics you provided. If you put three leds in parallel you will need to use a different resistor for each color to provide the current for each led to get the correct brightness for each led.
 

haroldjclements

Oct 17, 2013
24
Joined
Oct 17, 2013
Messages
24
Thanks Bob / Cannonball.

I have ordered some CD4069 devices. Whilst I await delivery, I will attempt to create my end goal schematic.

Thank you once more...
Harold
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
I think I screwed up. I looked at the 4069 datasheet and the min input for logic high is 4V, it will not work at 3.3V,

Instead you could use 74HCT04, which can work with a 2V input. Make sure the T is there in the part number, that is what specifies the lower logic level,

Bob
 
Top