A bit of review of this schematic, for me, please? - Page 1
Forum section: electronics / projects

author: LukeW
author_rank: Frequent Contributor
timestamp: February 17, 2012, 09:53:39 am
content: Hi everyone,If I could get a bit of peer-review of this schematic, to help ensure that it will work as intended, that would be awesomehttps://github.com/lukeweston/stuff/blob/master/plug.pdf(Tip for the GitHub uninitiated: click on "raw")Yes, this design is based on a transformerless power supply running from 240VAC.Yes, I understand what the implications of transformerless power supplies are in terms of isolation and safety.Yes, the unit will be completely enclosed in a plastic box during operation with no external cables or interfaces, only the RF link.Basically, this little unit will be connected in series with a 240VAC load device (a household device with a current draw of less than 10A).It will be interfaced to a remote controller wirelessly using an XBee 802.15.4 module (which will provide perfectly sufficient air gap isolation from the zappy bits, with no optocouplers, and no wired interfaces!)It contains a relay which will be used to turn on and off the power to the load, and it also contains the ability to measure to sample the load current waveform via a shunt resistor, so power use can be measured, and the voltage waveform too.I'm not going to use a dedicated energy acquisition chip like the ones you can get from Analog and Microchip etc, because I'd like something simple and cheap, even if it's not quite as accurate. So, basically, I'm just going to shove voltage and current waveforms into the AVR's ADC and try to construct a power measurement in the firmware. Maybe if everything goes according to plan I may even be able to do things like power factor measurement in the firmware. Yes, I know it won't be as accurate as a fancy energy DAQ chip.I have designed the Transformerless Power Supply for an output current of about 80 mA, which is relatively high for a transformerless power supply. This is why the capacitor is a relatively large 2.2 uF.The current budget breakdown looks something roughly like this:XBee module = 50 mARelay coil = 16.7 mAAVR = 5 mAMargin for error = 8.3 mATotal = 80 mAThere are non-isolated headers for ISP programming and serial debugging/programming - I might use an Arduino bootloader layer to make firmware development a bit easier.The XBee module will be unplugged during flashing - this means it won't stuff up if the programmer is injecting a 5V Vcc rail to the target.It goes without saying that all programming/flashing will always be done with mains disconnected!I have one of the XBee GPIO pins throwing a low reset pulse to the AVR, so hopefully the XBee radio link can be used to remotely reflash the firmware (via the Arduino bootloader layer) without the need to unscrew the case while the live hardware is online.I'm not 100% sure if the voltage/current sampling circuits will work as intended. These are a part of the system where I would especially like a bit of peer-review to help me check.What I'm aiming to do is turn both the voltage and current samples into sine waves that are scaled appropriately so the peak-to-peak amplitude corresponds to 3.3V when the load current is a bit more than 10Arms and when the voltage is a bit more than 240Vrms for the current and voltage waveforms respectively.These will be going into the AVR's ADC, with a reference voltage which is just Vcc, 3.3V, and I'm aiming to have them offset by +1.65V so that they're in the middle of the usable single-ended ADC range.Also, I don't want to introduce any phase distortion if I can help it, because that would mean we basically lose the potential ability to make power factor measurements, which I hopefully want to do.There are also a couple of temperature and light sensors sending back their readings to the remote side.The intended way that I've designed the current shunt amplifier to work goes something like this:(Note that this may be incorrect... you tell me.)(Note that the rail labelled as 12V is actually more like 12.4V, it's the 13V Zener voltage minus the 0.6V or so across the 1N4004.)Vshunt = 12.4 V - (I * 0.01 ohms)Op-amp Vout = 138.3818 - (11.0280 Vin)Op-amp Vout = -11.0 * (Vin - 12.4) + 1.65Op-amp Vout = (0.11 * I) + 1.65Peak-to-peak amplitude = 3.11 V at 10A rms load current.The voltage waveform is acquired by the voltage divider consisting of R17 and R19, AC coupled, and then re-biased to 1.65V by a voltage divider.Thoughts or comments?Cheers

author: Unknown
author_rank: Unknown
timestamp: February 17, 2012, 07:45:50 pm
content: Nothing to comment on within my skill level. However I'd like to say that submitting open source work for peer review is awesome. Hopefully more knowledgeable folks will chime in soon with useful feedback.

author: SeanB
author_rank: Super Contributor
timestamp: February 19, 2012, 02:01:29 pm
content: First off, a nice idea. You need to do some work on the input side. There does need to be a VDR across the mains input and output, as well as a fuse as well. You need a discharge resistor across the mains dropper C12. The mains sampling resistor can stay as a 1W unit, but it would be better to use 2 in series, as this will reduce voltage stress.Looking at the current shunt, I think you have arranged the power supply incorrectly, the common should be the top, and the diodes and capacitor should be the other way around making the lower side the 12V supply. That way the shunt resistor will be referenced to the common rail. You probably want to add a pair of clamp diodes to the voltage input, across R18 and R21, preferably a shottky diode, as clamps rather than relying on the microcontrollers input protection, as they will degrade with time and voltage spikes.

author: LukeW
author_rank: Frequent Contributor
timestamp: February 21, 2012, 04:00:31 pm
content: These are all reasonable suggestions, thanks.https://github.com/lukeweston/stuff/blob/master/plug2.pdfI have deleted all the microcontroller, etc, from this revised schematic for the sake of clarity. (Unchanged from previous schematic).By VDR I assume you mean a standard zinc oxide 240VAC MOV (rated for 275V or so, whatever the typical mains ones are) across the mains line, which I've added.I have reversed the topology of the transformerless power supply so that the mains active is connected to the floating ground instead of the floating +12V. And this should allow the op-amp circuit to be simplified to get rid of the tricky offset biasing stuff.I have added consistent capacitive coupling followed by Vcc/2 re-biasing to both the voltage and current signals. 100k resistors are used so that the HPF cutoff frequency is not too high and it attenuates the 50 Hz signals.Could you have another look and check this for me? Thanks.

author: LukeW
author_rank: Frequent Contributor
timestamp: February 24, 2012, 05:44:13 am
content: Sean? Anyone?Any further feedback or help would be much appreciated

author: LukeW
author_rank: Frequent Contributor
timestamp: February 24, 2012, 07:12:18 am
content: Actually, I have realised that the previous circuit will not work properly, because the opamp only has a single-sided 0-3.3V power supply rail and the input signal going into it was centered at 0 v with no DC offset.So I have reworked the signal a bit.https://github.com/lukeweston/stuff/blob/master/plug3.pdfI have capacitively coupled the input signal into the op-amp, and rebiased it to Vcc/2, and I have biased the op-amp to Vcc/2 also, with a gain of 11, non-inverting, so the output signal coming out of the opamp is still centred around a DC offset of Vcc/2, but the AC sine wave component is amplified.Hopefully I've set up all this correctly.

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 24, 2012, 06:47:51 pm
content: This is been a great thread with some things I have not thought about. I always love that.With a non-isolated power system, does the ground of the circuit essentially float with the active voltage swings? It seems like this would alter the characteristics of all the components, but I guess they are just looking at the difference between ground and +12V, maintained by C1.Is Neutral in your system, tied to ground at the power box? I know in the US, we are 120V active (used to calling it "hot") and neutral, where neutral is essentially ground, but only at the power box. Is 240V the same way? (In US, we run 2 hot branches for 240V, with a neutral and a ground.)Edit: I had been considering something like this on my "future projects list". However, I figured that I would try to use a power line communication system to a hub, as I'm already hooked to the power line already. The wireless solution would get expensive if you started wanting to monitor multiple devices.

author: SeanB
author_rank: Super Contributor
timestamp: February 25, 2012, 09:03:36 am
content: Looking better, you might want to add some resistance in series with C5, for overload protection. 1k would be a good start. you need to rework the opamp a little. Take 2 1k resistors in series across the supply rail, then decouple with 10-100uF to give a local half rail. Then feed this as a reference to bias the opamp, using 100k resistors to feed pin 3 instead of R13/14. R9/12 should be a single resistor to the same point to define the gain better. You can use the half rail as a feed to the voltage source as well instead of R3/8 as well, but you might want to get a dual op amp and use it to provide the half rail as well, instead of using a high divider current. C2 and C5 could be lower in value, as they will have a long start up time constant, and are driving a high impedance input in any case. 100n will do. You might duplicate the protective diodes from the voltage side in the current side. You will need low leakage diodes, and will have to make sure they are kept dark ( photodiodes do not make good isolating diodes if exposed to light) at all times.

author: LukeW
author_rank: Frequent Contributor
timestamp: February 26, 2012, 03:55:58 pm
content: Quote from: sacherjj on February 24, 2012, 06:47:51 pmThe voltage of the local groundrelative to the neutralwould vary up and down as the mains line voltage fluctuates, yes. (Because, after all, the local groundisthe active line.) But, exactly as you say, the +12V rail will remain fixed at +12V above the local ground. It's fixed by the zener diode.To understand how a transformerless power supply circuit like this works, it all basically just comes back to a basic principle in electronics - whenever we measure a voltage, it's actually a measure ofpotential differencebetween some node in the circuitand some other node in the circuit which we arbitrarily choose.In Australia (in single-phase low-power domestic household situations) we have the active, the neutral and the earth connected out to all power outlets on 3 separate conductors, yes. The neutral is connected to the earth only at a single point at the main distribution/breaker board where power is connected into (all) the premises, as per a system which is called (in Australian codes at least) Multiple Earthed Neutral, or MEN.I like the idea of combining this sort of system with a PLC (powerline communications) interface. That would be elegant... very cool. But I don't have any experience designing or working with those kinds of data PLC coupling circuits.

author: LukeW
author_rank: Frequent Contributor
timestamp: February 28, 2012, 07:14:03 am
content: Quote from: SeanB on February 25, 2012, 09:03:36 amThanks.I must admit I did have a bit of trouble translating your description of the changes to the opamp circuit into actual schematic when drawing up the schematic. I'm not sure that this is right.https://github.com/lukeweston/stuff/blob/master/plug4.pdfJust ignore the 1N5711 diode values, that's just a placeholder until I pick a good practical choice for the type of diodes for the clamps.I'm not sure R5 looks right, but I couldn't really visualise what you meant in terms of feeding that bias from the buffered 1.65V reference circuit (added as per your suggestion.) I'm mainly just used to doing that sort of thing simply with a voltage-divider pair after the coupling capacitor.I should check that the 100 nF capacitors have an appropriate 3dB frequency when combined with the input impedance of the opamp circuit (and the biasing resistor in the voltage circuit). It should be as low as possible, below 50 Hz, otherwise it will start to significantly attenuate the desired 50 Hz signals. But I think it should be OK, the input impedence of the opamp circuit should be sufficiently high, meaning that the highpass centre frequency will be sufficiently low.

author: SeanB
author_rank: Super Contributor
timestamp: March 04, 2012, 05:39:43 pm
content: R9, R5 can be 100k or so. R14 should be connected to Vcc/2 instead of GND. You do not need R12 at all, put a 100pF in it's place ( placeholder value) as a high frequency filter on the input circuit, it will have no effect on the mains and first few harmonics. D3,D5 are in the wrong place, they should be on the input of the opamp instead of the output. Where they are currently they will protect the micro, not the poor opamp. R1, R2 can be 47-220k, lower supply current, and the opamp will supply the needed current gain. watch out for the leakage in C2, you might want to spec a 1 - 10uF 35V tantalum unit to have low leakage current. Your PSU has a limited power supply ability, and you want to keep the power below 5ma total unless the PSU has a larger value capacitor for C12.You might add a MOV across the relay contacts as well, just to reduce arcing if they get frequent use.