About: Enjoy all types of reverse engineering. Projects such as web servers /rtos /power supplies

Here is a follow up project that expands on the original zero crossing Triac Controller that was designed previously. I wanted to expand the controller to allow web based control as before but to increase the number of channels and still have the capability to drive an air pump in a timed manner with separate on and off periods which are pre-settable via a couple of pots.

It is of course possible to have done this in software with a button that shows the on and off phases but decided not to do this and to use the "kiss" principle for now. Maybe I will look at down the line perhaps.

The design is somewhat like the original project but have simplified by removing the PWM control that was on a slider and controlled the dimming of some leds. I have elected not to do this with this project and stick to a standard 8 Channel controller with opto isolation and zero crossing functionality.

The controller and web interface module is based on a PIC 18F67J60 which is part of the OLIMEX picweb rev c board which you can google and find details on. Because of the modularity of this design you could use any controller you choose, you just need 8 ports of logic drive.

The webpage for the front end is first compiled using the microchip utility and loaded into the board independently. The code for the webserver is compiled using the Microchip IDE and the MCC18 compiler. Although I got the code to partly compile on a windows 10 platform the linker refused. I had to resort to the trusty win7 OS which was on a 64bit platform but compiled fine. The web page was created in Dreamweaver although any good html editor would work fine. The bottom line is that the interface board and webserver can be replaced with any controller you choose to use as the main triac board just needs 5V DC and the ability to ground any of the control pins to turn the triacs on. Due to the requirement to drive LED floodlights in the garden I have dropped down the fuse ratings to 500mA per channel to cater for 10W Leds and only CH 8 has snubber for motor drive. Incidentally 1.6A rms X 220v still equates to approx 350W so still capable of reasonable single phase motor.
The image here is the front end as displayed on a web server. The channel select buttons are on the left and of course toggle when accessed in a browser or phone.

Using the OLIMEX board does allow you to use the onboard thermistor to display the temperature of the enclosure it is mounted in should you so wish.
As before the code uses AJAX dynamic web page techniques with all status passed by a status.xml file and not having to reload the web page entirely on refresh which is done automatically at 500mS intervals using JavaScript.




The front end of the design consists of the PIC WEB OLIMEX board seen here with the ethernet cable connected and the Pickit 3 connected. I have modified the code for the ports I need and have managed to select 8 pins that can be used. The chip itself does support I2C so you could always expand out further if you wanted a myriad of ports to control although the web page space would be a little limiting in this regard.

Essentially selecting the button on the web page toggles the ports that are defined in code.
On the PIC you can define these and map to the 18 series chip. On initial all ports are held at zero including port 8 which holds the 555 timer in reset. More about the 555 later. All the outputs go through fet inverters on the intermediate board which drive the opto isolating triacs, which subsequently trigger the main triacs.

Its possible to bypass the 555 by using the handbag link on the intermediate board which takes the o/p straight to the triac board. Note the double inversion on the input to the 555 so that all outputs at zero mean no output.


Lets walk through the block diagram.

Starting at the home router from the cloud we hopefully will have a local non routable ip address set up on the pic web module. This is set in the config.h file so we change and add to the local address range we are using on our router. I also selected the pool addresses for DHCP to avoid the router giving any addresses that might conflict. once this is done I set the router to port forward on port 80 to the ip address that you set.

Following on from this I plugged a link from the router into one half of a Simplex HP200PT ethernet over the mains module. The other half is plugged into the garden shed mains socket which then connects to the web server. The IDC connector then plugs into the intermediate board and then by RJ45 to the Triac Zero Crossing module. Once you plug a 9V DC into the web server then you can connect from anywhere in the world and it will serve up your pre saved web page front end.

This is of course no different to using a Hive module or similar with Hub but hopefully this is cheaper.

Of course this non-secure so is not equivalent to other devices out there but with a little code tweaking at the web front end or a firewall at the router you could restrict traffic or hackers. Its on the todo list.

Step 3: Intermediate Board Walk Through

So starting with the power supply we are using the same 9V feeding the web server. This is dropped down to 5V to power the 555 and circuitry. The drive from the Olimex is 3.3V and is inverted by the FDV's to switch the inputs. Pin 28 is the port G4 from the webserver pic chip and drives the snubber based o/p 8 for our motor.

The 555 is set to work in astable mode and held at reset by the reset pin. Unfortunately we cant drive this directly by the web server because of the 5v limitation but we do a double inversion by the FDV301's and hold it low.

The two pots on the charging circuit were chosen to give me an independent mark and space ratio so i can control the pulsing of the air pump for the desired pond effect.

Now if you do not want this to be controlled by the 555 then just select it out using the handbag link on P1.

All the o/p's are mimic'd in hardware by the use of led's on the intermediate board so you can see the operation of the web server works correctly. This was a good test procedure so that when i am in the shed and connecting via a gsm i can see what channels are activated with the triac unit disconnected.

I will provide a video of this in operation so you can see it working up to the intermediate board stage.

Connectivity ...oh yes.. the intermediate board is fed with the same 9v from the web server plug and dropped down to 5 to power the board. I have fed this forward via plug P3 to the triac board although you can always power the triac board directly with 5V for test purposes.

Control wise i have used a standard RJ45 connector pin to pin which i have crimped together however you could just use a standard wired connector and compensate for the crossovers!


OK so if you have been following then you would have seen the construction and use of the intermediate board to switch the triacs, lets have a look at the main board.

From the left we have the RJ45 connector which serves as the ground point to trigger the opto isolator IC's . There are led's on all the trigger inputs current limited by 100 ohm resistors, so you can see which channels are enabled at any one time. One side of the MOC 3063 is fed with 5V permanently and the anode side of the device diode is fed the RJ45. Grounding the respective pin will turn on the led on the board and enable the main triac. The opto isolators themselves pick up a mains feed from the non isolated side to detect the mains crossing points and for U1 is by R1 on pin 6 . Internally there is a connection for the zero detection circuitry to generate a pulse which is on pin 4 and fed to the gate of the external triac. Once the triac is switched on the full mains voltage is switched across MT1 and MT2 of the external triac and feeds 220V in this case direct to the device to be powered.

As the switch is operating on the hot side of the mains then no external cables are subject to volts when off .This is safer if you have a neutral available to you and live connections are not sensible to route externally permanently in a switched feed.

Step 5: Construction and Use Notes.

As this project is mains orientated i have to reiterate the safety notes about working with mains voltages. At 220V they can be lethal so if you are thinking about constructing this then tread carefully. Work with high voltage removed wherever you can . I have used an IEC cable as a feed here which i can unplug quickly to isolate the the unit. Do not hang scopes or anything directly across the rectified mains without use of an isolating transformer particularly where ground is not strictly ground. As mentioned before don't float the scope by lifting its earth, its dangerous and you forget to replace,

Tracks on PCB's carrying mains current.

All the tracks on the PCB that are carrying mains current are 1 mm which according to the spec above should be fine for the current concerned. The Triacs used are BT136's which are good for 4A but would not want to push them to that amount of dissipation in this set up.

If you want to read more then this excellent web site has the graph and the details.

Check it Out!

Step 6: The Intermediate Board Layout

There are three pdf's i have attached for the intermediate board . Two are for the prints.
They should all be at 100% scale and suitable for printing onto tracing paper. the top view is reversed so that the dark side is against the PCB

Overlay the two images and sellotape them together.
Slide in your double sided board and expose and etch as per normal. i covered this in a previous tutorial.

Unfortunately you will have to drill and wire through the vias if you are doing this yourself.

The BOM for the board is as the attached.

While you read the previous i will etch and prepare a board and create a video of how to get to this point.
Watch this space for the link!

As promised here is the link to the etching process.
The Intermediate board is being etched here before i populate the board

nb I made a couple of changes to the intermediate board. One crucial which is the ground from pin 19 of the main connector to ground on the intermediate board and change in the size of the footprint for one of the caps.


In this section I describe in the video how to test up to the intermediate board and that the interface is being driven correctly. Of course the data or logic here is a one way ship and the assumption is that it works when you see the buttons change on the web page. As you can see from the schematic I have added leds to the channel driver circuit on the Intermediate board and the Main Triac Board so you can see the optos on the Triac board being driven in real time as a confidence. I could have added some more logic and fed back the actual current drawn via hall effects to the micro but cost is cost and the 4 channel version ran for three years without incident. Have a look at the video of the completed 8 Triac board which is similar to the four channel Triac Board I published earlier.

Added Triac main board dummy load test before putting into enclosure.

Step 8: Closing Stages

Here are the closing stage videos I have uploaded to You Tube

One is a load test with the boards in their enclosures and the other is the outside view lighting up.

Also added some motes about the web page construction thats downloaded to the pic chip.