basic backlight

User avatar
DiodeHead

14 May 2018, 17:22

hi guys, I need I little help with a topic that would be very basic to some. I have a project in mind and it involves backlight, it has 50 keys each one with it's corresponding led, as features I only want to control brightness.

Image

this is how I would do it, but I don't know if this method is correct or even possible. this is a simplification and the schematic would have the 50 LEDs. I'll be using 3mm bright white LEDs, I'll try to find out their forward voltage.

and what transistor to choose is another question, since MCU pins usually have a 20ma - 40ma I think this is the way to drive the LEDs, but I don't know if the 5v USB rail has enough juice to drive all those LEDs, 200ma was the maximum current??

thanks in advance :)

Anakey

14 May 2018, 18:54

hmm i think your idea is mostly correct, however i think you will be wanting to run all the LEDs in paralel ideally each LED would also have its own resistor, however if the current is low enough then the number of resistors may be reduced. I have recently put side lighting onto my handwired build at first it was 10x2 so 10 lots of 2 paralel and the current was in micro amps with no resistor at all and the LEDs barely glowed, after it was wireing all 20 in paralel and now they glow fine, still need to fine tune the final resistor value to get the balance of brightness to curent but it will do for now. Also I think you might need a resistor between the MCU_PWM and the transistor also depending on your transistor.

User avatar
vvp

14 May 2018, 20:25

@DiodeHead
You nay want to read this post. It will give you some hints how to do it.
You will need the resistor Anakey mentions if you would use some bipolar transistor. If you would use some FET then there is no need for the resistor.

zool

14 May 2018, 20:32

you cant run that many LEDs is series like that with a 5V supply.
this will help you with the power requirements:
http://led.linear1.org/led.wiz

User avatar
DiodeHead

14 May 2018, 23:09

:) thank you very much, I'll read it and try to put something together as soon as possible. :)

User avatar
DiodeHead

15 May 2018, 16:00

well, the one's that I have are 2.8v forward voltage, I guess that they should be as Anakey said, all in parallel with their individual resistors.

If I put one on my bench power supply they get very nice and bright with 3v and 0.01amps so in the program that zool recommended I wrote:

5: Source voltage
3: diode forward voltage
2: diode forward current (mA) Help
50: number of LEDs in your array

this gave me an individual resistor of 1k and a total consumption of 100ma, which I have to test and see if I did make any mistake in the calculations, but this configuration should give me a very bright backlight that I would be toning down with the PWM.

thanks a lot for the help. :)

Anakey

15 May 2018, 16:13

0.01A on your bench supply = 10mA if you are happy with the brightness level then the diode forward current would be 10mA.

User avatar
DiodeHead

15 May 2018, 16:18

haha thanks a lot, hmm I was testing right now and I was wondering where some of that brightness went, I still don't know why I put there a 2

Anakey

15 May 2018, 16:24

you would probably need to reduce the current to below 10mA anyway, as 10mA x 50 LEDs = 500mA which is going to potentially overload the PC USB controller as most do not like going over 500mA for the USB.

User avatar
DiodeHead

15 May 2018, 16:37

I went with half that (470 ohms) and I'm still happy with brightness but I think I should be aiming for something like 250ma including full brightness and MCU running, isn't it?

Anakey

15 May 2018, 16:40

you should be ok with about 400mA total for your LEDs which would give a forward current of 8mA for each LED.

zool

15 May 2018, 16:48

300mA total is really safe for pretty much everything, and that is really only on low power ports or older systems.
micro will draw very little lets say ~30mA to be on the cautious side for an at32u4.

User avatar
DiodeHead

17 May 2018, 16:13

hmmm then is settle the 470 ohms resistor it is, I'll then end up with a total current of 250ma + MCU.

For transistors, I have to order some 337 (that is what I'm seeing in most Arduino tutorials with a 2k2 resistor) since all I have on hand right now is 2n3906 and those are rated for 200ma if I'm not mistaken reading the datasheet. but at least I would like to code the PWM part, can I use a 2k2 resistor with this transistor too? how can I calculate that resistor?

thanks :)

zool

18 May 2018, 01:18

If you just wanna write your pwm code, just drive a LED with a limiting resistor directly from micro pin.

Else do you have a circuit with the question? not a 100% which resistor you are talking about.
An NPN tranny circuit will be a little different.

User avatar
DiodeHead

18 May 2018, 08:42

you're right, but I wanted to do it with the transistor to see what problems I would encounter and found out, they are little fragile creatures, I'm also making a tube amp and tubes support much more abuse, I already have burnt two of them (transistors), but the third one is hanging in there.

My question was if there's some kind of rule of thumb for knowing if I would need a resistor to drive it ( for example you guys told me if its a fet I don't need it) and if need the resistor how to calculate (for example, look for this in the datasheet and apply ohms law knowing that your pin supports around 20-40ma)

But maybe this is too broad of a question, anyways this weekend with more time I´ll try to read on transistors since as you can see my knowledge is very basic :)

zool

19 May 2018, 02:59

"poof" ahh f!. is the way we all learn :) parts are cheap, pencil and paper is cheaper.

User avatar
vvp

19 May 2018, 20:51

You need a transistor when the LEDs powered by by an MCU pin need more current than one MCU pin can provide.
Typically, an MCU pin current rating is at most about 20 mA. E.g. if your LED would use 5 mA forward current then you can put at most 4 such LED in parallel at one MCU pin without a transistor. Also notice that most MCUs have maximum limit for current from all the MCU pins together. This can be e.g. around 120 mA (some STM32 models). In such a case you can have at most 5-6 pins powering LED directly (while each pin is limited to at most 20 mA). It is also common that some MCU pins have smaller current rating than others. Read the data sheet for your MCU of choice.

If you insist on a bipolar transistor then you need to consider, current amplification of the transistor α (often around 100), and forward base-emitor voltage drop Vbe (often around 0.6V). Then you can compute your base resistor Rb:
Rb = (Vcc - Vbe) / Ib
Ib = Iled / α
Ib - current through base (must be less than maximum MCU current rating)
Iled - required current to power LEDs
Vcc - power voltage of the MCU

Just use a FET a be done with it. Prefer FETs with enough source current rating and small gate-source capacitance. Use PWM at about 10 kHz or lower frequency and you can connect your MCU pin directly to the FET gate.

Post Reply

Return to “Workshop”