Creating a 8x8 LED matrix with 2 shift registers?

Go To Last Post
66 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Freaks,

I'd like to create a 8x8 LED matrix using the smallest number of pins of my AVR. It'd be great to use two shift registers, one for rows and one for columns but it doesn't seem possible because according to my understanding shift registers can only source current, they cannot sink current.

How is this possible? I'm open to alternative solutions as long as the pin count stays as low as possible.

Thanks in advance.

Laci

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 74HC595 and others can both source and sink 25mA current. Some shift registers can do larger currents.

Use SPI to drive them. Use a separate /CS for each chip.

If you end up with 256 x 8 matrix or bigger, you can use daisy chained shift registers to drive the columns. You will need high current drivers for the rows.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends on your shift registers and what sort of current you need for the LEDs. Vanilla logic shift registers will source or sink a small amount of current, there are also a number of power shift registers with integrated low side drivers, not sure about options for high side power shift registers. At least one of your shift registers must be capable of driving 8 LEDs at once.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot, David!

I'm wondering why couldn't I see any projects featuring such a configuration. I could only see shift registers being used either for rows or for columns but not for both. Nobody wants to save pins?!

By high current drivers you mean a darlington array, for example?

Laci

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For the reason that I gave you. Who wants an 8 x 8 matrix?

For a big array of 7-segments or LED 8x8 matrix displays, you are either going to multiplex or have a large number of shift registers.
You end up with largish currents on the common pins. Hence ULN2803 or similar.

Personally, I would multiplex and put up with the high-current drivers.
A single 8x8 can probably be driven directly by shift registers.

Think about it. Your shift registers involve two 595s and 4 MCU lines to control them. Buying an MCU with more pins could do everything with one chip.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm in a situation where I have 4 MCU lines to drive the shift registers but not much more. Because of this it costs me less to go with my proposed solution rather than upgrading my MCU to have more pins.

Should the scenario below work?

* Using a 74HC595 for the 8 rows.
* Using a 74HC595 and a ULN2803 for the 8 columns.

The two 74HC595 is supposed to be daisy-chained therefore only having to use 4 MCU lines.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes. You can actually daisy-chain both 595s and only use SS, SCK, MOSI. As you are multiplexing, you are presenting each pattern of 16 bits every period. 8 bits hold the rows, 8 bits hold the single column you are lighting.

If you were doing a 256x8 display, you probably use two chip-selects. For 8x8 there is little point.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What I still don't understand is how can I make either of the 595s *source* current and the other *sink* current. I thought that 595s can only source current.

Laci

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read your data sheet. All chips can sink current. If they have totem-pole outputs they can source current too.

If you have sink-only devices like an 8051, you connect the row cathodes to the 8051. The common-anodes are connected to PNP column drivers.

AVRs or 595s can sink and source.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use a pair of cascaded shift registers to drive everything off one set of pins. Shift out the column data, then the row data, and finally send the latch pulse. Total, three pins. ( data, clock, and latch)

You could use a pair of 74HC595 shift registers, and connect the outputs of the shift registers to driver ICs to power the display. I'd suggest ULN2803 for the column drivers, and TD62783A for the row drivers. Both are available from DigiKey.
If you want to reduce the number of chips a bit, replace the ULN2803 and one of the 74HC595 ICs with one TPIC6B595 IC, also available from DigiKey

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,

Thanks a lot for your explanation! Being a newbie to electronics I have to look up some of the concepts that you mentioned but I'm starting to see the light at the end of the tunnel.

Chris,

I've been browsing on Digi-Key and these are the actual component prices for 100 PCS:

74HC595 - $0.3
ULN2803 - $0.3
TPIC6B595 - $1.056
TD62783A - $1.53

Looks like the TPIC6B595 doesn't provide a good value in this scenario. (I know that pick and placing extra components cost money too but not that much.)

Is the TD62783A necessary for this circuit to work? If so, does it have a cheaper alternative by any chance?

Thanks a lot!

Laci

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The TPIC6B595 would only be useful if you needed to reduce the size of the board, other than that, it is more expensive than separate chips.
I don't know of any other source driver than the TD62783A, but then I haven't looked all that hard either. If your LED supply voltage is 5v, you might be able to make a cheaper system using the 74HC595 to drive eight P type mosfets for the row driver. If you're using more than 5V for the LED voltage, then you'd have to use something as a high voltage buffer between the mosfets and the 74HC595.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

