Hardware: Schematics

AC dimming is a bit different than DC dimming; you can't simply use PWM. Alternating current switches polarity many times per second and if a solid state switch were to be quickly opened and closed like with pulse-width-modulation the result could be out of phase (see picture at the end for reference). So instead we must have a way to detect the zero-crossing point, wait a number of milliseconds, then enable the switch. The amount of 'wait time' after the zero-cross will determine the dimming amount.

For this build I used a H11AA1 for the zero-cross detection and a (3 channel) TRIAC optically isolated by a MOC3020. The basic schematic can be seen on the image on the left.

Hardware: Wiring it Together

The next step was building the circuit. The top board has 3 header pins for each of the channels and a ground pin. The LEDs light up and dim as the AC wave would on the TRIACs. The bottom board has the zero-cross detection and is an input into the micro-controller.

The ENC28J60 module comes assembled and is essentially plug and play after the appropriate libraries are downloaded. The controller I used was an Arduino Nano. It has a small footprint and all the capabilities of a regular sized Arduino UNO, plus it fit on a breadboard which makes the wiring a lot easier.

Programming: Arduino

The first iteration of this project had a simple HTML page in the controller. This time, I decided to only display a link to the secondary page to save memory on the controller and have it focus on handling the GET request a client. Using the UIPEthernet library I was able to connect the ethernet module and leave most of the previous code the same. The main difference this time is that I added more functions to handle different types of GET request from a client.

To handle the AC dimming I used the TimerOne library to count the number of milliseconds after the zero-cross has been detected and trigger the TRIAC accordingly. This video was a good reference for this project.

Programming: The Server

Similar to the previous iteration of this project, the navigation is a basic navbar slider. This time the ON and OFF buttons are combined into one and there is a slider to control the dimming of each light. Because we don't want to overflow the controller with too many requests I wrote a function that allows a maximum of 1 GET request per 5 seconds while using the slider.

As a work in progress I also have a 'XdimFromToIn' function which specifies the light letter, initial and final light brightness value and the time in which to perform a fade. There is currently no button to perform this, it's manually put onto the URL as a GET request.

Testing the System

To make everything more portable and powered from a single line I took apart a 5V switching power supply from a phone and placed it near the zero cross detector. The system works as expected, dimming the lights as the the slider is dragged, blinking and turning on/off when the buttons are pressed for each channel. The ethernet module operates well and remains connected after many days of being constantly on. The TRIACs do not show any signs of overheating when the lamp is operating.

The video shows a few of the functions the controller can take, including blinking and dim to a particular level. The next step is to put it into a box and experiment with plugging it into other devices.