Matrix problem

Hello everyone, i am new to this forum, but I've been using arduino for a while now, however i have been using it only for small and simple stuff, but recently i found a very simple (or so it seemed) video about an led matrix with shift registers, i don't quite fully understand how they work, tho i watched a few videos. now, i have 2 problems, the project is for 8x24, but i only had leds for a 8x16 matrix, thought that the code would still work an i would be able to use it just like this, the second problem is that in the schematic they don't show the led polarity...so i just put them with anodes on rows, plugged it in, changed my output pins, because it was easier to connect them differently on the pcb, and gave it a go...and my matrix is fully on, and only flickers a bit when i turn the speed potentiometer. here is the schematic and the code, any idea is welcome, except the idea of rebuilding the matrix :slight_smile:
If i have to modify the whole code, just help me out with one character and i will do the rest
...the code is too long and i can't post it as a code

matrix_8x24.ino (21.5 KB)

Do you know what to do to change the polarity of the multiplexing? Have a read of this:-Arduino Workshop

Most mobile devices will not cope with .ino files. Post it as a .txt file instead and then we can all read it.

ok, i will give it a read, meanwhile here is the code in .txt

8x24.txt (22 KB)

Please post your code with code tags as per the instructions in 'how to use this forum - please read' item #7.

That 74hc595 driving the rows is going to fry. The ones driving the columns are somewhat overloaded also. The current limit for any pin on a '595 is 35mA and 70mA for all 8 pins combined.

With your red LEDs and 100R series resistors, each led will draw around 30mA. That's probably over their maximum, but as you are multiplexing, you will probably get away with it.

Each '595 sinking current from the columns will need to sink 30x8=240mA, more than three times their limit, if LEDs in all 8 columns are lit.

Each pin of the '595 driving the rows will need to source 30x16=480mA for a 16x8 matrix or 30x24=720mA for a 24x8 matrix. That's 20 times over the limit for the pin and 10 times over the limit for the chip. And 3 times what the Arduino can provide. I'm not surprised it is flickering. Can you smell burning yet?

If you care, ask for advice how to fix these things.

i cannot post the code because it is too long, i have stated this in my first post
the leds in my matrix are under driven, just enough to light up, my main problem is that the code is not working.

bogdan666:
the leds in my matrix are under driven, just enough to light up, my main problem is that the code is not working.

"Under driven"??? Then the schematic you posted must be wrong. You may think the code is your problem, but...

i used 1k resistors

Thorough and absolute waste of time. Use the MAX7219 modules, do it properly. :roll_eyes:

bogdan666:
i used 1k resistors

For 24 lines, you need to use 4k7 resistors.

i cannot post the code because it is too long,

You can if you post it as an attachment.

bogdan666:
i used 1k resistors

Please carefully review the schematic you posted. Are there any other differences to your own circuit? No-one likes to have their time wasted.

In that case, only the pins of the 74hc595 driving the rows are overloaded. 16x3=48mA compared to their limit of 35mA. So there is still a possibility that this could cause flickering, as the chip begins to fail. And 3mA per led with 1-in-8 multiplex explains she l why your display is dim.

i reviewed the schematic a few times, the only diference betwen that and mine are the resistors and the fact that i have only 8x16 not 8x24, wich i said this in my first post, the code i use i posted in .ino as well as .txt
I don't mind the leds being dim, when i power up my circuit the whole matrix lights up and the whole circuit, includind the atmega 328p and the 595 draws 25mA.

bogdan666:
I cannot post the code because it is too long, I have stated this in my first post

So you did! Sorry!

I've been reviewing the code....

I think the multiplexing is done by column-by-column. That means the multiplex ratio is 1-in16 or 1-in-24 rather than 1-in-8 which I assumed. My assumptions were based on the circuit designer understanding, well, how to design circuits, such as whether to place the series resistors on the columns or rows for example.

On top of the high multiplex ratio, the code appears very inefficient, using shiftOut() rather than SPI.transfer() and implementing a "walking one" by shifting 24 bits each time rather than simply toggling the clock line.

The code is an absolutely superb example. It demonstrates so many bad practices, over-complications, uneccessary repititions, obfuscations... I don't know where to start in terms of correcting it. My gut tells me to delete it and start over.

I'm really sorry if this all sounds so negative. I now have a deeper insight into why the matrix is so dim and flickers so badly. I take my hat off to the coder. Knowing so little, to have battled doggedly on to get anything working at all shows impressive determination. Bravo!

PaulRB:
I've been reviewing the code....

Now that in itself shows great enthusiasm! :grinning:

PaulRB:
I think the multiplexing is done by column-by-column.

In which case, no risk of damage. :roll_eyes:

PaulRB:
I take my hat off to the coder. Knowing so little, to have battled doggedly on to get anything working at all shows impressive determination. Bravo!

Have to agree.

Now if the rows were the cathodes, then substituting the right-hand 74HC595 with a TPIC6A595 and multiplexing by row using the 1k resistors could produce a workable display.

But only as an exercise. For any serious purpose, I have advised in #9.

so i have to start from scratch... great, can you help me make at least one character so at least i have a foundation ?

You do not want to alter your matrix. I guess a lot of time went into building it. Would you consider cutting your matrix in half, so 2 x 8x8? Then you could use max7219 chips and one of the popular Arduino libraries for use with the max chip such as LEDControl or Parola.

If you truly want to continue with your current design, you could remove the series resistors on the columns and instead have 8 x 750R series resistors on the rows. But this would always be dim, as only 4mA will flow through each led with a duty cycle of 1/16, or 1/24 if you extend your matrix.

A better solution would be to scan the matrix row-by-row instead of the column-by-column used now. This would be brighter because the duty cycle would be only 1/8. Also, you could use a UDN2980 chip to boost the current available from the '595 driving the rows. You would keep the series resistors on the columns but you could reduce them to 750R.

Well, the easiest solution for me is to put resistors on the rows, and we can modify the code for row scanning, i will not extend the matrix, besides i have some red leds, even at 4mA they are bright enough for the experiment, i will keep the 1k for now and do some measurements after this is working properly.

No. For row scanning, the resistors should be on the columns. For column scanning, the resistors should be on the rows. This is one of the problems with your current circuit: you are column scanning but the resistors are on the columns.

Whenever LEDs are connected in parallel, each led should have it's own series resistor. When scanning the matrix column-by-column, you are lighting a column of up to 8 LEDs at a time, so for each led to have its own series resistor, those resistors must be on the rows. When scanning the matrix by row-by-row, a row of up to 16 LEDs could be lit in parallel, so the resistors must be on the columns.

In terms of brightness, it will make no difference whether you scan by row or by column. You hit the same limitation either way: the 35mA limit of a '595 pin. If scanning by column, that 35mA can be shared between 8 LEDs, so around 4mA each. But the duty cycle is 1/16, so the average led current is 0.25mA. if scanning by row, the 35mA is shared by up to 16 LEDs, so only around 2mA per led. But the duty cycle is 1/8, so the average current is also 0.25mA.