or use ONE MAX7219 chip to do a 3 wire interface or a MAX7221 for the 4 wire SPI thing including the led display update
MAX7219
http://www.maxim-ic.com/datasheet/index.mvp/id/1339

The MAX7219/MAX7221 are compact, serial input/output common-cathode display drivers that interface microprocessors (µPs) to 7-segment numeric LED displays of up to 8 digits, bar-graph displays, or 64 individual LEDs. Included on-chip are a BCD code-B decoder, multiplex scan circuitry, segment and digit drivers, and an 8x8 static RAM that stores each digit. Only one external resistor is required to set the segment current for all LEDs. The MAX7221 is compatible with SPI™, QSPI™, and MICROWIRE™, and has slew-rate-limited segment drivers to reduce EMI.

MAX7219 <$1 on Ebay from lots of vendors

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

My LED supply voltage is 5V because my device is a USB peripheral and I use USB voltage. It also means that 100mA is the maximum current that I can surely source from the host. That makes me think about whether I really need any drivers.

100mA / 8 LEDs = 12.5mA per LED maximum. I've been browsing the data sheet of the 74HC595 and the maximum current rating is 20mA which is surely more than 12mA. I don't know whether this 20mA pertains to the device or per pin but in the former case would it even be necessary to use any drivers?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bluegoo,

I'm in love with the idea of being able to use a single cheap IC to get the job done, but after taking a look at the product page of the MAX7221 on Digi-Key I'm wondering if you saw some Chinese knock off on eBay.

http://search.digikey.com/us/en/...

This baby costs more than 6 bucks per device for 100 PCS. Maybe it's created from pure gold, although its color suggests otherwise. :)

(Only SPI can play in my situation.)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use SPI to control a MAX7219. It behaves similarly to a 595 interface.

You won't go too far wrong with this SOIC-24 or DIP-24 from Ebay. Buy them with PayPal. I see no great problem with buying 'cheap' offers from China. I would not give them a credit card number though!

Note that a MAX7219 can drive some pretty high currents. Start it up with a low brightness.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,

There's no way I'll buy any parts from China ever again if not necessary because I don't like being spammed on a regular basis.

Octopart suggests that this IC is fairly expensive from more legit sources:

http://octopart.com/partsearch#s...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Having an 8x8 matrix with led's I would use NPN and PNP transistors as a (power) switch for the matrix. That way you don't need to worry about sink and source current of your shift registers.

An alternative might be using PNP transistors to source current to a line of LED's and use TPIC6C595 as drain. The TPIC6C595 can also drive the PNP transistors via a resistor.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jan,

Thank you very much for the schematic, I owe you one!

I have some questions:

1) Are there any NPN / PNP SMD tansistor arrays available for this purpose?

2) Is it necessary to use one resistor per LED? I'd like to minimize the number of components.

3) Isn't it feasible to only use resistors to rows or columns but not for both?

4) I'm assuming that the 74LS595N part is functionally equivalent to the 74HC595. Correct?

5) Shouldn't the 75HC595 be able to drive 12.5mA loads per pin without any drivers / transistors?

Thank you!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci wrote:
David,

There's no way I'll buy any parts from China ever again if not necessary because I don't like being spammed on a regular basis.

Perhaps you have had a bad experience.

I can see little harm in trying 10 chips first. I would not place an order for 1000!

Cheap offers can occur quite legitimately. e.g. bankrupt stock, over order etc.

I agree that the price is very 'attractive'. I presume that Maxim-Dallas would not let a sub-standard batch onto the market.

So you either get full-spec or complete fake.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci wrote:
Jan,

Thank you very much for the schematic, I owe you one!

I have some questions:

1) Are there any NPN / PNP SMD tansistor arrays available for this purpose?

2) Is it necessary to use one resistor per LED? I'd like to minimize the number of components.

3) Isn't it feasible to only use resistors to rows or columns but not for both?

4) I'm assuming that the 74LS595N part is functionally equivalent to the 74HC595. Correct?

5) Shouldn't the 75HC595 be able to drive 12.5mA loads per pin without any drivers / transistors?

Thank you!

1) I think it exists in arrays but it's not smaller than having separate transistors. Those transistors can be put anywhere.

