This started out as a simple project to control some lights which has descended into programming and power electronics.
Anyway on with the first bit.
It all started with the garden pond, i'll explain later but for now the crux of the matter is i need 3 power channels which can be independently controlled from a smartphone. I decided that 4 channels was probably a better idea so the design was a quad affair. I set the power limit for each channel as 500w which would mean that any device would need to deal with just over 2 amps I decided on BT136 Triacs [as they handle 4 amps no bother] that would be optically isolated and preferably their gates fed from opto triacs with zero voltage crossover detection.
Lets look at the circuit.
Step 1: The Circuit
P1 is a 5v supply fed from external. This powers all opto triacs via 100 ohm resistors and led before entering opto triac and returning to pin in P4 P6. Grounding these pins turns on the respective opto triac via U1/4 cathodes.
Opto Triacs are MOC 3063 zero crossing devices and a sniff of the 220V line in is returned by the neutral return on Pin 1 of P2/3/5/7 and fed to U1 in this case by R3/R2/C1. This T section compensates for the potential lag of the current in any inductive load. Pin 4 of U1 is connected to the gate of Q1 the BT136 power Triac.U1 has a zero crossing detector built in so we sync the switch to the mains incoming or moreover the gate "pulse". R4/C4 is a snubber to limit the DV/DT of the switch off to stop the power triac from false triggering and letting its smoke out. All devices are built with smoke inside them and if you let it out they will fail to function any more.
Line in is fed to 4 separate fuses and fed by inductors to the load terminal "Hot". The return or neutrals return to the MT2 terminal of the power triac. Note the topology of this.The triac is in the cold leg or the neutral side of the load.
Couple of points. Mains voltage is being switched here and if you do not know what you are doing do not touch this stuff. If you do then make sure everything is powered by an RCD, and if you do not know what that is then you definitely dont want to dabble.
I am not responsible for your safety if you fail to heed the above. Death can be fatal.
Step 2: The Board
I designed the board from a single layer pcb with photo resist. Note the mounting of the 6 pin optos and the creepage distance between the pins. You can clearly see the low voltage and the mains sides of the circuit.
The layout is on the file attached which i copied to tracing paper and then exposed using a home brew UV lamp box then developed and etched. Drilling took a while. The Triacs were mounted on an old heatsink from a PC power supply as was all the wire for the internal connections. The insulating strips for the Triacs were also taken from the same power supply.The calculations for the heatsinks I will describe later if anyone is interested but the crux is a large lump of aluminium is called for. Normally the Triacs saturate give or take a few volts so you normally only have to deal with 12W or so.
All the copper tracks have been "tinned" to make up the physical size of the tracks and note the large cables feeding the line in IEC. I also used some old insulating card from the old pc power supply to protect the underside of the board from 220v and also sprayed all the board underside with plastic seal 60 which is a protective insulator.
The snubber resistors need to be rated at 2W and any capacitors in the circuit at mains voltage need to be rated at 400V or more.
I have yet to fit the inductors and only have link wires in so far but they are due to be delivered shortly.
Testing is still ongoing but does what it says on the tin so far. i will post a video of the tests later.
Step 3: Pictures of the Constructed Board.
The board i have mounted in a clear plastic lid box and will add some more pictures of it shortly.
The fuse holders are seen in the side of the box.
What next.... The intermediate channel switching card with timer to control a pulsed pond pump.
The web server and outputs to drive PWM for led pond lights and the software in the tcpip stack.
Features temp controller as well.
Step 4: Closing Stages
Some Notes on the design so far.
4 dual pins have been added for handbag links to force the channels on for testing purposes.Of course you will still need the 5v supply to power the optos but best to feed that from a switch mode or isolating transformer supply.
The PCB tracks for positioning of the triacs need shifting slightly to accommodate the thickness of the heatsink
R7/R8 combination resistors for all need making slightly longer on the pcb....or use smaller resistors wattage wise.
The 5v indicator led resistor is shown as 1k its actually 330 and the caps are 100n and 10u..i will update the schematic later.
Fuses are 3.15A .
The inductors are actually 100uh I have added to slow down the rate of rise of current through anything inductive. More testing follows.
I mentioned previously that this design switches in the neutral side of the circuit as we have access to a neutral. in many dimmer circuits or domestic switch you do not have access to a neutral so the triac switches in the hot side of the circuit with each load.
interesting note on powering leds using this design:
The lamps are 220v 50hz 30mA 5.9W BC Candle design. I found that when inserted they glow despite the triac circuit being off, and when measured across the o/p i had 35v of ac. If you look at the circuit you will notice the snubber across the triac. This is made up of 180 ohm resistor and 100n plus the 680 ohm and another 100n. Where it is in the circuit means its capable of shifting a small current to neutral even if the triac is off. Also does the 680 and 100n because the opto triac needs to sense the mains phase to fix when to fire. With a tungsten lamp the current it dumps when off is the impedance of the lamp which can vary from 121 ohms for 400 watt or 1.6k for 30w. This is in series with the snubber and a small current flows.Too small to even get the tungsten wire to glow hot. Not so with a led design. The very small current is enough to get the leds to glow albeit marginally. I have not removed the snubber to see if it fixes it but i guess it will. I doubt if 680 ohm and 100 n will get it to glow.
It may be that the design has to change to power to switch in the hot side rather than the cold, i might try this later if i have no joy with removing the snubber. Some Triacs are snubberless so might be just the job to use for leds.
Overall this circuit could be reduced down to a much smaller size through careful matching of the components to wattage, and maybe given time i might just do that, particularly if its driving just leds with minimal current, although at 220v you need to keep and eye on the track spacing to avoid any flashovers.
You will note that the tracks feeding the triacs are all 100 mil or 2,.54 mm ish in todays money, this gives you about 3.6A allowing a temp rise of 30 deg C but should be more as I have tinned all the tracks to thicken them up.
Track spacing is in the hands of the gods as far as volts are concerned although the majority of the tracks at the MV level are in excess if 1 mil per 40V as an absolute min.
Step 5: Onwards and Upwards
Ok so we have our 4 channel triac driver which accepts a 5V rail incoming and all you have to do is deck the 4 cathodes from the opto devices and the respective channel turns on.
So as mentioned before I am going to control this board from a web server but not a big boys webserver, in fact a small mcu based webserver with some interesting features. However I need to do some work on the `output of the webserver board as I want to drive one of the channels as an "on" signal but the on needs to control an air pump which I need to adjust the on period and the off period. Now why would you want to do that I hear you say, well I could elect to do it in software and I have on many occasions but this time I want to have some good old analogue tweaks before the pump. The reason is , yes I know get on with it, is that the pump I have sits in the bottom of a pond which is six foot deep and if you turn it on continuously then it obliterates the views of the KOI in the pond. What we need is a good push of the pump to get it up to pressure and then just as it gets there turn it off so we get a pulsed ring of bubbles that slowly migrate up through the pond from the ring in the sump drain. bit like blowing smoke rings you know when we used to puff the woodbines all those years ago.
The pond also has a ring of leds buried into its walls which at night is a feature as the bubbles percolate up through it. The Leds are driven by small driver cards which need a PWM signal in order to dim them which emanates from the web server card[ I have programmed that and will describe later ] Suffice to say that all the signals from the web server card come via a 34 pin onto the intermediate card which I will describe next.
Step 6: Intermediate Board
So here is the intermediate board.
The schematic you can find below and it looks like this.
Incoming from the webserver we have 4 pins on the 34 pin header which arrive on pins:
pin 8 [PWM 1]ch 1
pin 10 [RD1] ch 2
pin 11 [RD?] ch 3 and
pin 28[RG4] ch 4
of the 34 pin header
pin 8 is a PWM signal which is inverted by q1 and fed off by p3 pin 1.
pin 10 is in inverted by q6 and exits on pin 1 of p4
pin 11 is inverted by q8 and exits via pin 2 of p4
Leds D1/4/5/6 are just indicators to show whats being turned on.
So as a recap these three channels are capable of being driven on and therefore pull low the channel opto on the triac driver board. I'll get to the webserver later.
Now here is the fun part. U1 is my adjustable driver chip and is a plain old 555 timer.Pin 28 which is RG4 of the webserver chip is normally high and holds the 555 in reset .with pin 3 low. when told to turn on it goes low turning off q3 and starting the timer sequence. pin 3 goes high decking P3 pin 2 and turning on ch 3 of the triac board.C3 charges via r2 d3 and when it reaches the threshold on pins 2 and 6 it flips on the discharge pin 7, pin 3 goes low and discharges c3 via d2/r4. this then repeats at infinitum until pin 28 of the header goes low again.
Notice that the time constant of all this is independently controlled by the two pots R2 and R4 so the on can be controlled relative to the off.
The power incoming on J1 is nothing special just feed with 9v and has a 5V regulator.
IMPORTANT POINT All the inputs to this board or outputs from the webserver are 3.3v signals, they dont much care for 5V which is why i have chosen to drive everything through the digital switch FETS.
As I write this I have not built and tested it but it should work. If not I might have to tweak it a little but lets see.
Construction is mainly smd so we can keep the size down.
Step 7: Time for a Web Server
Well I thought the best thing to drive the intermediate card was a web server based MCU so thought the best one to use and easiest is the PIC WEB board from OLIMEX.
I took the web page as originally designed and modified it along with the code on board to create a pwm based channel and added some output ports to toggle. I could create a timer based app as well as there is an on board real time clock for this card.
The code for the web page is downloaded to the PIC WEB board independently of the program code and there is a program that you use to compile the html and upload to the board.Again this is free from microchip along with a demo version of MPLAB which i used to program the C Code running on the MCU,
The great thing about using AJAX type programming for the board is that the status information is resident on the MCU and the query just asks for the XML file to update the buttons. What this means is that there is no request to load a complete page which means the traffic is minimal. I'll grab this via wire shark when i get a chance but you can see there is actually no disturbance to the display on any update as AJAX or java effortlessly changes just the icons associated with the HTML in the background I linked the status update to my CSS page which describes the buttons and colours etc.
Note the image of the web page which i have created. Its fairly basic and i might titivate it later if i decide to add any features. As far as the look and feel of the page is concerned you can download a fresh web page without taking the board out of operation for more than a few mins.
Obviously the skies the limit within reason for the manipulation of the page using the CSS file and the layout of HTML as stored. What you cant have is lots of pages though as memory is scarce but this is not designed for that purpose, its purely a control interface.
Step 8: The Video So Far
Here are some images of the PWM output which i have programmed into the PIC code.
The Timer circuit for CH 4 is not yet affixed to the board but will essentially control just the pond pump.
Web server O/P 1 is PWM for the led driver card which i will describe later and will bypass the Triac block.
It is not possible to dim the tungsten lamps at 2.5Khz using the MOC3063.
CH1 On the web page is mains O/P via the Triac
CH2 On the web page is mains O/P via the Triac
CH3 On the web page is mains O/P via the Triac
CH4 is mains O/P via the Triac but using timed on and off periods by the 555.
All outputs are fed via a 100uH inductance to limit the rate of rise of current through the triac during switch on although these have not yet been tested on the air pump.
You will notice that the web page has an outside temperature indicator and the plan is to add a pond temp sensor so I can watch the temp in the pond. I plan to implement this using an I2C I/O that is present on the PIC chip and couple to a sensor which i will mount on an encapsulated block of copper to dip into the water. More later.
Step 9: HIGH SIDE SWITCHING REDESIGN
Well the complete board was finished for the triacs and cables laid in the garden to power the lighting.
It all works fine even for the led's once i had removed three channels worth of snubbers. But wait...there is an issue.....if we look at the original circuit you will notice that the triac is being switched in the neutral.Now thats not good, it means that if i inadvertently run over a cable with the lawn mower i could liven something up....time for a rethink. Lets redesign but using the optos and triacs in the live feed. we will continue to switch on the zero crossing point but shift the gate voltage. If we now look at the circuit you will notice that the mains enters via the IDC connector and connects to a fuse. This then feeds a choke to get rid of any rf and limit the dv/dt across the triac. we are using BT136 triacs so 100uh should slow things down enough. This mains then feeds the top end of the Triac and a feeder resistor to the input of the zero crossing opto. With no current through the opto we have nothing on the gate and therefore the triac is held off. This means no voltage appears on the connector to the outside world and therefore no voltage exists on my exterior cable as the other leg is tied to neutral, which is normally at about ground. This means i can wear my flip flops in the garden and the dog does not get electrocuted, so far so good. What is not shown here is that the opto device senses the phase of the incoming voltage and at the zero crossing point turns on its triac thereby connecting the instantaneous voltage to the gate of the main triac which is on its sinusoidal ramp up.At approx 12v the triac fires and connects MT1 to MT2 which applies the full mains voltage to the other end of the resistor turning off the opto triac ready for firing in the other half cycle. I redesigned the main board as a prototype and tested using the active mains leds. Channel 4 has a snubber across the triac which will power the leds but i have a motor i am driving here so its not an issue. The three other channels have no snubbers and any active led sitting in the path of the triac is well and truly off. Job done. Take a look at the attached circuit diagram.