For syncing the dimmer channels to the AC line, I put together a simple zero crossing detection and triac control in Diptrace. It's based on this design http://playground.arduino.cc/Main/ACPhaseControl but has some additional precautions like logic level MOSFETS, varistors and fuses. Also, I had to change some components for cost and availability reasons, the specs are pretty much the same. We're using high current 16 amps continuous load triacs here, so we won't have to cool them when driving 25 W bulbs.
Disclaimer: This is 230V AC mains circuitry, so if you want to do this, know what you do and don't hold me responsible for the outcome. It's dangerous, I strongly suggest that you don't build this by just copying the circuits if you're not able to figure it out by yourself. Take this content as purely inspirational, if not satirical! THX!
Here's the zero crossing detection circuit, I used a SFH620A AC-optocoulpler, which is pretty similar to the H11A11 from the arduino example:
The triac driving circuit is based on powerful BT139 triacs (instead of the similar Q6015L5). Triacs are best driven by optotriacs, in this case the MOC3052-M. I will have 8 of those triac circuits and one zero crossing detection circuit on a 10x10cm pcb. Because I'm planning to drive many optotriacs, I cannot, or should not, power the optotriacs directly from any µC. The pulse, that drives the optotriacs cannot be neglectable short, so even if we're driving them at 15-25 mA, at some point, the forward current of all the optotriac emitters circuits would just sum up to something the µC cannot provide. Also, if the µC hangs, it might just blow. So I added thes nice little logic level N-MOSFETS, 2N7002, to every emitter cathode of the optotriacs. Almost any logic level N-MOSFET works here, use whatever you have. I've never had trouble driving logic level MOSFETS without gate resistor from any µC, but if you're worried you might as well add some. A pulldown however is necessary of course.
So, I've carefully tested everything on a breadboard, and even if these circuits are pretty basic, they seem to work reliable. However, there's a lot to improve. I.e. we should have some buffer capacitors and at least footprints for snubber circuitry for driving inductive loads, but one step after the other. I routed the boards single sided, so that you can easily fabricate them on a mill, but eventually, they will go to dirtypcbs.com, so the top layer has an optional grounded copper spill for shielding. The first boards will look like this:
So, after some double checking on the gerber files, this went to dirtypcbs.com to get 10 nice boards. My plan is to use two of these boards for the lamp and 8 of them to make a 8x8 light bulb matrix. So, let's hope this works as planned.
In the comments esot.eric mentioned some worries about the earthed and grounded shielding copper spill covering both the logic part on the left and the mains half on the right of the PCB. He also investigated this deeper and posted some good information material that I want to integrate into this project log. He quotes his source like this:
"For each power supply stage, keep power ground and control ground
separately. Tie them together [If they are electrically connected] in
one point near DC output return of the given stage."
So, the mains part of the PCB should be spatially isolated from the logic part, which it is, but there's no good reason to cover the mains part of the PCB with a copper spill. First, this increases the risk of HV making it into the logic and damaging it, and second, this messes with the idea of shielding the logic part against EM irradiations of the high switching current transients. While this is definitely a design flaw that will be removed from the sources, I am not to worried about this causing too many problems in practice. The copper spill is grounded and will be earthed, so its still unlikely that failures in the mains part will damage the logic. Even if, it will defenitely blow the leakage current fuse and turn the lights out.
In further investigation, I also found an example implementation of a electronical controlled dimmer here, and it's clearly visible that the copper spill ends exactly between the HV and the logic side of the optotriacs.