Author Topic: Choosing right resistor for transistor base in LED matrix  (Read 274 times)

PGPG and 1 Guest are viewing this topic.

Offline kanaronTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
Hi
I want to create LED matrix 7x5 and I was wondering choosen resistors are correct in this case for transistor's bases and if this approach is valid at all.
If I understand transistors correctly then base resistor determinates current going into base and collector-emiter current is base current times beta. But in case of LED matrix collector current is changing. I'm multiplexing columns so one "row" NPN transistor will always have either one LED off or on so 0mA or 20mA on collector. But "column" PNP transistor can have 0-7 LEDs turned on so 0-140mA on collector. And this leave me puzzled because from my reasoning I have to use different base resistor depending on how much current is on collector. I checked part of this design on breadboard and with 1k resistor on PNP transistor base everything worked. Maybe current consumption showed on my power supply was lower than 140mA with all 7 LEDs on. But I just prefer to ask first if all of it is correct before ordering parts and PCB :)

If screenshoot is not readable then:
- base resistors for "column" PNP transistor is 1000 ohm
- current limiting resistors are 1 ohm (because voltage drop of LED in datasheet is from 2.6V to 3.4V and supply voltage is 3.3V then I assumed that 1 ohm resistor is probably ok in this case)
- base resistors for "row" NPN transistor is 3600 ohm

2331197-0
« Last Edit: Yesterday at 04:19:39 pm by kanaron »
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3142
  • Country: us
Re: Choosing right resistor for transistor base in LED matrix
« Reply #1 on: Yesterday at 04:44:39 pm »
1 Ohm is way too little for the resistors R51 - R55. If the LED voltage happens to be 2.6V and allowing 0.2V for CE drops, you'll have ( 3.3-2.8 )/1R = 500mA going through the LED.

I'd start with 100 Ohms and adjust from there.

I'm multiplexing columns so one "row" NPN transistor will always have either one LED off or on so 0mA or 20mA on collector. But "column" PNP transistor can have 0-7 LEDs turned on so 0-140mA on collector.

With your schematic I don't think you want to do it that way. I would have only one NPN on at a time - ie scan one row at a time. Then you can size the current limiting resistor for just one LED being on. Otherwise you have to pick a resistor value which will work for one to seven LEDs being on -- quite impossible.

« Last Edit: Yesterday at 04:49:36 pm by ledtester »
 

Offline Xena E

  • Regular Contributor
  • *
  • Posts: 247
  • Country: gb
Re: Choosing right resistor for transistor base in LED matrix
« Reply #2 on: Yesterday at 06:37:53 pm »
There's no need to explicitly calculate a base resistor for each current scenario.

Pick the maximum current that the driver transistor will have to handle, calculate the current needed to bias the transistor into saturation, collector current divided by worst case gain, (from the data sheet) multiplied by five¹ for a safety margin to ensure the transistor is fully saturated then from that figure calculate your resistor value.

¹Purely rule of thumb, basically the resistor is a current limiter it's just about keeping the transistor switched fully  on.

As for the shared current when multiple leds are on, either multiplex or give each led its own individual resistor from the bus lines.
 

Online PGPG

  • Contributor
  • Posts: 33
  • Country: pl
Re: Choosing right resistor for transistor base in LED matrix
« Reply #3 on: Yesterday at 06:43:30 pm »
And this leave me puzzled because from my reasoning I have to use different base resistor depending on how much current is on collector.

Your reasoning is wrong.
In such schematic you not regulate LED current with transistor base resistors. This resistors should insert into base enough current for transistor to be totally switched on. So if you know that maximum collector current is 140mA and beta is 100 you need to insert in base minimum 1.4mA. This will switch on the transistor but it will be poorly turned on. If in collector there will be 140mA than voltage drop at transistor (collector-emitter) will be about 0.7V, but when only one LED will be on the voltage drop will be 0.2V. And you will get different current in LEDs depending on how many of them are on. You should insert in base more current. The reasonable minimum in your case will be 140mA/20.
The same with npn transistors - minimum is 20mA/20.
Current in the LEDs should have been set by resistors that are in serie with them. Measure voltage drop at LED when 20mA is going through them and assuming that at pnp and npn transistors you have 0.2V calculate the LED serial resistors. 3.3V can be to small voltage if these are LEDs needing about 3V. Typical red LEDs have voltage drop around 1.8V.
To ensure LEDs will light more or less the same you should have a drop at these serial resistors about 1V. In other case you will notice difference in brightness as because of voltage drop differences at diodes you will get different currents and brightness depends mainly on LED current.

And one more thing. I understand that you tested how your LEDs shine and you assumed 4mA average current is what you need.
« Last Edit: Yesterday at 06:54:50 pm by PGPG »
 

Offline kanaronTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
Re: Choosing right resistor for transistor base in LED matrix
« Reply #4 on: Yesterday at 07:44:15 pm »
Thanks, I will make R51-R55 larger.

I would have only one NPN on at a time - ie scan one row at a time. Then you can size the current limiting resistor for just one LED being on. Otherwise you have to pick a resistor value which will work for one to seven LEDs being on -- quite impossible.