2) yes, because the total current per line will change when you switch on/off LED's.

3) The leds will be dimmer or brighter if you use 1 resistor per line.

4) yes

5) you have to look at the specs for that :D. there is a max current per pin AND a max current per chip. for the HC version I see that absolute max current per pin is 20mA (source and sink) and 70mA for the total chip. This means that for the 8 lines you can have 8.75mA maximum per line. And it's wise to stay well beyond that value so I would suggest 5mA max per line...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

David,

Being spammed is only one of my concerns.

The other is being dependent on Chinese companies long-term. Of course everyone is dependent on China directly or indirectly but being dependent through a trustable third party (an international distributor) is much more appealing for me, especially considering that we're about mass produce our products eventually.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I fully understand. I would not want to rely on some cheap offer for any long term design. Fine if you just want a one-off batch.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looking at the HC595 data sheet, you could use one to drive either the rows or the collumns directly, but not both, so you will need at least one driver.
If you drive the LEDs by row, each column driver would have to handle only the current of that one LED, but the row driver might have to handle the current for up to eight LEDs at a time if all the LEDs in that row happen to be on. Similarly, if you drive the LEDs by column, each row would only handle one LED at a time, but the column driver might have to handle eight LEDs.

One other thing to watch out for. Since the display is multiplexed, each LED will be on for no more than 1/8 of the time. This means that it will appear 1/8th as bright as it would if it were not multiplexed. Check to see if that 20mA current results in LEDs that are bright enough for your use.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With a TPIC6C595 you can drive the PNP's and use one to sink current so it could be used instead of NPN transistors but also limited to 250mA per chip and 100mA per channel. To sink the full led array you'll have a absolute maximum of 31.25mA per line or 25mA to be more or less safe. This is a max of 3mA per LED.

There is no need for blinking LED's in my schematic.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jan,

First of all, now that (I think) I understand the essence of your design and I really appreciate it not only because I can see how it works but because it seems to be pretty much the most cost-efficient solution.

I've been searching for LED matrix schematics and none of them used one LED per resistor which made me thing that either the other designs are sloppy or your schematic has redundant resistors. I believe it's the latter one. :)

I think it'd be completely feasible to remove R1-R64 and rather place resistors directly below T6, T7, T8, T9, T1, T3, T4, T5. That's 8 resistors, 1 resistor per column instead of 64 resistors, 1 resistor per LED.

Given that at any moment only one row is active those 8 resistors would be used for the actual row.

A) Can my alternative design work?

B) I've made some research and according to my understanding one resistor per transistor is needed because otherwise the transistor would be killed due to the high current. That being said, I'm still not sure how much current should the transistors get. What's the rule here? I'm such a n00b... :)

C) Is the reason of using PNP transistors for columns and NPN transistors for rows because the former sources current and the latter sinks current?

D) Why using expensive high-current drivers when this design can be implemented with cheap transistors? What's the catch?

Thanks in advance!

Last Edited: Thu. Mar 22, 2012 - 08:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

I know that multiplexing reduces the potential brightness according to the duty cycle. I cannot foresee whether the resulting brightness will be feasible because the LEDs will be arranged in a complex pattern and covered by a semi-transparent colored film. The best thing that I can do is to start from the cheapest solution first, test it and search alternatives later if needed.

As for the D) question (transistor vs high-current driver) that I asked in my previous post I'm also very interested about your opinion on the subject.

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci wrote:
Jan,

First of all, now that (I think) I understand the essence of your design and I really appreciate it not only because I can see how it works but because it seems to be pretty much the most cost-efficient solution.

I've been searching for LED matrix schematics and none of them used one LED per resistor which made me thing that either the other designs are sloppy or your schematic has redundant resistors. I believe it's the latter one. :)

I think it'd be completely feasible to remove R1-R64 and rather place resistors directly below T6, T7, T8, T9, T1, T3, T4, T5. That's 8 resistors, 1 resistor per column instead of 64 resistors, 1 resistor per LED.

Given that at any moment only one row is active those 8 resistors would be used for the actual row.

A) Can my alternative design work?

B) I've made some research and according to my understanding one resistor per transistor is needed because otherwise the transistor would be killed due to the high current. That being said, I'm still not sure how much current should the transistors get. What's the rule here? I'm such a n00b... :)

C) Is the reason of using PNP transistors for columns and NPN transistors for rows because the former sources current and the latter sinks current?

D) Why using expensive high-current drivers when this design can be implemented with cheap transistors? What's the catch?

Thanks in advance!

A) Yes it will work.

B) The resistors are needed to protect the LED. A transistor can have quite some drive current.

C) yes: NPN can sink current, PNP can source current. Well, both can do both but driving the transistor is just a tad easier when using NPN's for sinking and PNP 's for driving. Alternatively you can use TPIC IC to sink the current.

D) The catch is what LED's are you using? A high current CREE 3W LED is different from an ordinary red sign LED.

The current is driven by the combination of resistor and known voltage drop over LED. It's just on/off so you can calculate the resistor needed for your LED. I would go for a series resistor because it's much easier and cheaper. But the resistor also consumes power. So when using high current LED's a lot of heat is dissipated through the resistors. In that case you need current drivers.

[edited some stuff so you would think I'm less an idiot than I really am]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jan_dc, your circuit can't work with all the LEDs separately controlled. In your circuit, turning on any single LED requires turning on both the row and column transistors for that LED. Now look at what happens if you try to draw a diagonal line on the display. The ROW 1, column 1 LED is on, as is row 2, column 2 and so on. This means that every single row would have to be on, and at the same time every single column would be on. this would result in all the LEDs being on, not just the diagonal line that was intended.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's what I would use as a circuit for the display. It uses 3 ICs and eight resistors. Only three output pins are needed from the CPU. To use it, shift out eight bits with only one bit high to select which column will be on, then shift out eight bits of data for the rows, with a high for each LED you want on. Latch the data with a pulse on the latch pulse, delay, then repeat the whole cycle with the next column.
Assuming you want the total current to stay under 100mA, and a five volt supply, use 330 ohm resistors. This will keep the row current below the limit of the 74HC595.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris-Mouse wrote:
jan_dc, your circuit can't work with all the LEDs separately controlled. In your circuit, turning on any single LED requires turning on both the row and column transistors for that LED. Now look at what happens if you try to draw a diagonal line on the display. The ROW 1, column 1 LED is on, as is row 2, column 2 and so on. This means that every single row would have to be on, and at the same time every single column would be on. this would result in all the LEDs being on, not just the diagonal line that was intended.

Yes... I noticed that too. I was too quick answering and didn't thought of that.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

Thanks a ton for your schematic! It's not only as simple as possible but one can get the parts for the cheap!

I've been thinking but still cannot understand why Jan's circuit can't work. After all, drawing a diagonal line would involve iterating the rows (or the columns) one by one and lighting up the desired LEDs within that row (or column). At least that's the way I see it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I assumed my schematic is static. So all LED's are driven at once. This is not the case. Only 1 line (column or row) is driven and you need to cycle through the whole thing.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jan,

Ah, I see. I assumed from the get go that we're about to use multiplexing for the matrix so this comes naturally for me. Luckily, both of your designs assume multiplexing which is perfect for my needs.

Chris,

Previously you wrote that "I'd suggest ULN2803 for the column drivers, and TD62783A for the row drivers". Your current design doesn't utilize the TD62783A. Is there any reason why?

Last Edited: Mon. Mar 26, 2012 - 10:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends on what led current you want. If you were running more displays, you would want more current to get acceptable brightness therefore you would use the source driver. Using the source driver allows you to run a higher voltage other than 5V to the display, again, allowing more current.

Be sure not to get multiplexing and pwm confused.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman,

Thanks for your clarification regarding the source driver!

I've corrected my above post by referring to multiplexing instead of PWM.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci, the first idea was based on an assumed average current of 20mA per LED. Because of the multiplexing, This means a peak current of 160mA with a 1/8 duty cycle.
Afterwards, you said you wanted the total current to be kept under 100mA. This means a 100mA column current, 12.5mA per LED. 12.5mA is within the drive limitations of the 74HC595, so no drivers needed for the rows. The current for each column would be between 12.5mA for 1 LED in the column, and 100mA if all eight LEDs are on. Thus, a driver is still needed on the columns.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

Thanks a lot for the thorough explanation, makes perfect sense!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris-Mouse wrote:
mondalaci, the first idea was based on an assumed average current of 20mA per LED. Because of the multiplexing, This means a peak current of 160mA with a 1/8 duty cycle.
Afterwards, you said you wanted the total current to be kept under 100mA. This means a 100mA column current, 12.5mA per LED. 12.5mA is within the drive limitations of the 74HC595, so no drivers needed for the rows. The current for each column would be between 12.5mA for 1 LED in the column, and 100mA if all eight LEDs are on. Thus, a driver is still needed on the columns.

No it's not good! The worst case is 8 LED's on meaning a total current of 100mA! The 74HC595 can source (or sink) only 70mA per chip. And this is absolute maximum rating! The 74HC595 will have to drive 8 times 12.5mA...

I would go for 50mA in total maximum to be safe.

On the column side you could use a TPIC6C595 to sink the current.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jan,

Thanks a lot for the clarification!

I'm not sure whether I'll go above 50 mA total but in case I will according to the earlier conversation the TPIC6B595 can be replaced with a 74HC595 and a ULN2803 which should provide a better bang for the bucks.

So the whole circuit would use 2 parts of 74HC595 and 2 parts of ULN2803 in this case regarding the ICs. Correct?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Jan_dc, you're right, I'd missed that little point about the total VCC current.

Mondalaci, you have the IC total right, just don't forget the eight current limit resistors. If you want to keep the total current under 70mA, use at least 400 ohm resistors. 470 ohm resistors would give you a better safety margin.

While I was going over the circuit again, I spotted another potential problem. When power is initially applied, the two 74HC595 shift registers will have random contents. That makes it likely that multiple rows will be on simultaneously, along with multiple columns. Worst case, it's possible to have all the LEDs on at once, which would massively overload the power supply, at least until the CPU comes out of reset and writes correct data to the display.
To fix that, instead of grounding the output enable on the column shift register, I added a pull-up resistor to it, and connected the enable line to another CPU pin. this way, all the columns are guaranteed to be off until after the CPU has had time to fill the shift registers with valid data. As a side bonus, if that enable line is connected to a CPU pin with PWM capability, you can use PWM to control the display brightness without interfering with the display scanning code.

The big question I have now is still brightness. With the peak LED current down to under 8.75mA per LED to meet driver limits, the average current is now down to around 1mA. That's not going to be a very bright display. You could use that TD62783A source driver to drive the row lines, or you could use a bunch of P channel MOSFETs. You can use pretty much any P channel logic level MOSFETS with a drain current equal to or greater than your worst case row current. Here's what the schematic would look like with the MOSFETs, and that change to the enable line on the column shift register.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

Thank you very much for your updated design! Frankly, I'd have never thought about these issues and it'd probably take me a *lot* of time to figure them out.

In my true style I have some further questions. :)

1) Are you really sure that the content of the 74HC595 is random upon initialization? It may easily be the case, it's just weird to me because it's not advantageous usability-wise.

2) Wouldn't using a ULN2803 in the place of the MOSFETs or the TD62783A provide the same current to the LEDs? That'd probably be a better choice purely regarding costs (pick and placing less components and/or not having to use another component).

3) How about using a BJT instead of a pull-up resistor for the Output Enable pin? I guess it'd be just as good for this purpose but probably more expensive and overly complicated. Correct?

Thanks again!

Laci

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci,
Looking through the data sheet for the 74HC595, I can't find any reference to Default values when power is first applied to the chip. Given that lack, and the fact that power-on-reset circuitry is rare in any of the 74XXX integrated circuits, it's safest to assume random until proven otherwise.

The ULN2803 won't work for the row drivers, you need something capable of sourcing current, not sinking it. The TD62783A would work. You'd have to look at parts cost, assembly cost, and board layout issues to decide which method is best.

I'm not sure how you'd go about using a BJT to hold the enable line high until the CPU is ready. It's certainly going to be more expensive than a simple resistor. During the time between power being applied, and the CPU getting around to initializing the display, the I/O pins on the CPU are high impedance inputs. The pull-up resistor is there simply to guarantee that the column drivers are off any time that the CPU input pins are high impedance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
1) Are you really sure that the content of the 74HC595 is random upon initialization? It may easily be the case, it's just weird to me because it's not advantageous usability-wise.

That's why they have a reset input! The suggestion of using a resistor to hold it in reset until the cpu comes alive and drives the port pin would have to be the simplest.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys,

