Chapter I. Hardware.
Part 1. Analog Front-End. Opto-Isolator.
Looking at the Power Quality Analyzer display, I was wandering, if there is any error in the measurement results, introduced by transformer. Overall THD picture doesn’t change much, suspiciously drawing same chart in the morning and in the evening, when electrical grid load significantly differs. Obviously, to estimate effect of the transformer, I have to repeat measurements w /o one, than check again if there is something new. It is one reason, why I decided to design my own Analog Opto-isolator.
Thinking of Power Meter project, I realized, that except Voltage Isolator, I’d need Current Isolator as well. Things are easier with Voltage measurements, even I’m not sure at this time if transformer relayed harmonics content proportionally / correctly to what is has at the input, the same time dynamic range for Voltage is quite narrow. Value is not changing much from default 110V, may be -10 ~ +10 % at the most. But it’s not the case for Current, which may vary over great extent.
Quick search over the i-net for AC current sensors, brings quite disappointing results. Sensors based on Hall Effect IC with optical isolation are expensive. Another category – Current Transformers, using simplest and well developed for over 200 years technology is also not cheap. And not accurate. Data sheet specification, what I read, states that liner response of typical current transformer is only in a range 1 – 100 %, or just 40 dB. Price tag – several dollars and up. Even more expensive, and definitely not for hobbyist budget, most advanced samples have 0.1 – 100 % range, or 60 dB. And it’s another reason, to develop Analog Optoisolator, which would cost less, and be linear over 90 dB.
Warning: Shock Hazard
The meter described in this project connects to high currents and high voltages. High currents and high voltages may be hazardous, even lethal. I’m not taking any responsibility for consequence that may result from the use of this publication or the circuitry described herein.
Don’t turn away, circuit shown above, despite it’s simplicity has outstanding performance:
- Linearity better than 0.1%
- Dynamic range more than
100 dB50 dB.
- Voltage gain ~25.
As you can guess, the reason not to use OPA and Linear opto-coupler in design, is to bring down overall cost. There is no need for amplifier at the other end, photo-transistor loaded by 4.7 k resistor. Voltage gain is not required for voltage sensing board, but it’s must to be in current sensing circuit, as shunt resistor outputs low voltage level, which in next turn limited by dissipated power. For example, assuming 0.25 W for power losses on shunt resistor, voltage would be: V = P / I, and for 20 A load generates only 12.5 mV. Having gain 25, 0.883 V peak-to-peak obtained at the output, which is perfectly match with arduino 1V ADC reference level. There is only one drawback. Circuit, based on Voltage regulator IC ( LM317 – configured as operational transconductance amplifier – OTA), requires manual adjustment / balancing for THD level. Good news, you have to do it only ones.
DC level matching to switch On internal 1V reference is not finished, work in progress. Would require 2 resistors and two caps in minimum configuration, may be voltage regulator / reference for filtering.
Same with ripple voltage (shown ~28 mVp-p on first drawings), probably, will add up LM7809 later on.
Two photo-transistors of the optocouplers loaded asymmetrically, 1k and 4.7k, in order to have maximum voltage gain. Plus, they have different collector voltage, so current passing via one LED has to be reduced. The easiest way to make initial adjustment, is to power up circuit from 12V insulated power source ( any cheap wall-wart / wall-mart is o’k), than apply sine waveform at the upper side of trim (50 k – adjustment pin LM317) pot. Next, measure THD level at the output using any available spectrum analyzer. I used my computer sound card and JAAA software. In this test, output may be powered from the same power source (better not, especially with wall-wart / wall-mart) or using arduino +5V.
First things to do, is get approximately 2.5V DC ( for +5V power source ) level at the output, tweaking another 50 k pot, which is in parallel to optocouplers photo-diode. Than do a fine tunning using 1k. Objective is to minimize THD level. 3-rd and 2-nd harmonics are most noticeable, but there is a chance, that “optimum” settings for them would be slightly different. If so, reduce input, and see that you have K-3 lower than -60dB, than make adjustment till K-2 drops to same or close level. Repeat a few times. Basically, technics is similar to balancing audio PA.
Distortion level goes up at higher frequencies, but as primary function for this opto-isolator is power metering application, I don’t care much, as long as THD stay below 0.5% at 20-th harmonics, or 1200 Hz for 60 Hz electrical grid. Same apply for linearity of the frequency response over specified range, as long as magnitude linearly declining no more than 1.5 dB. What is interesting, LM317 has “build-in” anti-aliasing filter, which attenuates frequencies above 1.5 – 2 kHz.
Real life test, Power Quality Meter project running with new Voltage Opto-Isolator board.
to be continue, next – current sensor…
Part 2-1. Current Board Opto-Isolator.
Replicating simple circuit based on LM317 and MCT6 optocoupler, I stumbled across one serious issue. I can’t get desirable dynamic range due high noise / interference level. As voltage from shunt resistor is ~12.5 mV only at maximum, decreasing load current to a few milliamps drops voltage level to just a few microvolts !!! Changing values of resistors, de-coupling capacitors, and adding up LM7805 regulator, I had almost no progress for a couple of days. Here is the drawings:
It’s working, and may be useful for AC current monitoring in a range 40 mA – 20 A. But it’s not what I wanted. My goal is to have a minimum measurable AC current at least 2 mA, better 0.2 mA. Which implies 80-100 dB dynamic range. I came to conclusion, that problem is in high level of interference seen by optocoupler from electrical grid. Taking in equation ~ 25 V, optocoupler must have 140 – 160 dB common mode transient
immunity (CMTI). Opto-isolator used in design can’t provide such high CMTI.
BTW, circuit above could find application in high side DC current measurements, where interference isn’t an issue at all, and could be easily filtered out.
To be continue…
Part 2-2. Current Board Opto-Isolator with PGA.
As I described earlier, low price version of the analog opto-isolator doesn’t work well with the current sensor, due high noise / interference level. It’s not shown on the drawings, but there was an amplifier with gain x400, I used in my experiments, to bring up very low signal level I got in small current tests. In order to solve an issue, I moved amplifier on sensor board. Basically, this is well known technics of using compressor / expander to lower dynamic range of the system. In my case, “bottle neck” is optocoupler, and compressor has to be on sensor board ( Programmable Gain Amplifier is nothing else than compressor ). It’s ad up cost of 74HC4066 and one more MCT6 optocoupler to the project, but it did the trick. Current sensor in this version has dynamic range more than 90 dB, which was my objective I state in the beginning for this Power (Energy) Meter project.
And here Shunt Board, Main Board, and Voltage Sensor Board (practically, intact from posted above).
Couple after-words, before I moved to the software section on next blog-page. For safety reason, better to use two optocouplers instead of one shown on the drawings in analog path. In current configuration, there is very little spacing between high / low voltage sides, as input and output routed to the same side of the optocoupler. This concerns both sensor boards, for Voltage and Current.
Now, when hardware part is complete, I’d start to work on software. Of course, FFT would be there -);
to be continue…, on next page..