Yes, this is a big problem, especially for editing code. I don't see the harm in allowing people to edit their posts, regardless of how old they are. At worst you can make a mandatory "last edited at XXXX" message appear.
Edit - I found a way to modify older posts even if there is no button. Simply submit this URL:
But like I said there are many suitable ICs for the task that are not that expensive. Linear drivers are less efficient but reduce the board space and necessary components. You just have to pay more attention to heat and voltage requirements. Switching drivers have a larger BOM but are much more efficient and flexible.
The STP04CM05 is a linear regulator and you actually don't need one per LED. You need 3 per 4 LEDs. Since they have 4 channels a piece. The only hardware I've had to use in addition was a simple PI (L/C) filter and a heavy-duty 25A protection diode which also lowers my 5V supply down to 3.55V. That has a large heatsink.
Also try Mouser for the driver ICs like STP04CM05, I've found they are significantly cheaper there.
Tomppu, the thread you linked to actually contains the explanation and the solution to the flickering problem you encountered. Start at this post to see what I mean. The solution is to output the BAM waveform followed by a mirror image of it.
I don't have time to modify the code right now, but I might later this week. If you can get a working version using MIBAM (mirror image bit-angle modulation) I would be glad to test it!
Edit: There is a dedicated MIBAM thread here. After reading through, on the Atmega328 at 16MHz, I think it is possible to drive 64 channels at 120Hz with 11-bit resolution (2048 levels). At 10-bits you could drive 128 channels, etc. Then again that is based on assembly performance so I'm not sure what the difference would be using the Arduino IDE. But it's encouraging!
Honestly, I think it's easier and nearly as cheap to drive power LEDs with dedicated ICs. There are many out there on the market, like the STP04CM05 I mentioned earlier. I got those for $2.20 a pop from Mouser. There are also single-channel drivers with PWM input that you can run from the TI PWM chips like the TLC5940, which you can combine for hardware PWM control (3000+ levels). I like the STP04CM05 with software PWM because it minimizes the PCB size and BOM.
If you are using the TLC5940, you don't want to drive LEDs directly with it, but instead control a constant-current IC or a transistor (you may find a hex inverter IC useful in that case since 'on' is LOW on the TLC).
I'm actually using the DealExtreme LEDs in our projects. They have good consistency and you can't beat the price. The are very sensitive to overcurrent situations though.
As far as beam concentration, I recommend a reflector over a lens for most uses. As you have found, the collimating lenses essentially project a huge image of the LED pads onto your target surface. Personally, I like the SO27XA reflector but I'm not sure about it's availability outside of the States. A diffusing material can help as well; frosted window film is cheap and works quite nicely.
Tomppu, this is great. The speed limitations were the biggest difficulty with the previous version of the code.
I was controlling 30 channels, with their values being updated over serial at about 50hz. So I would still be calling precalcBamBytes() around 1500 times per second. Is it possible to only call precalcBamBytes() once after updating all 30 channels with setChannel()? That would reduce it to about 50 calls per second.
Also, what is the difference between the iUpdateBam 1, 2, and 3 functions? It seems that version 3 is the superior version. Is there any reason to leave the other two in the code, possibly just to provide an example?
Finally, is it possible to increase the PWM resolution above 256 levels? Possibly 1024 levels, or higher? This would make something like brightness calibration with a logarithmic curve (gamma correction) possible.
I will give your code a try, if I don't see any bugs then it will go into production. If you know of or notice any bugs please let us know in this thread, I would also be willing to help finalize the code and make this into a library like ShiftOut so that more people can take advantage of it. That is, after I wrap my head around bit angle manipulation...
So we completed our project in time for its debut at Hopscotch Music Festival, which was Raleigh's first major music festival. We provided the stage lighting for Motor Skills, whose performance was well-received.
I don't have any HD video yet, but here's some taken from an iPhone: Edit - better video in HD:
The system is as described above; a Processing sketch handles MIDI input and generates the pattern data, which is communicated over serial to the Arduino. Using the SoftPWM code we control a custom PCB with 12 of the STP04CM05 ICs and all the other requisite circuit components. These are connected to the light bars via CAT5 cables through a 12-port patch panel. Finally the light bars consist of a high-power 3W RGB LED, some optics, and other various parts for optimum beam spreading and heat management.
This software PWM implementation worked excellently for the job, so thanks again. I probably wouldn't have attempted soft PWM if you hadn't posted this. Using your code on an Arduino with an Atmega328, we were able to get 128 brightness levels per channel before seeing noticeable flicker, which works well except for the lowest brightness levels. I think a resolution of at least 8x higher is necessary for better dimming, logarithmic brightness, and good color mixing at low brightness. I doubt that could ever be squeezed out of the Atmega328, however.
Perhaps you could formalize your code into a library for better accessibility to people getting started? It seems fairly optimized already what with all the bitwise operations.
Definitely, a partner and I are working on using an Arduino to control a series of these ICs which are driving 12 high power 3W RGB LEDs mounted in polycarbonate tubes, and a series of RGB strobes in addition. We should have MIDI sync with Ableton Live and full manual control as well. We're trying to get it finished for a music festival in Raleigh next month, I'll be sure to post some videos when it's completed.
Excellent, thanks for sharing this. I'm going to be getting some STP04CM05 4-bit shift-register/high current LED drivers in the mail soon, and will try to adapt this code for that application. They also feature cascading so I'm guessing the only trick will be changing any 8-bit references in the code to 4-bits instead.
If this works I will be saving a lot of $ on hardware and a lot of head-banging on circuit design! Before I found the STP04CM05 the only cost-effective solution was a slew of TI PWM multiplexers, hex converters, transistors, and current regulators.
I will definitely buy you a beer in that case. 8-)
Thanks to all the contributors in this thread for helping me get a quick prototype RGB control circuit up and running. When it's late at night and you're working on hardware the last thing you want to do is reinvent the wheel in code!