With 16 I/O lines the direct method would only provide 16 outputs for 16 LEDs·using·a current limiting resistor for each LED.
I haven't seen any examples for the SX for using a 64 LED driver like the MAX7219 but I'm sure it can be done. There are many examples for the Basic Stamp 2 (BS2). I even worked on a multi-IC (MAX7219) version (128 or more·LEDs with 2 or more MAX7219) for the BS2.
The easiest approach is to use (8) 74HC595 IC's which allow you to control 8 LEDs at a time for each IC using a simple SHIFTOUT command for each 74HC595.
The downside to using the 74HC595's is that there are 8 of them compared to only 1 MAX7219.
Many other possibilities are possible but those are the ones I see used most often here.
The MAX7219 and MAX7221 are both matrix drivers -- 8 segments (leds) x upTo8 digits (columns). It offers some advantages to programming your own SX matrix driver in that current to each led on the matrix is controlled with one single resistor tied to a chip pin (you don't need 8 or 64 resistors for each col or led). It also offers 16 levels of brightness.
That said, a roll-your-own matrix driver in an SX would let you do full 8bit PWM (on each column, at least), and you'd be able to match led resistance to your banks of leds.
If you want full discrete control, you could cascade your own SXs -- 16 leds per SX and roll-your-own code to do full PWM on each led. Use RA.0...RA.3 for /CE, Din, Dout, /OE (or serial). Basically your SX would behave like a cascaded shift register(s) but with PWM on the pins... you could pass 16 bytes for each driver -- each byte being PWM value 0..255 for each LED. 0 would be off, 255 on. And you could certainly do that at 4MHZ w/o an external resonator (save more parts per chip).
8 SX chips x 2.79 = around $23
Maxim also makes some discrete LED drivers, in the 8-20 led per chip range, but I think they around $8, so using 4-8 of those could get a bit pricier (but there would not be the programming chores nor the need for all the external resistors). Some of those drivers are also available as I2C slaves, which is really nice.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
With the ubiquitous 74HC595 (eight of them in series), you could drive all 64 LEDs (at low current) with three I/O lines. By using eight parallel data lines, plus the clock line and transfer line, you'd be able to get data into the 74HC595s' output registers a lot more quickly. Depending on the current draw from your LEDs, you may also need some transistor buffering. If that proves cumbersome, TI makes a high-current, open-drain version of the 74HC595: the TPIC6595.
And of course, if you used "charlie-plexing", you could drive two banks of 42 LEDs each·straight out of one SX directly, using no external logic or drivers, and only 14 pins and 14 resistors. Naturally, a bit of multiplexing software is required, but then that's the fun part isn't it?
Peter -- I had forgotten about Charlie-plexing....thanks for the reminder.
If you haven't heard of Charlie-plexing, it takes advantage of the tri-state properties of micro pins -- it's actually a really good candidate for the SX...
Comments
Joe
I haven't seen any examples for the SX for using a 64 LED driver like the MAX7219 but I'm sure it can be done. There are many examples for the Basic Stamp 2 (BS2). I even worked on a multi-IC (MAX7219) version (128 or more·LEDs with 2 or more MAX7219) for the BS2.
The easiest approach is to use (8) 74HC595 IC's which allow you to control 8 LEDs at a time for each IC using a simple SHIFTOUT command for each 74HC595.
The downside to using the 74HC595's is that there are 8 of them compared to only 1 MAX7219.
Many other possibilities are possible but those are the ones I see used most often here.
The MAX7219 and MAX7221 are both matrix drivers -- 8 segments (leds) x upTo8 digits (columns). It offers some advantages to programming your own SX matrix driver in that current to each led on the matrix is controlled with one single resistor tied to a chip pin (you don't need 8 or 64 resistors for each col or led). It also offers 16 levels of brightness.
That said, a roll-your-own matrix driver in an SX would let you do full 8bit PWM (on each column, at least), and you'd be able to match led resistance to your banks of leds.
If you want full discrete control, you could cascade your own SXs -- 16 leds per SX and roll-your-own code to do full PWM on each led. Use RA.0...RA.3 for /CE, Din, Dout, /OE (or serial). Basically your SX would behave like a cascaded shift register(s) but with PWM on the pins... you could pass 16 bytes for each driver -- each byte being PWM value 0..255 for each LED. 0 would be off, 255 on. And you could certainly do that at 4MHZ w/o an external resonator (save more parts per chip).
8 SX chips x 2.79 = around $23
Maxim also makes some discrete LED drivers, in the 8-20 led per chip range, but I think they around $8, so using 4-8 of those could get a bit pricier (but there would not be the programming chores nor the need for all the external resistors). Some of those drivers are also available as I2C slaves, which is really nice.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Post Edited (Zoot) : 11/24/2007 8:59:44 PM GMT
-Phil
And of course, if you used "charlie-plexing", you could drive two banks of 42 LEDs each·straight out of one SX directly, using no external logic or drivers, and only 14 pins and 14 resistors. Naturally, a bit of multiplexing software is required, but then that's the fun part isn't it?
Cheers,
Peter (pjv)
If you haven't heard of Charlie-plexing, it takes advantage of the tri-state properties of micro pins -- it's actually a really good candidate for the SX...
www.maxim-ic.com/appnotes.cfm/appnote_number/1880
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST