Dimmers for Fun and Profit

Here is the schematic for the Blinky 1200 adjustable light cross-fader. More coming soon.

PDF ps.gz gschem

[top] Why?

I built two blinky boxes, the Blinky 1000 and Blinky 2000, for the 2005 Drop Day party at Dabney House. The Blinky 1200 was built later for Michael McMillen, then the Caltech Artist-In-Residence. The Blinky 2000 had many knobs and controlled four lights to music. I will sometime (Real Soon Now) get around to drawing/publishing the schematic for it. The Blinky 1000 was just a Blinky 1200 with the following changes:

Of course, these changes just remove some of the functionality of the Blinky 1200.

[top] What?

The Blinky 1200 controls two standard incandescent or halogen lamps. One light fades slowly on and off; meanwhile, the other light is doing the opposite of whatever the first light is doing. There is a knob to control how long a cycle takes and a knob to control how long the bulbs stay at maximum/minimum brightness. The Blinky 1000 is the same except without the second knob. The Blinky 2000, as previously noted, had a lot of knobs (seventeen in fact) and controlled up to four lights to music.

There is in fact a picture of the Blinky 2000 here, taken during Drop Day construction by somebody who is perhaps Erin Hartman.

[top] How do I build one?

I'm not going to give detailed step-by-step instructions. That's because this circuit uses high voltages and can be dangerous. If you don't know how to read a schematic, you probably shouldn't try to build such a complex and possibly dangerous circuit. If you want to learn such things, you should read The Art of Electronics by Horowitz and Hill. Pick up an old copy for $30-40 on half.com or some such place, or check it out from your university library if you have access to one of those.

I assembled this circuit on perfboard, mostly using wire-wrap. A few components, such as the triacs and the high-voltage side of the triac drivers, are obviously not good to wire-wrap. I used 12 AWG wire for all the high power stuff, although this is almost certainly overkill, and 24 AWG hookup wire for the low-current, high-voltage components like the triac drivers and triac gates.

I then mounted the circuit in a metal box, taking care to ground the case. It's important to use standard plugs and receptacles for maximum safety; I used a standard duplex electrical outlet (less than 50 cents at Home Depot or the like) for the outputs and an IEC 320 C14 connector (the kind on computer power supplies) for the power inlet. That way, I could use a standard computer power cable. I also added a 10 amp fuse, although a smaller value might be more appropriate. (I was using 12-amp triacs.)

You should also be sure to keep the high-voltage components on a separate part of the board, away from the low-voltage stuff.

[top] How it Works

I will attempt to explain here how this thing works. Images may be helpful, and perhaps I will insert images at some point. Meanwhile, look at the schematic.

If you just want to understand how dimmers work in general, see this page, which has a pretty detailed if poorly proofread explanation.

I will summarize the basic idea of that here, however.

The voltage coming out of the wall is a sine wave. To dim a bulb, we need to reduce the average power transmitted from the wall to the bulb during a cycle. There are two ways to do this: we can change the amplitude of the sine wave, or we can "chop up" the waveform so it isn't a sine wave anymore.

The first way is hard. It's what a variable transformer (i.e. a variac) does, but a variac is big and mechanical.

So we chop up the waveform. We do this with a triac, which is a device that has magical powers. It has two main terminals and a gate. Initially, the main terminals don't conduct at all. When a current greater than the triac's trigger current flows into (or out of) the gate, the triac turns on and conducts. It keeps conducting until both of the following are true:

Basically, this means that the triac can be turned on sometime during the AC cycle by a pulse to the gate and will stay on until the next zero-crossing point of the waveform. By controlling the point at which we turn on the triac, we can control the average power delivered to the light bulb. This happens fast enough that the bulb doesn't appear to flicker.

"Variac" is apparently a trademark of Instrument Service & Equipment, Inc. However, the name is in common generic use, probably because nobody wants to say "variable autotransformer". It is possible that "triac" was once a product name or trademark, although my research indicates otherwise. The term "triac" is sometimes written TRIAC, ostensibly a quasi-acronym for "TRIode AC"; however, application notes from Microchip and Fairchild do not capitalize it in this way.

[top] How the Blinky 1000/1200/2000 Works

This will describe the Blinky 1200. The Blinky 1000 is different in the ways described above. The Blinky 2000 is different in that I don't actually really understand it, and it has a lot more knobs. All three share what I call the David L. Stafford/Pope John Paul II Memorial Voltage-Controlled Dimmer Circuit.

The Blinky 1200 has several blocks; thus, a block diagram is warranted:


+------------+    +-----------+    +------------+    +--------+
|            |    |           |    |            |    |        |
| Zero-Cross |----| Ramp      |----| Comparator |----| Switch |
| Detector   |    | Generator |    |            |    |        |
|            |    |           |    |            |    |        |
+------------+    +-----------+    +------------+    +--------+
                                         |
                                   +----------------+
                                   |                |
                                   | Triangle-      |
                                   | wave generator |
                                   |                |
                                   +----------------+

Plus, of course, there's a power supply.

[top] Power Supply

Just about every part of the Blinky 1200 requires a low-voltage DC power supply. This is provided by the T1, D1, C1, and U1. This is a pretty standard way to make a power supply. The transformer reduces the voltage from 120V rms to around 12.6V rms. RMS is the root-mean-square voltage; that is, the square root of the average value of the square of the input voltage over the course of a cycle. It is a standard way to represent AC voltages. Others include peak (Vpeak = sqrt(2) * Vrms) and peak-to-peak, which is just twice the peak voltage.

The bridge rectifier D1 is a fiendishly clever device which basically takes the absolute value of the input. The capacitor C1 then smoothes out the rectified sine wave to a nearly constant value. (This would be the peak voltage, which for 12.6Vrms is 17.8 volts.) The regulator U1 then ensures that its output is almost exactly 12V.

[top] Zero-crossing detector

But what's the diode D2 for? Well, to find the zero crossings of the AC input, we need to be able to look at it after the transformer and before it gets smoothed out by the capacitor. To do that, we use a diode. At every part of the cycle except the peak, the voltage at the capacitor side of D2 is higher than that on the rectifier side. The diode ensures that this stays that way, because no current can flow backwards through it.

The base of Q1 is connected to the rectifier side of D2 through a resistor to limit the current. This turns Q1 on whenever the input voltage is high enough to make enough current flow. This means that Q1 is on everywhere except for a tiny bit before and after the minimum point of its base voltage, which is the zero-crossing point of the input.

