There is a lot to be observed from the waveform of the electrical mains. Harmonics, transient changes, periodic fluctuations, frequency shifts, impedance, power line communications - These all give clues as to the state of the country's electrical transmission system (or what loads your neighbour has connected). Platforms like MATLAB allow for the easy analysis of waveforms through powerful software tools, but only once the signal has been acquired.
The purpose of this project is to allow easy and safe access to the electrical grid waveform without a hassle. It's as simple as power cable in and 3.5mm audio out.
The Grid-2-Audio module is comprised of three main parts:
1. The case and IEC all-in-one power entry connector - As part of teaching myself AutoDesk Inventor, I decided to start with the mechanical aspect of the project. The presence of mains voltage potential is no joke and the design of the case reflects that. The utilisation of an IEC power socket with built in switching, fusing and illumination minimises any mains wiring around the internal space of the unit.
2. The PCB power supply and mains input - As the unit is design to measure the grid voltage and introduce minimal noise, the power supply needs to ideally draw a minimal sinusoidal current (at the fundamental frequency) in phase with the voltage. Additionally, there needs to be isolation between the mains measurement circuit and the output side, forcing the requirement of multiple transformer taps for the whole PCB.
3. The PCB signal conditioning - The mains signal needs to be conditioned to the 3.5mm audio format and protected from shorts. As an extra feature, a 50Hz high-pass filter will be included to provide an alternate "harmonic only" output to increase the dynamic range for harmonic analysis.
Finally, after weeks of umming and arrring, the schematic is done!
The overall design of the system has remained unchanged with the exception of the input filter. Originally, there were plans for an input LC low pass filter to reduce the harmonics and fluctuations in the mains supply current, which would result in measured voltage harmonics in the system. This is due to the resistance of the input IEC cable. Here is the final system hierarchy with the LC filter removed:
To compensate for the lack of input filtering, the power supplies have been modified to include a series resistor to limit the 100Hz “inrush” current to the electrolytic capacitor. Each half cycle there is a rush to “refill” the capacitor, which results in a sudden impulse of current. The series resistor limits this current and dramatically increases the charge time of the capacitor. This thereby reduces the peak current and the voltage harmonics due to the IEC cabling resistance. However, this does reduce the minimum capacitor voltage and the transformer turns ratio has been adjusted to compensate.
The mains current before the series resistor is added:
After the resistor is added:
Other than this factor, the power supplies (+/-9V x2) are quite basic and remain mostly unchanged:
The signal acquisition block of the hierarchy takes the grid voltage and produces a safe, isolated, 4V copy to send on to the signal processing block:
First, the voltage dividers reduce the mains level down to the 4V level. Using such large value resistors (power dissipation limits) has the potential to introduce thermal noise at this point, so the thick film type resistors were used to alleviate the issue. The 4V signal is then buffered by an OPA2134 op-amp and fed to the ISO124 isolation amplifier (lower input impedance), which provides near-galvanic levels of isolation. One of the many drawbacks to the ISO124 is the practical requirement for 4 separate power supplies (two of which are isolated from the other two) to drive it. Additionally, the ISO124 leaves the signal with a 20mV (0.5%) DC offset, a very low current driving capability (<10mA) and a 10mV (0.25%) 50kHz ripple.
Signal processing time (some resistors and caps have not been selected):
The signal processing hierarchical block takes the 4V signal and applies a 2nd order low pass filter that works in conjunction with the internals of the ISO124 to produce a 3rd low pass filter to remove the 50khz ripple. This signal is then sent to an inverting amplifier to reduce the signal magnitude to about 450mV peak and provide increased current drive capability. In addition, this op amp also removes the DC offsets that have accumulated and removes any RF interference/noise (1.5MHz 3dB point).
The 4V signal is also sent to a 3rd order high pass filter for a harmonics only output (500Hz+). After this the harmonics-only output is sent to another op amp to increase the signal magnitude to a matching 450mV peak output (along with DC offset removal and RF reduction).
The final outputs are/will be scaled (approximately) such that:
Main output: 0-450mVp is 0-423Vp (50Hz to 20kHz)
Harmonics output: 0-450mVp is 0-20Vp (500Hz to 20kHz)
The frequency range does expand up to 50kHz (-3db), but it only remains flat until about 30kHz. As sounds cards (mostly) cap before 20kHz, I only concerned myself with the bandwidth under 20kHz during the design process.
Sorry for the incoherence throughout the post - It was written quickly in many chunks ;)
Still working away at it in my spare time, but a lot of small things are catching me out.
The latest is the ISO124, a 21 year old IC, with extended requirements for bypassing and output filtering:
It's not that it's difficult to implement, but the assumption that it this sort of IC conditioning wouldn't be necessary is what now requires me to rework some of the design.
This IC also makes all of its electrical claims with only a 2kohm load - Do I need this?! Can I buffer the output and improve the specs - Or does it make them worse?! I'm not going to make more assumptions. Working backwards from examples gives clues, but it is frustrating.
The 2k load then has a cascading effect on the power budget and so on, which is causing continual annoyances.
I'm been making some progress on the Altium schematic!
Although mostly complete, there are a lot of annoying "Altium-y" things left to do that mostly revolve around footprint hunting and component selection.
Here is a higher level schematic that more-or-less resembles the initial sketch:
The design is mostly a bunch or repeated power supplies and a signal conditioned from an isolation amplifier (not that it was going to be anything else). What is making it interesting, however, it the power restriction set by the extremely limited space in the enclosure that is forced upon me by the two 1VA transformers:
After an afternoon pretending that I know how to design third order op-amp filters, I settled on the following for the harmonics filter with the help of a web tool (http://sim.okawa-denshi.jp/en/Fkeisan.htm):
This tool helped with the design of the following:
Ignoring the op amp at the top, the bottom three perform the following functions (in order): -->Third order high pass filter -->Voltage gain -->Offset removal and buffer.
The third order filter is a Sallen-key type set up as a Chebyshev style with a cutoff frequency of 500Hz and a 1dB oscillation at the higher frequencies:
Now, with both the main signal of the grid and the harmonics (500Hz) set to the correct 1Vpp levels for sound card audio (assuming a maximum grid harmonic distortion of 5%), the two output signals look as followed on a virtual scope:
Within the actual "harmonics" output itself, the grid rejection of the 50Hz signal is -60dB (a one thousandth), but as the fundamental component is 20 times the maximum harmonic level, the practical 50Hz signal in the harmonics signal will be 1/50 (i.e. -24dB) compared with the harmonics waveform.
The next step is creating the Altium schematic and layout (or as I like to call it: The "design by whatever footprint library is available" technique).
For this project I've taken the reverse approach or designing the case before the PCB itself. In this way I've imposed at least some design limitations to stop the scope getting out of hand and forcing a completion for the project.
Apologies for the Inventor screenshot interface overlays, but here is the front and central sections of the casing in inventor:
And here is the implemented 3d print: (Prusa i3 "MK1"):
I designed the case in an extrusion style with a faceplate, but the 3d printing manufacturing technique also allows for lateral features like cooling vents or indents for rubber feet (of which there are 4). Ports A and B are for the direct grid output and the 50hz notch filter output. The PCB itself will slide in along notches along the wall like traditional aluminium extrusion cases.
You may have noticed the two colour printing on the front plate, which is possible through a script provided from prusa that allows the printer to stop and change filament at a specified layer.
For the back of the case (containing the IEC receptacle) I had to create a cap to hold it in place during disconnects:
All together I'm quite happy with the final appearance and will be quickly be moving through the circuit and PCB design phase (with an aim to have surface mount automated assembly performed through Seeed Studios).
Final fun photo is a "cross section" of the entire enclosure using a portion of the case that I opted to print in two steps: