From: seeker@indirect.com (Stan Eker) Subject: Re: Light dimmer using triac? Date: Fri, 2 Jun 1995 07:45:07 GMT : David Honeywell (drh@netcom.com) wondered: : : I am working on a project where I am controlling 2 110V household lights : : via a computer. I need to be able to dim them, and somehow accomplich : : that using the parallel port. I can get on/off using relays, but I need : : to find a good way to dim these lights in several rough steps. Someone : : mentioned using a triac and using the computer to send pulses to make the : : light brighter or dimmer. It would be ideal to use 1 bit per light : : (pulses, but not serial--doesn't have to be exact), however, I could also : : convert my system to allow a byte of data. Does anyone have any : : schematics or ideas on how to do this? I can also use a pre-built module : : if one exists. Any help would be appreciated, especially if anyone has a : : schematic. I would GREATLY appreciate it. Thanks in advance. Here's an expanded version of my other post, including some example SSRs. I figure I'll have to upload it every few weeks as someone NEW finds a need. AC ZERO-CROSSING DETECTOR This will output a brief high pulse at each zero-crossing, going high roughly 100uS before the crossing, and going low again about 250uS after the zero crossing, total 350uS. The bridge rectifier can be one of the potted variety or just built out of 1N4148s. You don't need power diodes. One of the little 4-pin mini-DIPs that Digi-Key sells will work OK. bridge rect. R1 --------- 1 --------- 5 R2 AC ---/\/\/\----|~ +|-------|a c|------+---/\/\/\--- +5V 22K 1W | | | | | 10K 1/8W (120V AC) | | 2 | | 4 |_______________ output AC -------------|~ -|-------|k e|---. --------- --------- | for 220AC, use 4N25 gnd 39K 2W for R1 or equiv. If you need to shift the pulse slightly earlier, just hang a 200WV cap across R1 to shift the current into the 4N25 LED. A .01uF cap across R1 and a 10K for R2 makes the falling edge of the pulse roughly coincident with the actual zero crossing. Reducing R2 to around 5K will widen the the pulse to 250uS before and 250uS after the crossing, but going HIGHER in resistance won't do much other than to reduce the peak pulse level. This circuit maintains 1500V+ isolation from the AC line, dependant on the V(iso) of the optocoupler used. For any digital or microprocessor designs, I'd strongly recommend the isolation unless you like smoke. -------------------------------- In all of the circuits below, the Triacs and SCRs will dissipate roughly 1W of heat for each amp of load current, so figure your heat sinking accordingly. It's *not* a good idea to run them with no sink unless you are pulling less than 100mA of load current, about a 12W light bulb load. ASYNCHRONOUS TRIAC SOLID-STATE RELAY (SSR) This uses one of the many Triac-output optocouplers to greatly reduce the component count. If you have a PURELY resistive load, you can do away with R3 and C1, but it's a good idea to leave them in because of unwanted inductance from wiring and whatnot. Using a Motorola MOC3012 makes it asynchronous with the AC zero-crossing, meaning you can use it for dimmer circuits. If you just want ON/OFF control, the synchronous variation next is a better choice because it'll reduce switching noise. Dropping the CTL line low turns it on, and if you use it in conjunction with the circuit above, can make a computer-controlled light dimmer. All Triacs (and SCRs) need gate current to turn on, but once turned on they stay on until the AC voltage goes back to zero (a half cycle later). If you turn it on *just* after the AC crossing, the load will get maximum power. As you delay the turn-on time closer to the NEXT zero-crossing, you get less and less power to the load. LOAD MOC3012 .-------------/\/\/\- AC R1 1 --------- 6 R2 R3 | MT2 MT1 120V +5V ---/\/\/\----|a mt|----/\/\/\-+-/\/\/\-+---|<|----+--------- AC 390 1/8W | | 180 | 2.4K |>|\ G | 2 | | 4 | Q1 | | CTL -------------|k mt|----------------------------' | (TTL/CMOS) --------- `-----||------------' 10mA sink C1 0.1uF The values for R3 and C1 are for sensitive-gate Triacs requiring less than 15mA gate current. For normal Triacs with gate current less than 50mA, use 1.2K for R3 and 0.2uF for C1. If you choose to forego the snubber circuit, remove C1 and SHORT the R3 connection (so R2 goes ONLY between the opto and the load/Q1(mt2) point. One good Triac for normal home use is the 2N6071, a sensitive-gate type rated for 4A, 200V. For heavier loads, the 2N6342 is good for 12A, but needs the alternate R3/C1 values in the paragraph above. Above 12A I'd recommend going to (2) inverse back-to-back power SCRs, as they're not prone to latchup like the Triacs are. They're also HIGHLY recommended if you're switching a heavy inductive load like a motor. SYNCHRONOUS TRIAC SOLID-STATE RELAY (SSR) For ON/OFF type SSRs with zero-voltage switching, use the circuit below. The advantage: it will reduce the switching transients that the above SSR has when it turns on, as it'll ONLY switch when the AC line is near zero. It makes a lousy dimmer, but will help to keep your AM radio from popping and will increase the lifespan of both the light bulb(s) and the Triac. LOAD MOC3032 .--------------/\/\/\- AC R1 1 --------- 6 R2 | MT2 MT1 120V +5V ---/\/\/\----|a mt|----/\/\/\-+----|<|----------+--- AC 330 1/8W | | 51 | |>|\ G | 2 | | 4 | Q1 | R4 1K | CTL -------------|k mt|--------------------+-/\/\/\-+ (TTL/CMOS) --------- | | 10mA sink `--/\/\/\-----||--' R3 39 C1 0.1uF Using 220V AC, replace the MOC3032 with MOC3041 and change R4 to 330 ohms. Again, if you have a mostly resistive circuit, you can delete the R3/C1 snubber circuit, but it's never a bad idea to leave it in. INVERSE-PARALLEL SCR SOLID-STATE RELAY (SSR) For situations where you'll have a heavy inductive load (like a big motor), Triacs don't do well. The phase-shifted current keeps them in conduction and they blow out pretty quickly. The circuit below solves that by using 2 SCRs for the switching elements, since SCRs aren't prone to Triac latchup. For *minor* inductive loads, the snubber resistor+cap in the circuits above are usually sufficient, but fractional-horsepower motors need a change. D1, D2 are 1N4001 --------\ G Q1 MOC3032 | .--|<|--. R1 1 --------- 6 R2 | D1 | K A | LOAD +5V ---/\/\/\----|a mt|----/\/\/\----+--|<|-+---------+---/\/\/\--- AC 330 1/8W | | 51 | | 120 2 | | 4 D2 | | CTL -------------|k mt|--------------+--|<|---+-----+-------------- AC (TTL/CMOS) --------- | | K A | 10mA sink | `--|<|--' Q2 Q1, Q2 are (whatever) `----------/ G Further, there are 2 resistors shown as optional across each of the diodes, presumably in case you use sensitive-gate SCRs. Use 1K resistors for 120V, and 330 ohm resistors for 220V. Also for 220V AC, use MOC3041. If these circuits aren't enough to get you started, you'll need to do more research ON YOUR OWN. I *won't* be doing any more ASCII artwork for stuff like pot-controlled light dimmers and the like, as you can buy them at the store cheaper than you can build them. I only wrote this because of the seriously high cost of commercial SSRs, $50US or more new. Lamp dimmers are usually $12US or so, and aren't worth messing with. These circuits are from the Motorola Optoelectronics Device Data book. Additional applications are in the Motorola Thyristor Device Data book. Any mistakes are mine. LTBB