Go Down

Topic: Problem with led matrix array (Read 2040 times) previous topic - next topic

Hi all, I am pretty new at this topic and want now to use some arrays for further projects.
But now I have a problem I can't solve since yesterday.

I think there is this problem because the gnd's aren't all LOW. But why are those two led's on?
I have really no idea...

Here is the code:
http://pastebin.com/2PB4bzrW


And here is a pic of the result.
All resistors are the same.



Hope somebody can help me to find the mistake.
Cheers

Grumpy_Mike

Quote
Here is the code:

So where is the schematic?

The schematic of the Matrix is really simple. There are 5 rows with 7 led each. The rows have a common gnd ant the columns have a common anode.
I use 330R resistors. Everything is connectet to the digital pins of my Arduino UNO.

Grumpy_Mike

Sorry that is insufficient.
It might be simple for you but I have no idea how you wired it up, so I can't spot any errors you might have made.

Quote
The rows have a common gnd ant the columns have a common anode.

That makes no sense at all.

Quote
I use 330R resistors

Where?

Maybe some one else with special powers will be able to help you.

Good luck.

Here is the schematic of the : matrix.http://www.reichelt.de/index.html?;ACTION=7;LA=3;OPEN=0;INDEX=0;FILENAME=A500%252FTA20-11_TC20-11%2523KIN.pdf;SID=13Tkv1G38AAAIAAEcVGyYb8c65e914f2b410b7bef9d95184f20c4

What do you mean with special resistors? I can light the whole matrix with those resistors. But if I want to use this array I get this problem.

CrossRoads

The rows have a common gnd ant the columns have a common anode.

So TBA20-12?
The resistors are on the anode pins?
What is frequently done is to drive all the anodes for row1, then take the cathode for row1 low.
turn off cathode1, change the anodes for row 2, turn on cathode2.

The cathodes would have to sink 7 x 20mA each, so a part like ULN2003/ULN2803 would be used to buffer the arduino pins driving those signals.
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
Here is the schematic of the : matrix

No that is the data sheet of the part you are using. This is NOT showing how you wired it up to your arduino..

I am not sure what sort of answer you expect given that you are keeping so much vital information secret.

Oracle


The schematic of the Matrix is really simple. There are 5 rows with 7 led each. The rows have a common gnd ant the columns have a common anode.
I use 330R resistors. Everything is connectet to the digital pins of my Arduino UNO.


If you can't tell us what you're doing, nobody can help you and this thread is an exercise in frustration.  How is the matrix connected to the Arduino?

Everything is connected to the digital pins?  Directly? so rows and columns?  The Arduino outputs can only sink or source 40mA, which is not enough to drive a full row (or column) as you can.

If you have resistors on the rows and columns, you are splitting your current among whatever LEDs are on on that row (or column) so the brightness of each row (or column) will depend on how many LEDs are on and will not be consistant across the matrix.

Okay here is the schematic. Sorry for this but I don't know in which program I could make one.


If I want to turn on the LED's without an array all glow bright like they should do. If I use the script I've uploaded I get this problem.

Grumpy_Mike

Thanks for doing that, I can see now what is happening.
What I can't make sense of is that code with that schematic, I don't think they match. It is not the way to drive a matrix anyway.
This link shows you what you need to do:-
http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html

Thanks for the link. But why is my code not working. Where is the mistake? I looked at your site and the code is doing quite the same. You are just don't using a two dimensional Array. Don't you?

Grumpy_Mike

Quote
Where is the mistake?

It is asking the ground pins to take (sink) the current for a whole row or LEDs. So that while the current is limited through the LED it is not limited through the pin. Thus you are overloading the pins and damaging them. The current is limited to 10mA per LED and the maximum current you can have through a pin is 40mA, so if you have four LEDs on in a row you are fine but that is the maximum.

Quote
I think there is this problem because the gnd's aren't all LOW.

Only one pin must be LOW at a time.

It could be that you have blown one or more of these pins. Check to see they will sill sink current, do a flashing LED sketch, wire the LED's anode to +, cathode to a resistor and resistor to output pin. If the pin is fine it should flash.

CrossRoads

#12
Aug 23, 2012, 01:30 am Last Edit: Aug 23, 2012, 01:32 am by CrossRoads Reason: 1
This is the kind of connections you need to sink the cathode current.
Can be discrete transistors, or can use a transistor array like ULN2003/ULN2803.
Your pins 2-3-4-5-6 would drive the cathode transistors, the rest drive the anode resistors.
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.

tmd3

There are three things wrong with this project that I can see.  First, it's possible for your cathode, or "gnd" - pins to draw too much current.  That's already been described, and I won't belabor it.  You can rectify that by driving the cathodes with transistors, or by increasing the size of the resistors enough to limit the current with all the LEDs on to something less than 40mA.  You can test the circuit in dim light.  You'll be tempted to say, "I can turn on only four LEDs at a time, and that'll keep the current at 40 mA."  Resist that temptation.  Pretty soon, you'll make a coding error that turns them all on, and something will fail.

The first loop in setup() has an omission that could easily damage your Arduino in this circuit.  Here's the code:
Code: [Select]
  for(x=0; x<5;x++){
    pinMode(gnd[x], OUTPUT);
  }
Each of the "gnd" pins is set to OUTPUT, but the output levels aren't established.  At reset, the output levels are set to LOW.  That means that the first time through the output loop in loop(), all five rows of LEDs will be enabled.  With the values you have in the matrix, that would be four LEDs for each ground pin - just barely inside the limit - and 200 mA for the Arduino, again just barely within the limit.  If you coded something incorrectly, you could easily exceeed the pins' limits, or the IC's limit of 200 mA.  To fix this, I'd recommend setting the output level of each pin to HIGH before you set its mode to OUTPUT.  This quirk only affects the first iteration of the loop, because the loop sets the active "gnd" pin to HIGH after each iteration.

The second loop in setup has an error, too, and that error is both your good luck, and the source of your unhappiness.  Here's the code:
Code: [Select]
  for(y=0; y<7;y++){
    pinMode(led[x], OUTPUT);
  }
The loops iterates the variable y, but indexes with the variable xx has the value that it got at the exit of the previous loop, namely, 5.  So, this loop sets pin 12 to OUTPUT, and it does it seven times, while leaving the rest of the "led," or anode, pins as inputs.  Instead of driving the pins HIGH, setting them to 1 will just turn on the internal pullup resistors.  The LEDs will illuminate, but so dimly that you might not be able to see them.  I can't tell from the photograph.  To test whether this is the likely reason for your unexpected results, verify that the two LEDs that are illuminated are connected to pin 12.

This set of circumstances bodes well for your Arduino.  With only one anode pin active, it seems unlikely that there was ever enough current to damage your cathode pins.  I recommend - as does everyone else - that you redesign your circuitry to allow for turning on all the LEDs without damaging your Arduino.  Replacing the 330 ohm resistors with 680 ohm resistors should keep the current in each ground pin below 35 mA; if you want full brightness, you'll need to get some transistors, or some other way of driving the LEDs.


Thanks a lot! Now It works. I have changed the resistors and corrected the code! :)

Thanks for this link too: http://www.thebox.myzen.co.uk/Workshop/LED_Matrix.html
A good way to drive the matrix i haven't thought about.

Go Up