SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By Bergamot
Actually, I think that you could view multiplexing as a good thing. If you slow it down enough, it'd look like marquee lights :)
User avatar
By bigglez
Philba wrote:I think this was said but I will put it in my own words.
Greetings Philba,

Nicely done, sir!

Comments Welcome!
By Tomasu
bigglez wrote:Nicely done, sir!
I heartily agree :)
By Philba
Tomasu wrote:... I had assumed I'd need some "fancy" math which I'm not all that great at (and neither is a PIC for that matter).
Look up strange attractors. The math isn't all that bad but when you are doing for a large number of LEDs, the cost can become burdensome.
By Tomasu
Philba wrote:Look up strange attractors.
Yup, that there is some of the "fancy" math I was talking about.

I'll have to look at it more when I'm not so tired, but I don't expect to actually understand all of whats on the wikipedia page even when I am rested.

Which is why I was happy to see those rather simple methods you posted earlier with the tables of precalculated values and whatnot. I was also planning on doing some simple animations like you see with commercial light displays, but not as annoying. Probably still will try it out.
By Morrog
I was able to get 16 individually controlled, with greyscale brightness, LEDs working on two shift registers in a day or two. I spent more time trying to get my clock crystal to work properly :P

I've since dropped the greyscale feature of my project for now. It's nice, but there's two problems:
1) It takes more memory and more processing power. A lot more.
2) Cutting the voltage in half doesn't cut the brightness in half. To get a good gradient you'd have to come up with a brightness/voltage graph for your LEDs, and then probably use a very accurate PWM (more memory, more processing power) to get all the voltages you need.

I'm not trying to deter you, just some heads up. I dropped support for greyscale mainly because of the processing issue. My PIC has other things it needs to do.

About the wire resistance, for hooking up LEDs the wire length isn't going to matter. The resistance probably won't even reach an Ohm. If you want, you can use your multimeter (you've got one, right? :) ) to measure the resistance and subtract that from the resistance value you normally need (remember, LEDs need to be hooked up in series with resistors to limit the current going into them. If you didn't know this, read up on how to hook up LEDs).
By Tomasu
My PIC has other things it needs to do.
Mine won't :) This project is all about the leds. I'm hoping a 18F4550 can handle it at full blast. (48mhz, 12mips or so)
By Morrog
Oh for sure. If you want a refresh rate of 60Hz, and you have 64 LEDs to update, that's 3,840Hz. Now, for a greyscale with 256 different levels, that'd be 983,040Hz. The update routine is pretty slim, so you should have enough room to do 983,040 updates per second with 12mips. RAM usage would be 8-bits * 64 = 64bytes.

I think you may also be able to use the PIC's built-in SPI feature to handle the updates, though I haven't tried that myself.
By Tomasu
I think you may also be able to use the PIC's built-in SPI feature to handle the updates, though I haven't tried that myself.
SPI is just another form of a serial port. The MAX chip itself does SPI, though the shift registers will probably work fine off a normal port.

I was thinking though, since I wanted different colour LEDs as well, I'm probably going to have to separate them off into separate "trunks", so I can handle the different voltage levels separately. Otherwise some will either get over driven, or under driven.
By Morrog
SPI is an interface, not a port. Shift registers can be driven by SPI, as far as I know, by hooking the clock of SPI into the shift clock of the registers, and the data-out (out from master) to the input for the register. Data-in can be ignored.
The point of using the PIC's onboard SPI is that it can update the registers while you do something else, like update your pattern. I don't think it'll be necessary in your case anyway.

About the multi-colored LEDs, you don't need to separate them into trunks. You just need to put the correct resistor on each LED. Example:
A 1.5V@20mA LED driven at 5V will need a 175Ohm resistor. A 1.7V@20mA LED will need a 165Ohm resistor.

That's all you need to do. Though a word of warning, different LEDs will likely have different brightness levels at different PWM voltages. So when you use PWM to cut the voltage in half the different colored LEDs might have slightly different brightness levels. I don't think it will be noticeable though.
By Tomasu
SPI is an interface, not a port.
Right. I was just over simplifying. Its more of a protocol. And to me, really, a port is a protocol is an interface ;) its all a way to communicate with another device.
That's all you need to do. Though a word of warning, different LEDs will likely have different brightness levels at different PWM voltages.
Thats what I was talking about. I thought itd be better to have the different voltages on different SRs, one setup for each voltage level.
By Morrog
You aren't passing different voltages. Let's say you use 5V, you're going to pass that to the PIC, the SRs, and the LEDs. The resistors limit the current going through the LEDs. It doesn't make a difference to the SR what LEDs you attach to it.
By Tomasu
I was thinking of doing the limiting through the SRs, so the resistors weren't necessary. if that's even possible.
By Morrog
As far as I know, no. Someone will correct me if I'm wrong, but I see no way of doing it. You'll need a resistor hooked up in series with each LED. It's not that bad, except construction wise. Resistors are dirt cheap.
By Tomasu
Resistors are dirt cheap.
Yup. and I have a boat load. Though after hooking up that many resistors I might want to go smt ;D just to save space... 60 resistors. hmmm.