../media/archive/JDIY20/Media/ JD Presents | JDIY20 : A/C Controller Board

JDIY20 : A/C Controller Board

Over a decade ago I saw a project that captured me. It’s not new by any stretch, but I find it fascinating. Controlling high voltage (120VAC) with a low voltage (3.3VDC) signal. Some of you may remember the X10 devices that you could get from Radio Shack that was an easy way to create home automation. X10 is a communication protocol enabling communication between smart home devices. At the time a revolutionary leap, forty years after being brought to market, X10 is still going strong today. X10 carries a signal over the mains power wiring in your home so you can control light switches, lamp holders or mains outlets.

The device I saw used a simple Triac and opto-isolator to turn off and on 120VAC signals, which is basically how all these devices work. If you add a way to see when the AC signal is at 0V, you can then determine when to pulse the line of the Triac creating dimming. That is where the H11AA1 comes into play. The H11AA1 is a bi-directional input optically coupled isolator that makes it easy for a microcontroller to see when the A/C signal is close to the 0V threshold.

Pink: Controller IO | Blue: Zero-Cross | Yellow: AC Main | Green: Triac
The image above is a screenshot from the scope that shows how the zero-cross works. The blue signal is the zero-cross detection, anytime the AC main crosses zero, there is pulse created by a transistor inside the H11AA1. At which time there is a specific time (~8.3 milliseconds) between the next pulse. The reason why this is needed, is if you just pulse the AC line randomly, you may or may not catch the signal correctly, making dimming a light very sporadic.

I had tried to program without viewing the signals on a scope (because my scope could only handle 20Vpp), but I wasn’t able to nail it down perfectly. I got close, but the AC sync kept floating making my dimming unpredictable. Once I got my new scope, it was infinitely easier to nail down the exact timing. Now I can dim each channel without any issues. It was a very happy evening for me, I even did a happy dance once I figured it out.

Once I had the signals and program working correctly, I wanted to make my own board. I had taken an electronics and PCB design class that taught me how to use Circuit Maker by Altium. I have had good luck with it so far. There are many PCB layout and design programs out there, and each one has pluses and minuses. I also tried Dip Trace for a rocket board years back, but I like Circuit Maker better. There is a bigger community with it and a cloud service that lets people share projects. It requires you to login to use it, which I’m not a fan of but a small price to pay for a free development application.

My first board much like many first runs, I made a mistake. I swapped the 1st and 2nd pins on the TRIAC, so I had to make another run. I made the second board with optional room for a heat sink on each TRIAC so someone could run a higher current draw and remain safe. I also added a connection for the ground wire from the main to provide additional protection. I also update the silk screen to include resistor values. I had both boards made by PCBWay out of Shenzhen, China. I priced around 7 companies, US and over-seas, and I found them to be a solid option. I might use someone local if I need it sooner, but all my builds so far, time hasn’t been a critical aspect.
Version 1.0 & Version 1.1 Boards
While working with high voltage there are new procedures to put in place. For those that say 120VAC isn’t high voltage, I’ve been used to working with 3.3-12VDC. The jump to 120VAC has had some very exciting times during prototyping and testing. First and foremost is when I crossed, only for a fraction of a second, a 120V live wire with an IO pin by accident. It was loud, threw me back in my seat because is scared the bejesus out of me, and blew apart my microcontroller. Here is a look at what was left.

Crossed 120VAC with 3.3V Controller
I have been shocked by a main line before and it gives quiet the zing. I was moving someone and reached back behind their TV to disconnect it only to find bare wires where an outlet used to be. I learned a new procedure there too. Do not assume someone has proper outlets when moving their stuff.

All in all, for my first project that I had a PCB manufacturing run for, I am very happy with the results. I can see why once someone does it, they stick to this option. I enjoy soldering as much as the next maker and building a thing from scratch is great, but to have the board working like it’s supposed to and no extra wires anywhere, gives me great satisfaction. PCB manufacturing seems the next logically step after someone has built a lot of projects. If you are interested in building a A/C controller for simple on/off operation, it is very easy; use a Opto-isolator and TRAIC, and BOOM, done. If you want to add dimming control, you will need a zero-cross detector, there is no other way. There are plenty of forums out there with ½ bits of how to do this, and it took some reading to get all the actual details on the timing, at least the concepts of it. AC loosing sync is a common problem for dimming applications from all the threads I read. If you build one, and are having a sync issue, using an oscilloscope is my suggestion. Getting a visual really helped me understand how all the signals played with each other.

I have shared the code for this project below. The board I made gives the option for users to use whatever controller (3.3V-5V) you want. I have the examples in Propeller Spin and an Arduino sketch.

Propeller Code Download
Arduino Sketch

Observer Effect: The observer effect is the theory that the mere observation of a phenomenon inevitably changes that phenomenon. This is often the result of instruments that, by necessity, alter the state of what they measure in some manner. I have read about the observer effect plenty of time, but have rarely did I see it so obvious as I did during this project. The images below are a before and after a probe was added. As you can see, there is a visual change that is easy to spot on the scope. Slide the blue circle left for signal with a probe on the line, and right to see without the probe.

Difficulty: !!!!
There was a lot of learning curve with this project. Learning Circuit Maker and getting the timing of the A/C signal made for some challenges, and I had to get specific tools to solve. I am thrilled I completed this and now have a PCB manufacturing process.