Mains Gate: Programmable Relay & Energy Monitor [120709-I]

HELP! I'd appreciate any assistance with this project particularly from someone with power experience.Proposal
HELP! I'd appreciate any assistance with this project particularly from someone with power experience.
Proposal
Rather than some US political scandal, this is an idea for "mashing up" five of the circuits from the July & August 2012 double issue to produce a really flexible "mains gatekeeper" circuit combining a multitude of control, measurement, protection and logging functions at minimal cost.
The sources are:
- "A Zero Current Switch" by Matthias Haselberger.
- "MOSFET Circuit Breaker" by Georges Treels.
- "Equipment 'ON' Counter for 68 Years Max" by Vladimir Mitrovic.
- "16 Ways to Switch your AC Power On" also by Vladimir.
- "Soft AC Line Start" by Jurgen Kruger.
The new circuit starts with the mains switching element used in (1), an IGBT or high voltage MOSFET in the DC arm of a diode bridge. However Matthias's discrete control circuit is replaced by a microcontroller. Georges' idea (2), measuring current by using the voltage drop across the on resistance of the MOSFET, is adapted by using an ADC channel in the microcontroller. The Microchip PIC range has some controllers with in-built op amps which would minimise the BOM and cost of this circuit. Voltage will be measured on another ADC channel using a simple potential divider. We are now in a position to duplicate and improve all the functionality of these first two source circuits using firmware in the microcontroller. For example, we can measure power factor and apply any compensation automatically, so eliminating the need for the manual link and capacitor in Matthias's circuit. We can easily implement the ideal AC switch: zero volt switch on, zero current switch-off.
Next I will pinch two ideas from Vladimir (3). A separate programming circuit enables settings to be written to EEPROM in the microcontroller as well as logged values to be read. I would probably use a simple BOB style USB connection and a PC UI for this function. Following Vladimir again, we can use the mains voltage measurement already described as a timebase for logging the on time.
It is now trivial to embrace and extend Vladimir's other circuit (4). By using the mains timebase, we can improve the timing accuracy over the internal RC oscillator used in the original. We can eliminate the hardware programming switches and the corresponding microcontroller GPIO pins using the external EEPROM programmer. This will enable us to offer a much wider range of programming options including ones which respond to an external optically isolated input to provide a true solid state relay. I would also add an output which could be used to gang a number of the circuits for power saver arrangements (e.g. turn your peripherals off when the power drawn by your PC drops, indicating it has gone into standby).
By adding an optional power resistor switched by a second MOSFET or IGBT in parallel to the first, we can have a soft-start as implemented by Jurgen (5), with the extra benefit of programmability.
Finally we can push the firmware into completely new territory without needing any further hardware. We can measure and log mains voltage, power draw, power factor and accumulated electricity consumption. We can implement protection trips on any of these parameters. We could even implement timer functionality by building a firmware real-time clock on the mains timebase. A light level switch or thermostat would also be easy to add as an option using a few extra components.
Design Process
Model 1 illustrates the mechanical design of the above circuit. It is designed to fit in the bottom part of the DIN rail enclosure mounted on the mains in and out screw terminals as shown. The main components will be on the underside with the available envelope shown as a white box. The IR input and output will be mounted at centre on top of the board with a shield between to prevent optical crosstalk.
Model 2 shows how an interface circuit is mounted in the top part of the enclosure with matching optical transducers on the bottom of the unit. Again the available envelope for component mounting is shown as a white box. A number of interchangeable interface circuits may be designed. The simplest would be a connection from one of the pairs of screw terminals to the IR transmitter for a relay input. More complex would be a USB or Elektorbus serial interface with programming and reading capabilities.
Model 3 shows a concept for ganging several mains gates together. The interface circuit is split into two “bookends”. One bookend has an IR transmitter optically coupled to the input of the first mains gate, which has its IR transmitter bent through ninety degrees to fire sideways. Intermediate mains gates have both receiver and transmitter bent over to couple with the adjacent unit. The other bookend has an IR receiver coupled with the transmitter of the last mains gate which has its receiver bent over to couple with its neighbour. The firmware will allow messages to be routed from receiver to transmitter so that they get passed on ‘bucket brigade’ style and seen by all units.
Update 28-Nov 2012
Schematic 2 shows several improvements in the light of bench testing. I found that MOSFETS rated for mains voltages and currents (I am testing using a STP14NK50Z) need a higher gate voltage than the PIC microcontroller can switch, so I added a MAX4427 dual buffer. I was uncomfortable with the inefficiency of the control-side power supply concept of Schematic 1 and experimented with the capacitor-based solution shown in this schematic. Sadly, while the power supply and the switching cell both work well in isolation, connect them together and the sour smell of burning plastic ensues! Anyone have any clever ideas about this? Will I just have to bow to convention and use an isolating transformer?
Update 01-Sept 2013
I am reluctantly retiring this as a dead end because we have been unable to come up with a control power scheme which meets the original vision of an economical self-contained unit. Without this, a more conventional multi-channel design will be better. If anyone wishes to revive this under their own name, or reuse some of the ideas in their own design (which after all is exactly what I was attempting to do), please do so with my blessing!
Discussion (9 comments)
JohnHusband 11 years ago
JohnHind 11 years ago
TonGiesberts 11 years ago
120709-mains-gate-advise3-schematic.jpg (145kb)
Arne.Hinz 11 years ago
PeterPugwash 11 years ago
JohnHind 11 years ago
JohnHusband 11 years ago
JohnHind 11 years ago
TonGiesberts 11 years ago
JohnHusband 11 years ago
JohnHind 11 years ago
Raymond_Vermeulen 11 years ago
JohnHind 12 years ago
PeterWashington 11 years ago
Had you considered the PSoC 3 or PSoC 5 device families from Cycpress, I confess I haven't used them myself so I'm not certain that they are what you want, but they programmeable Digital AND Analogue function blocks, (similar concept to a FPGA), built in and there available from Farnell starting at around 10 GBP for the PSoc 5LP based an ARM Cortex M3 ?
See http://www.cypress.com/?id=4562
JohnHind 12 years ago
Swieter 11 years ago
I like this project. I'm interested in seeing it happen.
As for the power supply, many moons ago I researched some similar ideas on transformerless designs. I didn't take my work much further than Googling around. That is I didn't get to create anything. Microchip has a couple Application Notes, and I am sure there are more that could be of assistance in the design.
AN236
AN954
If creating the power circuit isn't something you want to tackle, then maybe a module would work like MPL-03SE series from MicroPower Direct. Again, I haven't used these, but have a scribble in my notebook to try them out.
JohnHind 12 years ago
Hooligan0 11 years ago
Can you give us the values of R1,R2,C1,C2 you have used ? And what is (approximately) the current needed by IC1,IC2 and transistors control ? The smell of 'burning plastic' can be joule loss into R1 when C1 is empty.
JohnHind 12 years ago
JohnHind 11 years ago
I would like to build this project in a DIN rail enclosure so it will fit in a consumer unit box for safe mains wiring. The one pictured in the project image is from CamdenBoss and available from CPC-Farnel. It is a bit expensive, hopefully I can fine a lower cost / better alternative.
JohnHind 11 years ago
I'm looking at the PIC16HV785. This has a built-in zener bandgap regulator and two op-amps as well as a 12-channel 10-bit ADC and 256 bytes of high endurance EEPROM. It's a 20-pin package, a bit bigger than ideal for this application, and you need a high voltage programmer and a special 28-pin version for debugging.
An alternative is the PIC16LF1782. This is even bigger at 28-pins and lacks the internal regulator. But it has internal debugging and self-programming capability. It also has serial peripherals which would facilitate implementation of the Elektor bus, for example (with the HV785 the in-circuit programming link would be the only channel for configuration / reading - or bit-banging).
I am wondering if the mains-derived power could be made safe enough to avoid the need for isolation on the configuration link. I'm thinking about a fuse with a secondary shunt zener at slightly higher voltage than the primary shunt. If the primary shunt fails, the secondary conducts and blows the fuse. External IO lines could then be protected with diodes to VCC and GND.