Go Down

Topic: Choosing Duty Cycle For LED Matrix (Read 3215 times) previous topic - next topic

JoeN

Jul 06, 2013, 11:11 pm Last Edit: Jul 06, 2013, 11:14 pm by JoeN Reason: 1
I am going to hand-build a matrix for fun.  In the past I have mostly used 8X8 and 5x7 matrices that are commercially available, whatever is cheap.  Now I want something bigger that is all mine.  So on a larger PCB I am constructing a 32x16 matrix out of 5mm red diodes.  I have to choose duty cycle and I am just not sure about this.  I could go with a duty cycle of 16 and then I would have 32 columns and 16 rows, or with a duty cycle of 8 and have 64 columns and 8 rows.  A duty cycle of 4 is also a possibility, but with 128 columns which sounds less than fun - it also makes for more complex wiring - with 2 banks I can come in at the top and the bottom of the matrix for the column connections, with 4 banks, I have to come in the middle twice and at the top and bottom.  Since 8 has worked for me in the past, I am inclined to do that.  On the other hand, it occurs to me that I really don't know how to intelligently make this choice.  Is there guidance on that?  Is a duty cycle of 16 (or 8 for that matter) known to be too small?  Just looking for general advice.  Thank you.

The LEDs:

http://www.taydaelectronics.com/led-5mm-red-water-clear-ultra-bright.html
Emitting color: Red, Diameter: 5mm, Lens color: Water Clear, Forward voltage(V): 2.0-2.2, Current(mA): 20, View angle: 25, Luminous intensity(MCD): 8,000 - 12,000

The columns are anodes and the rows cathodes, not that it matters for this discussion.
I have only come here seeking knowledge. Things they would not teach me of in college.

CrossRoads

How are you controlling it?
One way would be to use a MAX7219 for each 8x8 piece, so 32x16 = 8 chips.
Easy to connect up, easy to control, each 8x8 is multiplexed at 800 Hz, all your code has to do is write data to registers via SPI commands to update the display.
Can daisy chain them, can control each individually. I chose to select each individually in this example.
Your wiring would be a little more intense, having to duplicate 8 matrices.
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.

JoeN

#2
Jul 06, 2013, 11:56 pm Last Edit: Jul 07, 2013, 12:08 am by JoeN Reason: 1

How are you controlling it?
One way would be to use a MAX7219 for each 8x8 piece, so 32x16 = 8 chips.
Easy to connect up, easy to control, each 8x8 is multiplexed at 800 Hz, all your code has to do is write data to registers via SPI commands to update the display.
Can daisy chain them, can control each individually. I chose to select each individually in this example.
Your wiring would be a little more intense, having to duplicate 8 matrices.



I've done a bunch of projects with MAX7219s so I want to avoid that.   You and I have written together on several threads about this driver chip - yeah it's easy to use for sure.  The fact is, I want to make a matrix.  Controlling it is secondary to me.  I want a matrix and then I can use it for multiple projects.  The duty cycle seems to me to be of primary concern because the quality of the matrix lives or dies on that regardless of how its driven.  Plus, I have to make that choice right now.  But my plan to drive it for the first application actually is going to be to use a EPM1270 CPLD to see if I can get some pseudo-PWM working and verify that the CPLD is big enough to support this many columns - I think each column needs its own circuit and that will eat up the CPLD fast.  If not, I could go to an FPGA but that presents some challenges, Altera CPLDs are very hobbyist friendly compared to the FPGAs.   If I can actually make that work step two would be to get it to display actual useful data from a dual-port RAM and push data to the ram with a 328.  Step 3 would be a USB interface to "program" the matrix from a desktop application.  So I see a way of doing many things here I haven't done before, all in one project.
I have only come here seeking knowledge. Things they would not teach me of in college.

JoeN

