5
\$\begingroup\$

I'm wondering how practical (read: safe) it would be to use an audio capture device to "record" a mains AC signal for the purposes of monitoring the characteristics of the AC sine wave.

I am thinking something relatively simple like a feeding the live conductor through a resistive voltage divider and straight into the audio input. While this won't provide any isolation (but see below), I am assuming this will avoid any unwanted smoothing/filtering that could result from using a transformer to provide the isolation. However there is such a thing as a small 1:1 audio isolation transformer, but I'm not familiar with their behaviour - would they pass a 50/60 Hz sine wave of unknown quality without filtering it in any way? Obviously if it only passed through the 50/60Hz base frequency I wouldn't be able to see any distortion in the waveform so I imagine I will need something with a large enough bandwidth so as to allow any distortions to be accurately captured.

I would like to use a Raspberry Pi for the audio capture, mostly because it has an Ethernet connection for remotely streaming the waveform captures for display on a PC, but also because it has local storage to keep the captures in the event of a network interruption. Since it can be powered over the Ethernet connection and this also provides electrical isolation, I figure the solution with the resistive voltage divider isn't so bad because although the Pi itself would not be isolated from the mains, everything else would be. So long as the Pi is in a proper enclosure with the appropriate warning labels about it being mains referenced it should be fine...right?

My reasons for asking are that I am planning an off-grid set up and would like to experiment with using 3-phase motors as generators, so I would like to be able to continuously monitor the generated AC waveforms partly out of curiosity, and partly to have a way of identifying potential issues.

Being able to treat it as an audio recording also potentially allows me to capture say 24 hours worth of waveforms on a loop so that if anything goes wrong, I can look back and see what the power quality was like leading up to the event (e.g. frequency gradually dropping until it went out of range.)

There are devices you can buy that store waveform captures designed for power quality monitoring, but they are industrial devices and prohibitively expensive for hobbyists, so it would be great if I could accomplish the same thing myself with commodity parts.

\$\endgroup\$
9
  • 2
    \$\begingroup\$ An audio transformer will have a bandwidth into the many, many kHz, ideal for keeping all your line harmonics intact. Go with an audio transformer. Operate it within its Vs specification, so check very carefully what frequency the drive level is specified at. 1 kHz != 50 Hz. Do not even consider a direct connection to your pi unless its (a) battery powered or powered from the generator under test and (b) has a many kV opto-isolated link to the rest of your system, not just ethernet isolation. Ethernet isolation is only designed to break ground loops, not to keep you safe. \$\endgroup\$
    – Neil_UK
    Commented Apr 17, 2021 at 7:43
  • 2
    \$\begingroup\$ Upvote for an excellently-written question. Lots of effort put into explanation, a great example to any new OPs. \$\endgroup\$
    – TonyM
    Commented Apr 17, 2021 at 7:44
  • 2
    \$\begingroup\$ An audio transformer is unlikely to have mains isolation rating. Have a look at openenergymonitor.org to see how they're doing it. I also strongly advise against direct mains connection. \$\endgroup\$
    – Transistor
    Commented Apr 17, 2021 at 7:48
  • 1
    \$\begingroup\$ @Neil_UK: Ethernet isolation (1500 V) is designed to protect equipment and people from dangerous wiring faults and induced transients. \$\endgroup\$
    – Dave Tweed
    Commented Apr 17, 2021 at 10:49
  • 1
    \$\begingroup\$ @DKNguyen: Any "audio" interface is by default going to be able to handle the bipolar nature of the signal. \$\endgroup\$
    – Dave Tweed
    Commented Apr 17, 2021 at 10:52

3 Answers 3

2
\$\begingroup\$

Most audio circuits have a low-end cutoff frequency in the 20 Hz range. So, even at 50/60 Hz, they will have a small attenuation, and a noticeable phase shift (perhaps 10-20 degrees).

Why do you care about the waveform so much ? The AC line is quite 'dirty' and most loads don't care. Motors and (incandescent) lamps don't care. Laptops, TVs, and other loads draw power proportional to the input waveform (power factor correction) and also don't care.

You are challenge is most likely to be large V spikes (to 1000's of V ?) and may damage your recorder.

\$\endgroup\$
3
  • \$\begingroup\$ My understanding is that devices with poor power factor (e.g. electronics) may draw power only on part of the sine wave, which can lead to increased vibration in the generator due to each rotation having uneven torque. Monitoring the shape of the sine wave is one way to identify this issue before it becomes a problem, and to also shut down the generator automatically if there is a risk of the vibrations getting bad enough that it could cause physical damage. The idea is to protect the generator rather than the load. \$\endgroup\$
    – Malvineous
    Commented Apr 20, 2021 at 2:46
  • \$\begingroup\$ Well then you want to monitor the CURRENT consumed, not the voltage. With a reasonable generator, the voltage will remain sinusoidal, and if you have poor PF loads, the current will be distorted. Note that most modern electronics will have Power factor correction (PFC) and will draw sinusoidal current. Motors will have a phase-shifted current and only looking at the waveform will not tell you anything. Also, the distortion is during each cycle -- it won't cause noticeable vibration on the motor, \$\endgroup\$
    – jp314
    Commented Apr 21, 2021 at 4:41
  • \$\begingroup\$ The current waveform won't be a problem as I can just use a current transformer, it's only the voltage I would still like to measure. Like I said in my question, partly it's just out of curiosity, and a conventional generator might be able to manage the voltage regulation but like I said I'm just planning to use a simple permanent-magnet motor as the generator, so I'm not sure it will have good voltage regulation, hence my interest in monitoring the waveforms so I can actually see what's going on and learn from it. A number of the devices I wish to use don't have PFC. \$\endgroup\$
    – Malvineous
    Commented Apr 23, 2021 at 1:36
1
\$\begingroup\$

I have directly connected 120VAC mains to a voltage divider and directly digitized that and it works fine, although you really really do have to be careful about having energized neturals/grounds and stuff like that, which you seem to be aware of. Note that it is probably a good idea to put transient protection on one or both sides of the bridge if you want it to be connected for long periods, so think TVS on the high voltage side and zener diode on the low size.

Another potentially safer idea might be to use an opto isolator - either pre-packaged or home built. Basically use the mains voltage to drive an LED (possibly through a voltage divider) and then use a phototransistor to read the brightness of the LED from across an air gap. You might need two LEDs pointing in different directions if you want to see both sides of the waveform. Note that you will miss stuff very close to the zero cross because of the forward voltage of the LEDs, but you can add a bias if you need to see that stuff.

Quick and dirty that probably would work (and get me flamed on SE!): Connect an LED directly to mains with a suitable size current limiting resistor. Take a matching LED and point it at the first one and wrap them with some electrical tape to block outside light. Connect the leads from the second LED to the audio port. I bet the photoelectric effect on the second LED would be enough to be picked up by a 1V peak-to-peak audio port. If you can live with only seeing half the wave and having some clipping near the zero point, then you are done! Otherwise add another LED pair with reverse polarity and connect that to the other audio input (assuming it is stereo). You have some control over the gain and range by adjusting the current limiting resistor and size of the gap, and you can compensate for any non-linearity in software using Audactiy.

\$\endgroup\$
2
  • \$\begingroup\$ Very interesting idea using the opto-isolator! I presume I'd have to do some sort of calibration in case the output is not exactly linear compared to the input, or are opto-isolators designed to be used this way? \$\endgroup\$
    – Malvineous
    Commented Apr 23, 2021 at 1:38
  • 1
    \$\begingroup\$ @Malvineous correct. This should not be too hard since you can calibrate the curve based on the voltage going into the LED after the divider and then backwardly calculate the corresponding mains voltages. A voltmeter and potentiometer (or variable voltage power supply) should be all you need. \$\endgroup\$
    – bigjosh
    Commented Apr 23, 2021 at 8:29
0
\$\begingroup\$

I know I'm stepping in pretty late. A better solution to monitoring the voltage is to use one of the inexpensive voltage monitor modules. Search ZMPT101B. The transformer is a 1:1 turns ratio transformer so the primary current is mirrored as an equal secondary current; a resistor in the primary circuit determines the primary current and a sampling resistor sets the output voltage to monitor. They include a circuit that amplifies the output and sets the output centered at 1/2Vcc. These come ready to hook up easily to an Arduino (etc), provide good isolation, and extremely low phase shift - it is essentially "resistive". They can easily be powered from the Arduino regulator.

I have a couple of cautions with these transformer modules. First, the resistor that is included in the primary circuit is a small SMD resistor and there is NO WAY it is rated or safe for a 240V line input (as advertised). It would be MUCH safer to remove/short this resistor and use a series of several off-board resistors in series to get the needed voltage handling ability. The other issue is that the primary circuit resistor (820k-ohm) on the board as delivered is VERY close to one of the holes in the board for mounting! Stay away from this hole or use extreme caution with insulation at this point (nylon screw and standoff, etc.). Other than these 2 issues, it is the proper way to measure line voltages safely, they are readily available all over fleabay, and the needed mods are inexpensive and straight-forward.

The first stage amplification uses the Vcc/2 referenced secondary and sampling resistor (100-ohms) with capacitor coupling and a fixed 10x voltage gain. The second stage of amplification is variable (potentiometer) and produces output centered at Vcc/2. Be careful to not saturate the second stage, else clipping/distortion; best to keep the output in the 1V AC range for 5V Vcc applications. Remember, normal peaks are 1.414*Vrms, and there could be higher voltages, so with a 2.5V reference level the normal peaks stay well-enough away from GND and Vcc so that the LM358 amplifier stays linear. Record this isolated voltage with the audio recorder, etc.

\$\endgroup\$
3
  • \$\begingroup\$ Wouldn't passing the signal through a transformer filter out some of any potential distortion in the AC waveform, making the reading less accurate? \$\endgroup\$
    – Malvineous
    Commented Oct 26, 2022 at 14:00
  • 1
    \$\begingroup\$ Everything is relative. What frequencies are you concerned with? The suggested circuit is almost entirely resistive in nature, so it's not acting like an LC filter. But certainly there are bandwidth limits to the transformer, and also the opamp of the module, if you use the widely available module. I think it would show major distortions on the line, switching transients, etc. High freq and hard edges (high freq..) are likely somewhat attenuated. I have an X10 modulator, imposes a 120khz signal on the line. I'll check what that looks like and get back soon. Traveling ths week. \$\endgroup\$ Commented Oct 27, 2022 at 19:16
  • \$\begingroup\$ That would be useful to know, thanks! Given it would be sampling at audio frequencies (48 kHz, maybe 96 kHz) the highest frequency to be monitored would be limited to below 24/48 kHz anyway. What I'm most interested in is ensuring the AC waveform being fed to equipment is as close to a sine wave as possible, so I'm after something that won't smooth out any distortion in the waveform, which would hide potential problems (e.g. increased vibration in motors). \$\endgroup\$
    – Malvineous
    Commented Oct 30, 2022 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.