Eric, just a question: Are those leds electrically isolated in a way you can control them in a matrix form? or they have a common polarity pin side? 1) matrix 6 x 5 (11 bits) can be formed to light just one led at time, it needs enough pull up at the leds anodes side (source) and enough sink current at the catodes side. There are chips available to do it easily. 2) common polarity allow you to use a 74HCT45 for example (bcd to decimal decoder - open collector) to select one led from ten, sink the catode, using 4 bits combination 0-9 (ignore A-F), with other 3 bits you can drive FET transistores that will drive which one of the 3 bars of 10 leds will receive power (source at anodes). Again, there are plenty of other chips. The conversion from 16 bits to matrix selection (65536 -> 5x6) or (65536 --> 4x3), it is just a common division or logic selection. As 10 or 30 does not make part of 2^n dimension, it will create gaps and errors to divide it logicaly using some bits from the counter to select rows and collumns. For example, you could use this logical selection, with errors: Using the counter high order first 4 bits (xxxx .... .... ....) to select the bar; 0,1,2,3,4,5 = Green <--- extra position 6,7,8,9,A = Yellow (each x800h selects a LED) B,C,D,E,F = Red (each x800h selects a LED) The Green bar can't share the same idea to use x800h to select a LED, so it doesn't work well. Dividing the value 0-65535 by 2184 you will have a result from 0 to 30 (0-1Eh), convert to decimal, use the high nibble to select the bar (in the common anote or catode posibility), and the low nibble to select the led (via the 74HCT145 for example). Here the error is very small and the most accumulated error will appear at the last led #30 that will lite earlier 0.023% than expected, because (2184x30)/65535 = 0.99977, and will hold 16 counts more than the other LEDS (2184 each one). Considering that each LED will share 3.33__% of the range, the error is not considered. In the matrix style, just use a table of 30 bytes size, each one with the 5x6 bit combination, example, the entry #28 will have contents 54h, the 5.h converted to binary will select the column #5 for the source side, while the .4h converted to binary will select row #4 for the sink (ground), and the LED #28 at the matrix position 5.4 will light. For sure you use several other solutions as 4 x 8 bits parallel registers, or 4 x 8 shift registers when you control to shift up or down, and other crazy ideas. ----------------------- Eric Oliver wrote: > > First of all, I would like to take a moment to thank all of you. Over the > last few weeks I have ask several questions and got excellent replies. It's > been several years since I belonged to a group so active and helpful. > Several years ago, I belonged to the Borland C++ forum on CIS. It was > there that I learned to program. Over time I was able to give back to that > group. I hope that someday, I'll be competent enough to do the same on > this list. > > I would like to pose a question. I'm not really planning to use this > algorithm at this time, but I just bought three LED chips from Radio Shack. > I'm sure most of you know the item. Each chip consists of ten LEDs in a > bar configuration. You can mount any number of them side by side to form a > chain of bars. I used them to test my PIC hooked up to some 595s. > > But I was thinking that they could be used to convey information in the > form of a bar. With values ranging from 0% to 100%. For instance, if you > chained three chips, the first green, the next yellow and the last one was > red. Say you were monitoring spindle load on a machine. As the load > progresses from 0% to ~33% the green LEDs would light in succession, as it > moved past 33% through ~66% the yellow LEDs would begin to light and so on. > > So what I can't figure out is how to translate the load ( in the previous > example ) to the bit representation needed to shift to the 595s. Just as > an example, let's say the spindle load is measured and the result would be > between 0 and 65535. Now, we would need 30 bits to control all 30 LEDs. > How would you go about converting the load to the 30 bit number ? > > Like I said, I really don't have an application for this at this time, but > since I don't have an answer to the question, I thought I'd ask it. > > Eric