Thanks for elaborating on the 74HC595. Components that are not initialized by default seem weird to me because I came from the software world but your explanation makes perfect sense.

Chris,

At this point everything is pretty clear to me. The last thing that's left is deciding on the TD62783A vs MOSFETs issue.

First of all it's important to take into consideration that I wanna drive 47 LEDs, so a 8x8 (=64) matrix is overkill. A 7x7 (=49) matrix would be enough, but a 6x8 (=48) matrix is even better for this purpose because 6 MOSFETs are enough this way.

As for the component selection of the concrete MOSFET device, under the "Discrete Semiconductor Products" headline of the Digi-Key product index I can choose:

* "FETs - Single" and set the filter "FET Type" to "MOSFET P-Channel, Metal Oxide", or
* "FETs - Arrays" and set the filter "FET Type" to "2 P-Channel (Dual)"

In the former case I'll need 6 parts per device and in the latter case I'll need 3 parts per device.

As for the additional filters to be used I only have to watch for the "Current - Continuous Drain (Id) @ 25° C".

Is the above correct?

Thanks a lot!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci, that looks about right.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

In the meantime I've tried to take another look at your schematics and realized that they disappeared from the external server where you uploaded them.

Could you please upload your schematics as attachments here on AVRFreaks so that those would be accessible in the future?

Thanks in advance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Oops. Looks like we had a server failure that took down the images. Let me see if I can figure out how to upload the most recent one here.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot, Chris!

I happen to have the first version of your schematic which I also upload now.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

1) Could you please confirm that the BSS84,215 and BSS84 MOSFETs are good for this purpose? (I could get the former from a local supplier but ultimately I'd like to choose the latter because that's the cheapest one.

2) On a related note I'm confused about the "Package / Case" vs "Supplier Device Package" fields. It seems to me that the former lists packages that are compatible with each other. Maybe their footprint is the same or they only differ in naming (TO-236-3, SC-59, SOT-23-3 seem to be pretty much the same). Please le me know what's the situation here.

Thanks a lot!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

3) I almost forgot: What should be the value of the pull-up resistor?

Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Those MOSFETs should work just fine, assuming your current stays below 130mA per row.

It appears that the Supplier Device Package is what the manufacturer calls the package the device is in, while package/case are industry equivalents, but I'm not at all sure on that. The best solution would be to ask Digikey exactly what they mean by that.

The value of the pull-up resistor is not at all critical. Pretty much any value between 1K and 100K should work just fine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci wrote:
Freaks,

I'd like to create a 8x8 LED matrix using the smallest number of pins of my AVR. It'd be great to use two shift registers, one for rows and one for columns but it doesn't seem possible because according to my understanding shift registers can only source current they cannot sink current.

How is this possible?
led strip lighting outdoor I'm open to alternative solutions as long as the pin count stays as low as possible.

Thanks in advance.

Laci

$ As this modified post seems spam I have removed the links, I have kept the original text if there is a valid reason to restore it - JS $

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I cannot thank your help enough, Chris. Now it's my turn to build the board. I'll let you know about the final result.

On a related note I've just reported Saxena to a moderator so this spammer is gonna be taken down.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The spam has already been removed.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now I see. I've had this page loaded for a long time in my browser without being updated.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

There's one thing left that I can think of. I'd like to utilize 5 white LEDs and 42 red LEDs in this matrix.

On one hand the value of resistors should be chosen based on the specific LEDs that are being used. In this case one row should be dedicated to the red LEDs with a specific resistance value.

On the other hand the maximum current that I can provide to the LEDs is fixed so maybe I shouldn't worry and use the same resistors for all the LEDs and mix the LEDs within the matrix in any way I want.

What do you think the correct solution is?

Thank you very much in advance!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your circuit may be designed with a maximum current, but it's not really enforced. LEDs with higher forward voltage drops will leave less voltage across the series resistor, and thus lower current in those LEDs.

There's a couple of possible solutions to the problem. One would be to simply ignore the fact that you are mixing different LED types, and accept the fact that this would result in different brightnesses.

If you could arrange for all the LEDs in a given row to be the same colour, then you could simply adjust the resistor value for that row to give the same brightness as all the other rows.

A third solution would be to use a driver IC that has a constant current output. I found this at Digi-Key:

