On Tue, 27 May 1997 19:03:09 +0100 David Dobbs writes: >Hi, > We are working on a lighting controller but we need some info >and / >or code on Zero Crossing, Phase Control and Interfacing Triacs. We >would >prefer code for the 16C84 but that doesnt really matter as we can >convert it. I can give you some comments, but my employer paid for the code! We used a 16c74a in a 4 channel dimmer (the Dove Systems Shoebox... see http://www.dovesystems.com/dove ) . It works like this.. Zero-crossing detection is done by hanging a current limiting resistor between one end of the power supply transformer secondary and the INT pin. The INT pin is set to watch for a negative edge, which generates an interrupt a little before the negative zero-crossing. The positive zero-crossing is determined by timing from the negative one. Phase control is done by using the compare mode of the capture compare register. On zero crossing, we look through a table of how far into the half-cycle we want to turn on the triac, finding the earliest one. We put that in the compare register and return. On getting the compare interrupt, we turn on that triac and look up the next one. Actually, we also turn on any others that have a turn on time within 256 clocks of the current timer value to avoid missing any due to interrupt response time. This results in a VERY minor interaction between channels. I can see it on the scope when running the simulator at 4 MHz, but can't see it in the product running at 16 MHz. Another interrupt is receiving the DMX 250 Kbps signal and stuffing the appropriate bytes into an array where a table lookup then determines timer values for the compare register (above). The main loop polls the A/D and reads in 4 channels of 0 to 10 volts control, if present. The triacs are driven by MOC3010N opto triacs. The optos are driven directly by PIC output pins. Harold