Electronic – arduino – multi channel ac dimmer for arduino

acarduinodimmerpwmraspberry pi

I have been looking for a simple ac dimmer circuit to use with my arduino and/or raspberry pi. I have used the TLC 5940 PWM Driver before just to control LEDs and I wanted to adapt this to controlling strings of xmas lights. Since I am just beginning with electronics, I don't wanna blow my face off by doing it wrong. Do you have any suggestions for anything that is not only compact but cost effective???

Best Answer

I've done this before, except I was controlling theater lights at 20A per channel. Here's how I did it:


simulate this circuit – Schematic created using CircuitLab

  • R1 sets the current through the LED side of the isolator, just like you're used to.
  • R2 limits the current to what the isolator is rated for, but it's only needed while the power triac is in the process of turning on. Use something that can handle the full line voltage and a decent amount of power, but it should barely get warm.
  • L1 limits dI/dt through the triac to match its rating. You can go bigger to reduce EMI, but not too big or it becomes difficult to turn the circuit off. More on that later.
  • R4 has a similar function as R1.
  • You can share the same Zero-Crossing detector for all channels. Keep in mind that the pulse width is not zero, so you'll need to find the center and use that.

The theory of operation is:

  1. Wait for zero-crossing
  2. Turn PWM off
  3. Wait for desired off-time
  4. Turn PWM on
  5. Repeat

You can do this in parallel for as many channels as you have hardware and processing time for. I always bit-banged it with interrupts while the main loop handled communications.

The PWM must be synchronized with the AC power line because the triac latches on until the current stops (which it must do every zero crossing, so we're okay there). You technically don't have to hold it on, but it makes the logic easier and removes the requirement for a minimum load.

The latching behavior may also cause a problem for false triggers. If the load is too reactive, including L1, then the triac dropping out may cause enough inductive kick to retrigger it, so it effectively sticks at 100% on.