#3
Jul 07, 2013, 12:04 am Last Edit: Aug 24, 2014, 10:38 pm by JoeN Reason: 1
Here's a very similar project I did.  I also have another one with 20 8x8 matrices (small ones, 0.8" Adafruit) arranged in a 5x4 mega-matrix, all run by a giant chain of MAX7219s.  Mean to make that into a video-pong game at some point, I just haven't done the software.  The hardware works...



Also pictured is my giant bag of LEDs and the matrix, so far, an hour into it or less.
I have only come here seeking knowledge. Things they would not teach me of in college.

CrossRoads

So you need 48 IO, 16 or 32 of them setup as PWM outputs, the other 32 or 16 set up to sink or source current to the selected column being driven.
Or split it in half two 16x16 sections, with 32 IO needed per section, each with 16 PWMs and 16 sinks/sources.
Brightness will be improved with the 2nd one, and depending on the CPLD, perhaps a x16 dual-port RAM for each half could be used.

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.

JoeN


So you need 48 IO, 16 or 32 of them setup as PWM outputs, the other 32 or 16 set up to sink or source current to the selected column being driven.
Or split it in half two 16x16 sections, with 32 IO needed per section, each with 16 PWMs and 16 sinks/sources.
Brightness will be improved with the 2nd one, and depending on the CPLD, perhaps a x16 dual-port RAM for each half could be used.


My problem with what you propose here, either way, is that we are looking at a duty cycle of 1:16.  Is that going to work well?

The way I see it, it's a 16x32 matrix but it can be organized as 8x64.  So you have 64 PWM outputs on the anodes and 8 switchable drains on the cathodes.  An entire row of cathodes is connected to ground, you do whatever you need to on the 64 columns (anodes) for 1/800th of a second, and move on.  I don't want a CPLD switching all this current so I think I need transistor switching for both the high side and low side.  The low side is going to handle much more current so I was thinking, 8 NPN medium-power transistors.  For the high-side, 64 low-power PNP transistors.  Or would MOSFETs be a good choice here?  I bet the CPLD would love that because it would totally minimize power requirements from the CPLD.  The high side will have the PWM switching on it so those transistors must be faster.

But, what I am getting at is how do you make this choice?  1:16 duty cycle (16+32 pins), 1:8 duty cycle (8+64 pins), 1:4 (4+128 pins), 1:2 (2+256 pins), or 1:1 (512 pins, cathode directly to ground) duty cycle?  There must be some way of knowing in advance.
I have only come here seeking knowledge. Things they would not teach me of in college.

CrossRoads

The other thing you have to consider is how the data is coming from memory.
You'll have bytes in an array representing fonts or a picture or something.
How will you send that out to the shift registers or the CPLD or whatever to be displayed?
And manipulate it to make changes?
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.

JoeN

#7
Jul 07, 2013, 05:37 am Last Edit: Jul 07, 2013, 05:42 am by JoeN Reason: 1

The other thing you have to consider is how the data is coming from memory.
You'll have bytes in an array representing fonts or a picture or something.
How will you send that out to the shift registers or the CPLD or whatever to be displayed?
And manipulate it to make changes?


Already thought about it.  The uC is going to compose frames in that dual-port memory.  Each frame is going to be 512 bytes, in other words 8 bits of grayscale for each pixel.  The CPLD is simply a dumb driver, it's going to display what is in the current frame buffer.  There are two frames - the one being displayed and the one being composed.  After the uC completes composition of a new frame, it raises a line to the CPLD and the CPLD switches to the new (other) frame for display.  So bit 10 on the address bus selects the frame.  That works out rather nicely, good thing I went with an matrix that has an integer log2 of the number of LEDs.  Anyway, that's the only direct line between the CPLD and the uC, other than maybe a blank/reset line.  The total list of features of the uC software, of course, is dependent on how much I wish to invest into it.  Like I said, I'd like to be able to program it over USB with Windows host software to send it text to display/scroll and simple bitmap images, with control codes to allow usage of the gray scaling - pulsing hearts might be nice for example :).   It won't have as many features as commercial displays that I have seen for sure.
I have only come here seeking knowledge. Things they would not teach me of in college.

CrossRoads

I don't know, seems to be a complicated way to replicate the 16 outputs of at TLC5490 for example.
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.

JoeN


I don't know, seems to be a complicated way to replicate the 16 outputs of at TLC5490 for example.


I hate those things.  Never had anything but trouble with them.
I have only come here seeking knowledge. Things they would not teach me of in college.

JoeN

OK, step 1 completed.  LEDs soldered down.  Now for bussing...  ]:D



I have only come here seeking knowledge. Things they would not teach me of in college.

CrossRoads

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.

Runaway Pancake

#12
Jul 07, 2013, 05:23 pm Last Edit: Jul 07, 2013, 05:28 pm by Runaway Pancake Reason: 1
How many pairs of nippy-cutters did you go through for all that?   :)

> > >  Once you get that humming, you're going to see the effect of in/consistency in brightness and in the die and lens alignment (manufacturing).  One by one they all seem about the same, but as a group, differences are more appreciable.
"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

JoeN

#13
Jul 07, 2013, 07:53 pm Last Edit: Jul 07, 2013, 08:53 pm by JoeN Reason: 1

How many pairs of nippy-cutters did you go through for all that?   :)

> > >  Once you get that humming, you're going to see the effect of in/consistency in brightness and in the die and lens alignment (manufacturing).  One by one they all seem about the same, but as a group, differences are more appreciable.


If there are any LEDs that are offensively inconsistent with the others, I will either replace them or fix them in software.

I still have the same Hakko cutters I bought a year ago, they don't seem to be wearing down.

http://www.amazon.com/Hakko-CHP170-Micro-Cutter-16AWG/dp/B0000WT6FI

OTOH I have killed one of these so far, replaced it with the same model.  The main spring broke and I couldn't find a replacement.  Not the best photo on this page, but it's a nice stripper.

http://www.frys.com/product/3256901

http://www.amazon.com/JT-Products-5020F-Heavy-Stripper/dp/B000WGAZB6 (better picture, bad price)

Wow, it really pays to search for best price.  Some of these vendors are crazy.

http://www.rvplus.com/the-best-connection-wire-stripper-crimper-hd-5020f.html  
http://www.wiringproducts.com/contents/en-us/p2208.html
I have only come here seeking knowledge. Things they would not teach me of in college.

CrossRoads

Ok, back to driving this thing:
Quote
The uC is going to compose frames in that dual-port memory.  Each frame is going to be 512 bytes, in other words 8 bits of grayscale for each pixel.  The CPLD is simply a dumb driver, it's going to display what is in the current frame buffer.

Sounds like your CPLD will be pretty busy.
It has to read from SRAM somewhere (internal, or externally shared with uC). Output PWM signal to 32 IO lines (assuming it can drive 20mA or more for that many IO lines) while controlling an external transistor to select 1 of 16 rows to be lit up. To prevent flickering, each row must be lit ~2mS (2mS x 16 = 32mS = 31.25Hz refresh rate).
Am I on the right track here?
I think this would be comparable to incorporating the functionality of 2 WS2803's into one chip.
Maybe you could do initial testing with those and P-channel MOSFETs as current source per row to confirm the matrix while you work out CPLD programming.
32*.02 = 640mA to supply a row, or more if your LEDs can handle high pulse current for a shorter time, often spec'ed as:

Peak Forward Current (1/10th duty cycle, 0.1ms pulse width) IFM 50 mA
http://www.superbrightleds.com/moreinfo/through-hole/5mm-red-led-30-degree-viewing-angle-8000-mcd/281/1208/

I don't see similar data listed for the Tayda part, perhaps they can supply it.
This then drives the refresh rate: 100uS * 16 = 625 Hz.  Definitely flicker free! Probably want a fast PWM rate so there are some on/off cycles occurring during that 100uS.
This also drives the SRAM read & output update rates.
You can then compare the constant current driving of the WS2803 vs your PWM control from the CPLD.
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.

Go Up