When Q1 is on, the voltage at the collector is approximately ground. (It's really around 1 volt because of the transistor voltage drops.) When Q1 is off, the collector voltage is 12 V because of the pull-up resistor R2, which turns on Q2. This brings us to the next block: the ramp generator.

[top] Ramp Generator

The point of the ramp generator is to generate a linear ramp that starts out at 0 volts and increases (linearly, of course) until the zero-crossing of the input, when it gets reset and starts over again. This results in a sawtooth wave synchronized with the zero-crossings.

D3, D4, R3, R4, and Q3 form a constant current source. (The diodes establish a relatively fixed base voltage of Vcc - 1.2V. You could use a resistive voltage divider here too, but it's not as "stiff".) This current source charges the capacitor C2 to generate the linear ramp. When Q2 turns on (which is at the zero crossings, remember?) it shorts out C2, which resets the ramp.

R3 is variable. Adjusting R3 adjusts the charging current, which adjusts the slope of the ramp. This also adjusts the maximum value, since the period is fixed at 120 hertz. This has the effect of setting the control voltage corresponding to minimum brightness. (See the end of the next section for why.) This is rather sensitive and not something you want to adjust during normal use, so I made it a trimmer mounted on the board rather than a knob on the front panel.

[top] Comparator

The comparator is an LM339, a chip made by National Semiconductor, which takes two voltages and compares them. The LM339 is an open-collector device, which means that its output is (equivalent to) the open collector of a bipolar transistor. The chip pulls the output to ground if the voltage on the "+" input is smaller than the "-" input and leaves it "floating" (i.e. not connected to anything) if the opposite is true.

The LM339 contains four comparators. The Blinky 1000/1200 uses two of them; the Blinky 2000 uses all four. I used LM339s since I had (and still have) an lot of them. For the Blinky 1000/1200, an LM393, which has only two comparators, would suffice.

The ramp voltage is connected to the "-" pin of the comparator and the control voltage is connected to the "+" pin. This arrangement pulls the output pin to ground when the ramp voltage is higher than the control voltage.

Note that this arrangement means that the light is at full brightness when the control voltage is 0V, because the ramp is always higher than the control. This might be the opposite of what you'd expect or want. If you want the light to be fully off at zero volts, you'd have to design the ramp generator to make ramp with negative slope that starts at the maximum and goes to zero. This is also possible and not too hard--you need to flip a few things around so that the capacitor gets charged at the zero crossing and then discharges at constant current. But I didn't do it that way.

[top] Switch

The switching part of the dimmer is composed of a K3012P (equivalent to a MOC3012) optoisolated triac driver and a 12-amp triac. The triac driver contains an LED and an optodiac, which is basically a triac with the gate replaced with a light sensor. The triac driver triggers the triac when the current through the LED is enough to make it light up, which for the K3012P only requires 5 mA. (This is good because the LM339 claims to be able to sink a maximum of 6 mA.)

Warning: when I was testing/wiring the triacs and triac drivers, I'd heard lots of bad things about triacs and I just wanted to get stuff working. I ended up wiring the triacs and drivers differently than I've seen in application notes and stuff. This may be bad and/or dangerous, although I can't see why.

[top] Triangle-Wave Oscillator

For the Blinky 1000/1200, the control voltage is provided by a low-frequency triangle-wave oscillator. This is what R8-13, C3, and U3A-B are for. I did not understand this when I built the circuit (which means that I probably could have done a somewhat better job had I taken some time to analyze the circuit properly rather than just copy something off the Internet), so let's look at it in some detail. U3 is an operational amplifier. If you want to learn about operational amplifiers, you should use Google or, even better, read the op amp chapter of The Art of Electronics by Horowitz and Hill. The important things to remember are, more or less:

Horowitz and Hill, as well as just about everybody else, call these the Golden Rules.

U3A is configured as a form of Schmitt trigger, which is a comparator with hysteresis. That is, the threshhold voltage changes depending on the output voltage. Let's see how this works.

There is no negative feedback, only positive feedback, so the first Golden Rule doesn't hold. Basically, since the gain is so high, the output is at ground if the - voltage is greater than the + voltage and a little below Vcc if the opposite is true. (Most op amps like to be run off a split power supply and go between a little above -Vcc and a little below +Vcc. The LM324 is a "single-supply" op amp, which just means that it can go all the way to ground, although it still can't go all the way to Vcc.

R8 and R9 form a voltage divider, so the voltage at pin 2 of U3 is Vcc / 2.

R10 and R13 form another voltage divider. We'll call the voltage at pin 7 (the "other" side of R13) Vin, the voltage at pin 1 Vout, and the voltage at pin 3 V+. It's easy to see that V+ = Vin + (10/32) * (Vout - Vin); if you don't see this, work it out assuming Vout = Vcc and then assuming Vout = 0.

We can rewrite this (approximating 10/32 with 1/3) as V+ = (1/3) * (2 * Vin + Vout)

If Vout = Vcc, then V+ > Vcc / 2 when Vin > (1/4) * Vcc. When this condition no longer holds, the output changes to ground potential.

When Vout = 0, then the condition V+ < Vcc holds whenever Vin < (3/4) * Vcc. When this is no longer true, the output transitions back to Vcc.

This is very nice, but where do we get the input voltage Vin? The answer is that we integrate the output voltage Vout using U3B configured as an (inverting) integrator. (There is negative feedback, so you can use the Golden Rules to analyze this circuit.) When Vout = Vcc, the integrator generates a negative linear ramp until its output is greater than (3/4) * Vcc; then the output of the Schmitt trigger transitions to 0 V and the integrator generates a positive linear ramp until its output is less than (1/4) * Vcc. This produces a triangle wave. The slope of the triangle wave is determined by the RC time constant of the integrator, which can be changed by adjusting R12.

The output of the triangle-wave oscillator is amplified by U3C configured as an inverting amplifier with (in the Blinky 1200) adjustable gain. The point of the adjustable gain in the Blinky 1200 is to saturate the op amp for a while during the middle of the cycle so that we get a clipped triangle wave instead of a triangle wave, which makes it more artistic. The gain, and thus the amount of time that the lights in the Blinky 1200 stay at maximum/minimum brighness, is controlled by R16. In the Blinky 1000 and Blinky 1200, the period of the oscillations is controlled by R12. R11 sets the minimum period. C3 can also be replaced with a different value to adjust the period as well.

The Blinky 1000 and 1200 both control two lights. U3D is configured as a unity-gain inverting amplifier to invert the waveform coming out of U3C. The input to U3D goes to one comparator, the output to another. ("Unity-gain" means that the amplitude of the input is the same as that of the output; it just flips the waveform.)

[top] Other Stuff

U4A and U4B, along with R19 and R20, drive LEDs that do a generally pretty bad job of indicating what the light bulbs are doing. Using the Golden Rules, it should be pretty obvious that U4A and U4B are voltage followers, which means that their input voltage is the same as their output voltage. They do a bad job because LEDs are even more nonlinear than light bulbs.

[top] Eep!

Note that the triac is triggered by current. For it to work as expected, the current needs to be in phase with the voltage, which means you can only use it to control resistive loads. Resistive loads are things like light bulbs and heating elements. Reactive loads are things that look like inductors, which usually means things with coils, such as motors and transformers. That means you probably can't dim low-voltage lights that require a transformer. At best it won't work; at worst it'll burn out your triac. Anything with a "wall-wart" (one of those annoying AC adapters that takes up too much space on your power strip) is probably an reactive load.

Actually, I lied. You can dim inductive loads if you use an appropriate "snubber network." For an explanation of snubber networks, see this Fairchild application note.

You also can't dim fluorescent bulbs unless they are specifically designed to work with standard dimmers. If you try, they'll just flicker pathetically and eventually die; you might hurt your dimmer as well. Only a few specialty compact fluorescent bulbs can be used with standard dimmers, and even those generally should only be dimmed over a certain range. Unless the fluorescent lamp says specifically that it can be used with a standard dimmer, it can't. This is something that the Caltech housing department needs to learn as well.

Trying to dim complicated electronic things, like switching power supplies, will probably break them. You really can't regulate your clock speed by plugging your computer into a dimmer :-).

Creative Commons License All content licensed under a Creative Commons Attribution-ShareAlike 3.0 United States License, unless otherwise noted.
Hosted by UGCS