http://www.digikey.ca/product-detail/en/STP08DP05B1/497-6271-5-ND/1641765

It's a shift register/latch combination, with constant current output drivers. It would replace the 74HC595 and the ULN2803 driver for the columns, and have the side effect of eliminating the need for the resistors in the row lines. You'd feed the LED data to the columns, then select one row instead of selecting a column and feeding LED data to the rows, but that's a fairly simple software fix.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Chris,

Let's take your last schematic as the basis and imagine a 8x6 matrix in the place of the 8x8 matrix. In columns 1-7 red LEDs will be used, 6 per column. In the rightmost (8th) column I plan to place the 5 white LEDs and leave a matrix junction empty.

At this point your first solution would involve having 6 resistors of the same resistance for the rows (or 8 resistors of the same resistance for the columns).

Your second solution would involve having 8 resistors for the columns of which 7 would have the same resistance and the 8th (rightmost) would have a different resistance.

As for your third solution I love the idea of being able to use the minimum number of parts possible but nothing seems to be able to beat the 74HC595 + ULN2803 combo price-wise.

Am I correct that brightness inconsistency across the LEDs regarding the first and especially the second solution shouldn't be noticable by the human eye? (Maybe both of these solutions would be equally good considering that the duty cycle can be set by changing the firmware.)

Given that the red and white LEDs are as evenly distributed within the rows as possible do you think that one of these two solutions is better than the other? (If not then I'd go with the first solution because its slightly simpler.)

Thank you very much in advance!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey Freaks,

After all this time I finally managed to breadboard Chris' circuit and test it with an Arduino Mega.

I've created a video and some pictures. (I shot the video and pictures before wiring the MOSFETs correctly but I fixed the wiring and the code since then.)

Here's the Arduino sketch (also attached):

#include 

int enableOutput = true;
int useSPI = true;

int numberOfRows = 3;
int numberOfColumns = 2;

int latchPin = 22;  // ST_CP
int clockPin = 23;  // SH_CP
int dataPin = 24;  // DS
int outputEnablePin = 25;

void setup() {
  Serial.begin(9600);
  pinMode(latchPin, OUTPUT);

  if (useSPI) {
    SPI.setBitOrder(MSBFIRST);
    SPI.setClockDivider(SPI_CLOCK_DIV2);
    SPI.setDataMode(SPI_MODE0);  // Every mode works except mode 1
    SPI.begin();
  } else {
    pinMode(clockPin, OUTPUT);
    pinMode(dataPin, OUTPUT);
  }

  if (enableOutput) {
    sendData(0);
    sendData(0);
    pinMode(outputEnablePin, OUTPUT);
    digitalWrite(outputEnablePin, 0);  // Enabled (active low)
  }
}

void loop() {
  for (int j = 0; j < numberOfRows*numberOfColumns; j++) {
    digitalWrite(latchPin, 0);
    sendData(1 << j / numberOfRows);  // Column data
    sendData(~(1 << j % numberOfRows));  // Row data
    digitalWrite(latchPin, 1);
    Serial.println(j);
    delay(100);
  }
}

void sendData(int data)
{
  if (useSPI) {
    SPI.transfer(data);
  } else {
    shiftOut(dataPin, clockPin, data);
  }
}

void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  digitalWrite(myClockPin, 0);
  for (int i=7; i>=0; i--)  {
    digitalWrite(myClockPin, 0);
    digitalWrite(myDataPin, myDataOut & (1<<i));
    digitalWrite(myClockPin, 1);
  }
}

As you can see according to the value of the useSPI variable the sketch can bitbang or SPI-drive the 74HC595s.

As for now it's only a 2x3 matrix. I have yet to design the PCB featuring the full matrix containing red and white LEDs but currently everything works as expected.

Thanks a lot everybody being involved, especially Chris!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's a small list that I've created featuring various offerings. This list is by no means complete and I didn't take the various characteristics of these components into consideration.

High side (source - PNP or p-channel FET): 74HC595 ($0.21) + ...
* MIC2981 - $1.29
* TD62783A - $0.91
* 6 FETs - 6*$0.04 = $0.24
* 3 dual FETs - 3*$0.8 = $0.24