So... multiplexing by each LED one by one? Then each row will take 7 times longer and entire matrix will takie 35 times longer to multiplex. It is simpler and I would only need 74HC164 shift registers for columns and rows and I could get rid of HEF4094 shift and store registers. I will test this approach tommorow to check if that 35 times longer for a matrix is visible or not. But based on my previous tests I think 1/35 duty cycle will result in much dimmer or almost invisible dots

Quote
As for the shared current when multiple leds are on, either multiplex or give each led its own individual resistor from the bus lines.
Thanks, I will calculate it as you said. And I think I will go with individual resistor per led. I'm already scared of soldering session (or weeks of soldering) as I have to place 24 of these matrixes on 10x5 cm space... 840 leds and now 840 resistors next to each led ;D

Quote
3.3V can be to small voltage if these are LEDs needing about 3V. Typical red LEDs have voltage drop around 1.8V.
Well, these leds are green and in datasheet it says that voltage drop is 2.6V - 3.4V... I'm not sure why there is 0.8V disperssion. Is it voltage range on which leds will be on or are there manufacturing errors and one led will have 2.6V drop and another could have 3.4V... I hope not the latter...

Quote
To ensure LEDs will light more or less the same you should have a drop at these serial resistors about 1V. In other case you will notice difference in brightness as because of voltage drop differences at diodes you will get different currents and brightness depends mainly on LED current.
If I should have 1V drop on resistor then for sure 3.3V supply can be too small. However brightness difference is not a big problem as for most of the time majority of leds will be off. Some of them will show few digits and other will not show anything most of the time. Of course I hope that we are not talking about massive brightness differences

Quote
And one more thing. I understand that you tested how your LEDs shine and you assumed 4mA average current is what you need.
Well I didn't test these particular leds as I still have to make a decision about package. I hoped for 0603 to make it easier to solder but if I have to place resistor next to each led then I think I will have to go with 0402. I tested this with factory made green led matrix 7x5. I hope there wont be much of a difference
« Last Edit: Yesterday at 07:46:26 pm by kanaron »
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5114
  • Country: ro
  • .
Re: Choosing right resistor for transistor base in LED matrix
« Reply #5 on: Yesterday at 08:20:36 pm »
Well, if you want to make it yourself, I would say make it as bright as you want. 

You will light up either one row out of 7 at a time, or you'll light up one column at a time out of 5...

So any led will light up 1/7 or 1/5 of time, which means  you can run the leds at currents higher than default current, because they'll have time to cool down.

For example, lots of leds rated for 20mA will also be rated for 100mA at 1/10 duty cycle (ex run for 10ms, off for 90 ms or something like that) so you could configure the default current at 40-50mA and as long as you don't screw up your code and keep looping through the leds, you'd be fine.


A slightly better solution would be to use led driver chips.

The easiest would be to use chips designed to run seven segment digits... lots of chips are designed to control between 4 and 16 "digits" , with anything between 7 and 16 "segments". You just tell the chip which segments to light up, and the chip will take care of looping through the digits updating the segments.

So in your 7 x 5 matrix , you could treat each group of 7 leds as the segments of a digit, and therefore you have 5 digits with 7 "segments" each.

TM (Shenzen Titan Micro) makes a bunch of seven segment led drivers that are very easy to use.

For example

TM1640B  can do 16 digits, each with 8 segments : https://www.lcsc.com/product-detail/TM-Shenzhen-Titan-Micro-Elec-TM1640B_C2962200.html

You could literally have 3  8x5 matrixes controlled by a single chip, or you could link together 3 "grid" pins at a time so that each of the 5 rows/columns will light up 3/16 of the time.

TM1638 can do 8 digits, each with 10 segments : https://www.lcsc.com/datasheet/lcsc_datasheet_2401261512_TM-Shenzhen-Titan-Micro-Elec-TM1638-TA2009B_C20611979.pdf

So you'd have 16  5 led columns, basically 2  7x5 matrixes.

TM1629B can do 8 digits, each with 14 segments : https://www.lcsc.com/datasheet/lcsc_datasheet_1809191914_TM-Shenzhen-Titan-Micro-Elec-TM1629B_C46800.pdf

So you could use 14 segments to control 2  rows of 7 leds  .... basically you have 16  7 led lines, so you could control 3  7x5 matrixes with a single chip


All these are super cheap, like 10-20 cents ... cheaper than buying the pnp transistors and resistors and use much less space on a circuit board. They're also not that hard to solder on a prototyping board, you could just bend the leads or use a small soic / tssop to DIP adapter board..

There's also DIP versions but more limited ex TM1637 (6 digits, 8 segments per digit) : https://www.lcsc.com/datasheet/lcsc_datasheet_2401261512_TM-Shenzhen-Titan-Micro-Elec-TM1638-TA2009B_C20611979.pdf  or TM1630  (5 digits x 7 segments or 4 digits x 8 segments ) : https://www.lcsc.com/datasheet/lcsc_datasheet_2209231730_TM-Shenzhen-Titan-Micro-Elec-TM1630_C5174529.pdf




