Go Down

Topic: Please help me understand this before i make my first matrix (Read 1 time) previous topic - next topic

Amn3sia

I'd like to make a 4x4 or 4x5 led matrix with my uno.
i think i got the basics down, and i know how to build it but there's still one thing that i don't quite understand yet. I'm new with electronics so bare with me please.

why exactly do i need transistors to drive the rows? if you scan through each row and collumn one by one, only a single LED would be lit at any given moment. which the gpio pins of the arduino is happy to drive.
or did i get this entire idea wrong?
am i supposed to do an entire row at a time, and pull every lit collumn LOW at the same time? wouldn't the voltage drop of the diodes prevent you from lighting more than a couple at a time with 5V?


I'm sorry if this has come up before. i tried searching around and didn't find anything.


I hope you can help me out.
Thanks in advance :)

PerryBebbington

Hello Amn3sia,
Welcome to the forum.

I saw this when you first posted it and I have been waiting for someone more knowledgeable than me to answer, they haven't so here is my answer....

If you have (say) a 4 x 4 matrix of 16 LEDs then you drive each LED only 16th of the time, so you need 16 times the current for each drive pulse to get the same perceived brightness as you would see if you just fed them with DC. The question therefore becomes not:

Quote
Why exactly do i need transistors to drive the rows?
But why are there not also transistors for the columns? You need transistors for the columns too for the same reasons. (I'm assuming in the circuit you have there are no column transistors! Please post your circuit).


Grumpy_Mike

Quote
But why are there not also transistors for the columns? You need transistors for the columns too for the same reasons.
It all depends on how you drive the matrix. You do not need transistors for the columns because they are only supplying the current for one LED at a time. Where as you do need transistors for the rows because they are sinking the current for the whole row.

See:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

CrossRoads

If you only drive One LED on at a time, with one column and one row, then you can get away with just 4 resistors to limit the current thru that one pair of pins, I'd suggest to limit current 20mA max (in case during your testing pins get left on full time so you don't burn up the IO pins or the LED) then calculating that the anode source will have 4.2V (min) on it and the cathode sink will have 0.9V (max) on it per the Electrical Characteristics section of the '328P datasheet with Vcc = 5V and Io = 20mA.
So using Red LEDs with Vf of say 2.2V, then 4.2V - 0.9V = 3.3V. 3.3V - 2.5V = 0.8V across the resistor, 0.8V/.02A = 40 ohm resistor.

The reason transistors are used is to allow higher current flows when driving a whole row or a whole column at one time, and 80mA can be turned on & off.  4 anodes can each have 20mA going out an Arduino pin and then a NPN transistor or N-channel MOSFET can be used to sink the 80mA of current for that column or row.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Paul__B

Mind you, while I realise this is nothing more than an "educational exercise" so you understand how these things work and will probably move on later, if you are serious you want to use a MAX7219 module, either with the display supplied or you can wire it to your own at any dimensions up to 8 by 8.

It does the job perfectly, and you can forget about how to multiplex.

Amn3sia

Thank you all so much for your replies. it makes a lot more sense now.
I think i'm going with the transistor on rows approach, and i think i almost got it, i just need a little help with the last few details :P
The only NPN transistor i could find 4 of was the C2878

will this do?
It's rated for 300mA which is more than enough to drive a row. anything else i should be looking for?

I've soldered all the LEDS and connected the rows and columns. So now i just connect each row to a collector, the base to any GPIO pin, and all of the emitters to the arduinos GND pin?
and shouldn't i also limit the current somehow in this case?
I haven't worked much with transistors. but the basic idea is that they amplify current in the base by it's hFE value, right? my guess is that i should let 20mA/750(hFE) through the base in order to achieve 20mA through the collector? according to my calculations i would need a 190k resistor between each transistor base and gpio pin, but i feel like i got the wrong idea here.

again, thanks in advance
you're all very helpful.



CrossRoads

Used like this, they are merely a switch and do not technically amplify anything.
You want to drive enough base current to get them into Saturation so you have minimum Vce, and let the choice of IO thru current limit resistor and Vf determine the current.