Low side (sink - NPN or n-channel FET):
* TLC5916ID - $0.87
* HEF4794 - $0.7
* TPIC6B595 - $0.65
* 74HC595+ULN2803 - $0.21+$0.39 = $0.6
* STP08DP05XTTR - 0.58
* TPIC6C595 - $0.57

I plan to go with the bottommost offerings.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

By the way, I've shot some videos of the most recent version of the display:

http://www.youtube.com/watch?v=v...
http://www.youtube.com/watch?v=a...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci wrote:
Thanks a lot, David!

I'm wondering why couldn't I see any projects featuring such a configuration. I could only see shift registers being used either for rows or for columns but not for both. Nobody wants to save pins?!

I use a shift-register for the rows, and a demuxer to select the columns. I suppose you could shave a couple pins from that by using two shift registers, but that means you've got to shift the column mask, rather than simply set the column number on 3 pins.

Shift register + Demuxer = 2 + 3 pins (clk, shift data, 3 pins for column select)
Shift Register + Shift Register = 1 + 1 + 1 (clk, row shift data, column shift data)

I'm not sure I'd go through that much trouble to save 2 pins, especially since the software will be slightly more complex to manage it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

random_hacker wrote:

I use a shift-register for the rows, and a demuxer to select the columns. I suppose you could shave a couple pins from that by using two shift registers, but that means you've got to shift the column mask, rather than simply set the column number on 3 pins. [...]

Actually as it stands today I plan to use the I2C-driven PCA9634 as the source and the SPI-driven TPIC6C595 as the sink for the LED matrix.

The PCA9634 being a very intelligent, programmable device I'll be able to set the brighteness for the individual lines which is a big deal because the different kinds of LEDs used in the matrix.

So after all the number of the available pins is not such a critical issue.

I'm however interested about the demuxer that you're using. Could you please name the exact part?

(Sorry about the delayed response, the notification email made its way into my spam folder.)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mondalaci wrote:
random_hacker wrote:

I use a shift-register for the rows, and a demuxer to select the columns. I suppose you could shave a couple pins from that by using two shift registers, but that means you've got to shift the column mask, rather than simply set the column number on 3 pins. [...]

Actually as it stands today I plan to use the I2C-driven PCA9634 as the source and the SPI-driven TPIC6C595 as the sink for the LED matrix.

The PCA9634 being a very intelligent, programmable device I'll be able to set the brighteness for the individual lines which is a big deal because the different kinds of LEDs used in the matrix.

So after all the number of the available pins is not such a critical issue.

I'm however interested about the demuxer that you're using. Could you please name the exact part?

(Sorry about the delayed response, the notification email made its way into my spam folder.)

I actually used the wrong term. I used a 1-of-8 decoder. the 74238 (specifically 74HC238). I recently found that it really can't handle the amperage that my circuit desired, so I'm considering hooking its outputs (or maybe using a 74HC138) to transistors (mosfets or bjts probably), which can handle the 480mA load my circuit could produce in theory.

I looked at the specs for your two chips you've selected. I'd be concerned combining a PWM chip with a multiplexed display. You might run into some strange aliasing effects which could cause certain rows to be not as bright, or even add a strange "flicker" to the whole of the display. Also, depending on your 8x8 matrix, you may find that the 100ma limit on the tpic6c595 just isn't enough. When I was running my calculations, I needed almost 500mA. And that's if I didn't run the thing as brightly as possible.

My 8x8xRGB matrix, each LED can run at 50mA max, which means each row pin could in theory pass 50ma*8*3 = 1200mA if I ran it at full power. My current plan is to run it at around 10ma for red, and 20ma for green and blue, which brings the total max current to 400mA, though I will need a margin to be certain I don't burn anything out.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

random_hacker wrote:

I looked at the specs for your two chips you've selected. I'd be concerned combining a PWM chip with a multiplexed display. You might run into some strange aliasing effects which could cause certain rows to be not as bright, or even add a strange "flicker" to the whole of the display. Also, depending on your 8x8 matrix, you may find that the 100ma limit on the tpic6c595 just isn't enough. When I was running my calculations, I needed almost 500mA. And that's if I didn't run the thing as brightly as possible.

The 100mA limit won't be an issue. When shooting the video that I included lately the matrix consumed about 30-40mA total so I don't worry about it.

I don't know whether I'll see any aliasing effects. Hopefully not. I'm waiting on the components to test the display.