There's also dot matrix" led driver chips.  For example, have a look at

IS31FL3738 : https://www.digikey.com/en/products/detail/lumissil-microsystems/IS31FL3738-ZLS4-TR/14308389

It's a 8 x 6 matrix driver, so you could easily do a 7x5 or 8x5  or 8 x 6 matrix - you may want 8 pixels because it makes it easier to make custom "fonts" / "characters"

Compared to the previous drivers, this driver lets you compare the maximum current through a single resistor, then you can set the brightness of each individual led to whatever level you want. So you can for example set the maximum current to something like 40mA because the actual average current on a led will be 1/6 or 1/8 of that)


« Last Edit: Yesterday at 08:22:09 pm by mariush »
 

Offline kanaronTopic starter

  • Newbie
  • Posts: 3
  • Country: pl
Re: Choosing right resistor for transistor base in LED matrix
« Reply #6 on: Yesterday at 08:35:35 pm »
Well, I have never heard of LED drivers, you always learn something new :) I will for sure take a look at this tomorrow, thanks a lot :)
 

Offline mariush

  • Super Contributor
  • ***
  • Posts: 5114
  • Country: ro
  • .
Re: Choosing right resistor for transistor base in LED matrix
« Reply #7 on: Yesterday at 09:43:43 pm »
Yeah, I should add ... there's dot matrix drivers that can go up to 350+ single color leds, I just gave you one that can do more than 7x5 leds and is easier to solder.

There's for example IS31FL3733B that can do 192 leds in a 16 x 12 matrix (but you can rearrange it as 8 x 24 or other patterns) : https://www.digikey.com/en/products/detail/lumissil-microsystems/IS31FL3733B-TQLS4-TR/12675547


If you want to keep it more basic, instead of individual transistors, with your 7x5 arrangement, you have the option of using chips like ULN2003A  which has 7 darlington transistors inside along with the base resistors. 
So basically, you put a voltage on one of the 7 input pins, and that channel is connected to ground. 

Because you're dealing with darlington transistors there's around 1v drop in the chip, so you have to account for that when you calculate the current for the leds.

For example, let's say you power with 5v , your red leds have a 1.8v forward voltage, and you want 20mA (0.02A) per led... then you'd set the current to  5v - 1.8v (drop on led) - 1v (drop in transistor)  = 0.02A x Resistor  ... so Resistor = 2.2v / 0.02A = 110 ohm

You can get these ULN2003A for pennies in DIP packages : https://www.lcsc.com/search?q=uln2003a

If you don't mind surface mount, you can go with the mosfet version ULN2003V12  which replaces the darlington transistors with mosfets, so it doesn't have that 1v drop, otherwise works the same : https://www.lcsc.com/search?q=uln2003v12

It also contains all the gate resistors, esd protections, everything inside.

so you can use uln2003A / uln2003v12 to connect to ground 7 leds, which means you'd rotate through 5 columns giving power to one column at a time.

This means each column may need up to 7 x 20mA = 140mA if you want to limit the single leds to 20mA, so you'd want pnp transistors or p-channel mosfets capable of at least 200mA.


There's loads that can do more than 200mA : https://www.digikey.com/short/mrvj1jb5

For example BC807 can do up to 500mA, and has a hFe of at least 100, so with just 3-5mA you're more or less fully open the transistor.  Basically, I'd just use a 100 ohm resistor on the base, but probably could go up to 330 or so without any issues.


There's dual pnp transistors or dual p-channel mosfets if you want to reduce component count.



 

Online PGPG

  • Contributor
  • Posts: 33
  • Country: pl
Re: Choosing right resistor for transistor base in LED matrix
« Reply #8 on: Yesterday at 10:57:20 pm »
Well, these leds are green and in datasheet it says that voltage drop is 2.6V - 3.4V...

In past all red LEDs worked with about 1.8V drop and green with about 2.0V. Green LED needed higher current to light comparably with red once.
Some years ago new green LEDs appeared. Working with much higher voltage and needing much less current. For signalling I use such green LEDs powering them with around 1mA while those old needed about 10mA.

I prefer to drive LEDs with current source so I don't care if voltage drop is 2.6V or 3.4V. Where from is such big voltage drop difference I don't know. Is it temperature change or manufacturing serie versus serie.
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3142
  • Country: us
Re: Choosing right resistor for transistor base in LED matrix
« Reply #9 on: Yesterday at 11:12:02 pm »
Quote
So... multiplexing by each LED one by one? Then each row will take 7 times longer and entire matrix will takie 35 times longer to multiplex.

With the way you have set up the resistors you should scan the display row by row, not column by column.

Also, if if your LEDs are bright enough with just 1mA of current you can get rid of both NPN and PNP transistors.

The 74HC164 can easily source 1mA per output pin and the HEF4094B can also easily sink 5mA from its output pins.

Datasheets:

https://www.diodes.com/assets/Datasheets/74HC164.pdf
https://assets.nexperia.com/documents/data-sheet/HEF4094B.pdf
« Last Edit: Yesterday at 11:44:25 pm by ledtester »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf