I've been looking at my own design of power meter. I was getting bad distortion from AC-AC transformers and decided to look at removing the transformer from the design. I started off looking at opto-isolated linear amplifiers, but all these do is V-to-f, send freq pulses over the opto, and then f-to-V again. As I wanted to digitize the signal anyway I thought I'd just move the ADC onto the 'live' side.
I've now come up with a working design. The SPI ADC can convert in 15us, so a max sample rate of around 66kHz, or 1300 samples per mains cycle. The electronics is isolated from the microcontroller using a SPI opto isolator. The whole circuit is then referenced to mid supply (2.5V) using an op-amp. A voltage divider then drops the 220V AC down to just under +- 2.5V peak. The ADC inputs are protected against overvoltage with a pair of Schottky diodes. I can read the reference voltage directly with the ADC, which removes the need for a software DC removal filter.
I'm now starting on the software. Still waiting for the current transformer to arrive, but hope to have a high resolution power meter. I'll write it up properly on my projects site http://www.rotwang.co.uk/projects/projects.html when I've made further progress.
I'd be interested to know what people think of the design.
My immediate concerns would be that the design and layout requires attention to matters like creepage distances, etc, that the average constructor is unlikely to know much about, and then when construction has been completed, testing and fault-finding requires working on live equipment. Professionally manufactured and properly protected, it clearly addresses many of the problems experienced with the current EmonTx, but it is not a design that I could recommend for anyone not possessing the relevant knowledge and experience.
Obviously the distortion you mention is of concern to you, but is it of any consequence for most requirements? Maybe the simpler solution would be to accept that the transformers generally used are not designed for measurement purposes and to use a transformer that is. If you run the standard AC adapter at half voltage, you will see the distortion reduces dramatically. So it can be done. 'Budget' adapters use the minimum amount of copper and iron to keep the price "competitive". If you are prepared to drive the iron less hard so that it stays away from saturation, you will have lower distortion, but at a price.
You are right about the potential hazards if the unit is not constructed correctly. I wouldn't recommend the design unless you knew what you were doing. I should have stated this.
The prototype was built in a way that allowed me to fault-find by isolating the voltage regulator and the AC divider, and power both sides of the opto from the same supply. I could then get the circuit working without applying any dangerous power. I then connected the regulator, so the mains side was self powering and used a signal generator to test the ADC. I could subsequently connect live mains knowing the circuit was fully working.
My aim was to produce an accurate measurement. Without having an accurate reference it is difficult to know how much distortion is due to the magnetics. The outcome of the experiment might be that I don't need anything this fancy. It would at the very least allow an objective assessment of simpler designs.
Good post daveb, I've subscribed to the post and later will digg a little bit more
All I can add is when I did an X-Y plot of mains against the output voltage of a possible new AC Adapter (deriving mains voltage directly via a resistive divider - yes, I know!) and fed via a variable transformer, the loop that I saw at 250 V collapsed noticeably at 230 V and it was an almost dead straight line showing 0.82 degrees phase shift at 125 V. I didn't note the harmonic content of the output, but I'd guess it was very close to the input's.
I've finally got round to writing up some notes on this design. I still haven't finished the software, but the hardware is stable.
Nice work there daveb.
daveb: Maybe the AC/AC transformer that you used was not up to the job. The one that I found lying around was from some old telephony device. It has an 8V dc outlet which is unused, and an AC outlet which nominally provides 6.5Vac. When run with a burden of 150R, it produces the entirely acceptable waveform that I've shown at http://openenergymonitor.org/emon/node/824 Keep it simple, I say!
Hi calypso_rae : yes, you are probably right. I tried with a couple of transformers. Clearly, if the AC-AC adapters used in OEM were as bad as this they wouldn't work at all. Have you analysed your waveform to see what the distortion is? You can build up quite large power errors with relatively small voltage errors mid peak, where the bulk of the energy is.
The circuit as shown is probably not a practical approach, but the design process was interesting. It does give accurate results though. I think that elements of the current interface, the PGA, the voltage reference buffers and the software (especially converting in the background to increase sample rate) are all applicable to the OEM project and would improve it.
With this circuit I can measure the power of my 1.5W phone charger and clearly see it switching on and off, I don't think that is possible with the existing OEM design.
Hi daveb: Your circuit may well give excellent results, but it's workings are way beyond my comprehension (apart from the buffer for the 2.5V reference!) No, I've not done any analysis, I've just followed the standard design which seems to be working OK and is heating our water.
Isn't an AC/AC mains adapter just a simple transformer which could be as beefy as is necessary to ensure a good waveform? The secondary is taking very little current so I would have thought that a decent stand-alone transformer would give a nigh-on perfect copy of the input waveform. With a pre-packaged adapter, although no high-voltage parts are exposed, the quality of the internal ironwork may well be of lesser quality.
Maybe someone would like to measure their mains voltage via a simple stand-alone transformer, stepped down and biassed for the Arduino, and displayed using the sketch that I posted yesterday at http://openenergymonitor.org/emon/node/824. I reckon the waveform should look OK ...
"You can build up quite large power errors with relatively small voltage errors mid peak, where the bulk of the energy is."
True enough, but that isn't where the distortion first appears. The earliest symptom you see is a shift near the crossing - there are two pictures here (which also demonstrate how things improve at a lower voltage). Some of the distortion may be due to the variable transformer that was in use for the tests.
Attached are pictures under the same conditions for a different adapter with a slightly higher VA rating. The yellow trace is the mains, the red trace is the adapter output. Also attached is a video - the X-Y plot of mains versus output as the voltage is swept over the range (zipped Windows .avi file).
I have not measured the harmonic analysis of the raw mains without the variable transformer in circuit.
"With this circuit I can measure the power of my 1.5W phone charger and clearly see it switching on and off, I don't think that is possible with the existing OEM design."
Also true, but a large part of that is down to the extra 6 bits you have in your ADC.
I think you are spot-on with "the internal ironwork may well be of lesser quality". These adapters are built down to a price and not for quality, and let's face it, for most purposes that is plenty good enough. If it charges the battery OK, that's it. These things are intended for sporadic use. You could put more iron and more copper in, the losses would come down, the running cost would come down, the waveform would improve but the selling price would rocket (comparatively!) and the market would not take it. If you're making a distribution transformer that is powered full-time for maybe a 30-year life, losses are important (because they eat out of the electricity company's profits) and so extra capital cost is repaid. The normal domestic user doesn't think of that (unlike us energy-conscious types!).
If I could find a low-power transformer with a 415V (or so) primary, I'd recommend trying that. Unfortunately, it would have to be made to order - the smallest I can find commercially available is rated at 100 VA. (R.S. no longer do their wind-your-own transformer kits with iron laminations).
I have designed an analog power meter using a multiplier for an immmersion controller and run into the same problem as you and worse with the voltage pick off. Extensive testing on using transformers as an accurate voltage pick gives the following errors.
Phase change due to variation in input voltage.
Phase change due to change in core temp
Phase and voltage shape change due to loading.
All in all they are bad news
I am now using a resistive divider to tap down the voltage but as well as clamping to the supply I have used two zeners back to back across the tapped down voltage. This has the advantage of protecting in case of failure of any of the resistive divider which would destroy your power supply. It would make sense to produce this as a potted block for use instead of the transformer.
Do remember that without galvanic isolation, the WHOLE of your meter is live and a potential danger.
If an X:Y plot of the 'tapped down' mains voltage versus the transformer's output is an oval, can that effect be compensated for using PHASECAL?
Sorry if this is a dumb question, but this post- Ohm's Law stuff is rather a shock to my system!
Plus the same effect in the c.t. and the error due to the voltage and current not being measured at the same time.
(And this is a long way past Ohm's Law )
OK Robert, thanks.
I think we all understand the basics of AC, and that a circle has sine and cosine components. But once the conversation moves into more complex and unfamiliar terms, many people start to struggle. I certainly do. I don't particularly wish to know all the underlying theory; I just want my PV Controller to work as efficiently as is possible.
I've started to write a piece in layman's terms which will hopefully consolidate these ideas in my own mind and may be helpful to others. It will have lots of pictures :)
Sorry - I can't help having been an electrical engineer for the past 45 or so years (if you count from starting as a student apprentice)
If you do know - or can look up and work through the theory (and there is plenty of information on-line, though not all is complete nor reliable) and use available tools, then you can bypass a lot of the practical experimentation and come up with a solution that not only seems to work for you, but does work and will continue to work both for you and others too.
Open-source tools for energy monitoring and analysis. This project uses the GNU General Public Licence