Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need a bit of help using a transistor as an on/off switch for an LED

Status
Not open for further replies.

Atheist

New Member
Hello All,

I have a 3V logic MCU and an LED with a typical forward voltage of 2.2V. I would like to use a GPIO pin of the MCU in conjunction with a transistor and a 9V source to enable digital control of the LED (either on or off depending on the low/high state of the GPIO). The reason for this is that the LED will probably be replaced with one which has a forward voltage of 4.9V in the very near future. But, for the sake of the work now, assume Vf = 2.2V for the LED.

I have added an attachment showing the circuit. It is the stuff on the right hand side of course.

I am doing something wrong with the below. Please read and let me know if you see it!

I want to produce a 10mA drive current to power the LED so I find Rc as:
Rc = (Vs - Vforward)/Ic => (9V - 2.2V)/(10*10^-3) = 680 ohms

I am using a 2N4104 transistor with Hfe = 1400 @ Vce = 5V and Ic = 1mA. A curve is not displayed to show any other points.

I find the value of my base resistor as
Rb = (Vmcu*Hfe)/(5*Ic) => (3V*1400)/(5*10*10^-3) = 84kohms


To test this I am using a prototyping board and a second power supply with grounds connected. The LED does turn on at Vb = 0.6V and the drive current, as monitored with a multimeter in line with the LED, does increase with increasing Vb. However, with Vb = 3V, the current in the collector, Ic, is only 7.1mA.

I checked the voltage drop across the LED and it is 2.3V. I checked Vce and it is 1.6V. Clearly I was forgetting to tabulate Vce into the earlier equation, but it has been a long time since I took an electronics course and I cannot recall nor find online how to take that into account correctly. What I would really like to do is to be able to say "okay, given this BJT and supply and microcontroller voltage, you can use these 1 or 2 quick formulae to find what resistors you need in the base and collectors to produce a given drive current for the LED." i can't think of how I can do that, though. Can someone point me in the right direction?

Thanks so much in advance.
 

Attachments

  • MS-ed_sensor-6_29_10.png
    MS-ed_sensor-6_29_10.png
    65 KB · Views: 208
Last edited:
Ha! An identical question. Silly me.

Thank you! I will check it out right now. I really appreciate your reply.
 
I could not find a datasheet for your rare old transistor.

hfe is AC current gain. hFE is DC current gain when the transistor has plenty of collector to emitter voltage and is not saturated like a switch.

For your switching transistor use a base current that is 1/10th the collector current so the base resistor should be 2350 ohms. 2.2k, 2.4k or 2.7k are common values that will work.
 
Thank you for the reply! I will have to look into why you suggest 1/10th of the collector current as that is not something that I am familiar with. I appreciate both of your comments very much. Audioguru, this is my second thread and you were likewise very helpful in the first. I very much appreciate you lending your clear expertise.

This morning I obtained 2N4401 NPN BJTs ( https://www.electro-tech-online.com/custompdfs/2010/07/2N2F2N4401.pdf ) and incorporated those into the LED driving circuit with encouraging results. The Vce drop appears to be drastically reduced such that the driving current to the LED using a 2.35k resistor on the base is much closer to the desired 10mA. I am looking forward to more projects involving transistors to sort of refresh my memory on there application as I seem to have forgotten much about their use. The much more complete data sheet for the 2N4401 makes it a lot easier for me to regain my bearings.
 
Okay, thinking about at I am assuming you made that recommendation as a sort of off hand `your current gain will be at least 10, so as long as you are over that much its just limited by the voltage/resistor on the collect`, is that the case?

I have a question now though..
When everything is on and the LED is working, why is it that when I measure Vce at the pins of the transistor my meter reads 0.07V?
 
The datasheet for nearly every little transistor lists its Max Saturation Vce Voltage when the base current is 1/10th the collector current.
The datasheets show a graph of the "typical" saturation Vce voltage when the base current is 1/10th the collector current.

Since you measured a saturation Vce voltage of only 0.07V then your transistor is typical and is a pretty good switch.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top