If it has Vbe of 0.8V for Ic of 100mA, then give it enough current to get there.
Output of (4.2V - 0.8V)/0.02 = 200 ohm.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Grumpy_Mike

Quote
I haven't worked much with transistors. but the basic idea is that they amplify current in the base by it's hFE value, right? my guess is that i should let 20mA/750(hFE) through the base in order to achieve 20mA through the collector?
No when dealing with the transistor as a switch you want the voltage between the collector and emitter to be as low as possible. This means not running the transistor in the linear mode where the hFE is important like you said, but in the saturation mode where the transistor turns on as hard as possible. To do this you have to flood a lot more current into the base. This saturation current will be stated in the data sheet, for your transistor the data sheet says:-
Quote
Collector-emitter saturation voltage
VCE (sat)
IC = 30 mA, IB = 3 mA

0.042
0.1
V
That is saying if you have a collector current ( IC ) of 30mA, to get the transistor into saturation you need a base current of 3 mA, and you will get a maximum of 0.1V between the collector and emitter, but on most transistors this will be more like 0.042V.

Notice that the base current is one tenth of the collector current. This is typical for a transistor and the rule of thumb is we say "the transistor has a forced gain of 10", that is, assume the hFE is 10 when calculating the base current.
So for a 20mA load you can have a base current of 2mA, but a current of 3mA won't do any harm.

Note this applies for small currents only, this is sometimes called the small signal characteristics.

PerryBebbington


Quote
It all depends on how you drive the matrix. You do not need transistors for the columns because they are only supplying the current for one LED at a time. Where as you do need transistors for the rows because they are sinking the current for the whole row.
Thank you Mike, that falls into the category of something I should have known! My ageing brain keeps letting me down :(

Amn3sia

I'm sorry for bumping a post this old, but i've been a bit busy and just finally found time to play around with this stuff again recently.

Thanks to all of you guys i was actually able to build my first little electronic something, and i had a bunch of fun coding animations for it.
I just wanted to let you all know how much i appreciate your help. This was kinda important to me, even tho it's just a silly little thing.


one last question though.
i would like to scale this up a bit, and maybe make an 8 by 8 matrix or larger.
i got a couple HC4051 multiplexers, but looking at the datasheet for those i noticed that i can sink a maximum of 50mA through it. which is obviously not enough for a row of 8 leds.
how do i get around this? do i still use transistors between row and ground, and just let the multiplexer switch those on and off?


Grumpy_Mike

Using an analogue multiplexer like this for driving digital outputs is pure folly. It is simply not the way to do things.

Use a shift register with a built in FET drive or add FETs to the output of a normal shift register.

Amn3sia

i was looking around at digikey and the max7219 seems a bit expensive for my little project, but i found this: TLC5916.
It's is a fair bit cheaper and seems to do what i want. am i missing something though?

Paul__B

i was looking around at digikey and the max7219 seems a bit expensive for my little project, but i found this: TLC5916.
It's is a fair bit cheaper and seems to do what i want. am i missing something though?
Yes, you sure are!

eBay.

The illustration in reply #4 is a link!

The TLC5916 does only half of the job.  The MAX7219 does it all.  :smiley-lol:

(No, actually the TLC5916 does only one quarter of the job.  :smiley-eek: )

manveen_singh

I saw this when you first posted it and I have been waiting for someone more knowledgeable than me to answer, they haven't so here is my answer....

do not do this next time. if you know the answer tell them asap .if you are wrong you will be corrected. do not wait for others to answer.

PerryBebbington


Quote
Do not do this next time. if you know the answer tell them asap .if you are wrong you will be corrected. do not wait for others to answer.
It's always a difficult call when I'm not sure. In this particular case my answer prompted GM to answer and he told me something I should have already known but had forgotten. If I reply straight away with information I'm not sure about I risk confusing the OP with nonsense. If I don't reply then they don't get an answer at all.

Go Up