Computing stuff tied to the physical world


In Hardware on Sep 23, 2011 at 00:01

Is it time for a tin foil hat?

Well, a recent comment mentioned common-mode voltage swings, and I think there’s a point there. With some resistance and impedance between the point I’m measuring and the power source downstairs, it’s easy to see how the whole thing swings widely in its “common mode”. Even the slightest leakage path to a non-swinging voltage potential could introduce a very substantial voltage difference.

Here’s a new test (it’s not the time to make mistakes!):

DSC 2635

What this does is place a ground plane underneath the whole circuit, sitting on (my all-time favorite) foam board. The foil is only attached to the JeeNode’s ground, nothing else.

And lo and behold – it really makes a difference!

The signal is 4 mV with nothing connected, and 7 mV with the power cable plugged in (but the switch still off). Turning the switch on has various effects, depending on whether the 100 W light bulb is plugged in.

With the light bulb included, the voltages I see are 80 .. 120 mV. Without, the voltages are 150 .. 400 mV. Still large swings, but nowhere near the consistent 650 .. 700 mV I was seeing before.

But what was more surprising (well… not in hindsight), is that these measurements depend on which way the power plug is plugged in. These old plugs are not polarized, so it’s easy to turn them around. It lets me put the measurement circuit in series with either the “live” or the “neutral” wire this way.

What I really like is that I’m back to 4 .. 7 mV readings when nothing is hooked up. That’s just one or two least significant bits, since the ATmega’s 10-bit ADC measures with ≈ 3 mV step sizes. It’s impossible to expect any better. This is also essential to get a decent shot at detecting low power levels.

Hm… this outcome is very awkward. A fully conducting enclosure might be best, but it’s also the most tricky one to deal with. This is after all still a dangerous 220 V hookup. A metal box inside a plastic box, perhaps? Yuck.

A shielded cable might help. Electrical signal amplification would introduce more (active i.e. power-consuming) complexity. Still, an op-amp with a super diode would allow using a capacitor to do the averaging.

  1. For me, this has nothing to do with ‘shielding’ (there is no earth connection of the shield, nor does the shield introduce a barrier between the ADC input and the AC parts of the circuit). You just build a more well defined capacitive coupling between Jeenode GND and (not well defined) parts of the AC circuit. As already said, this helps to couple the measuring circuit better to the voltage to be measured and prevents the ‘voltage swing’.

    • Good point. But how does that work, exactly? One side of the circuit is directly tied to one side of the shunt already. In essence, I’ve just added a big metal surface to one side of the shunt, right? (which then carries live 220V!)

    • I don’t see the ‘direct’ connection of GND to the live line. You use a resistive divider for coupling. This is superimposed with several capacitive dividers between various parts of the circuit and the environment. I see two possibilities: - no galvanic isolation, connect GND with low impedance (‘directly’, 0 Ohm) to one side of the shunt and measure only the positive halfwaves with rather low resolution. Or use an opamp with common mode range down to -0.1V and use amplification. - galvanic isolation, use a CT and again with or without amplification. This could be placed in an earthed metal box for shielding.

      A metal box with connection to 220V is shear horror!!!

      Sadly I have no time at the moment for tests with my own hardware setup. I hope to be back to ‘hobby electronics’ in two or three weeks. I am working on a remote switch with ardouino like hardware and RFM12B and I would also like to have some kind of current measurement in that for overcurrent protection.

      BR, Jörg.

    • Ah, yes – forgot about the voltage divider. Im doing these direct connection tests mostly as baseline, for a practical solution it will need to be non-contact. But it’s still useful to know how much could be measured directly. Especially since that turns out to be so tricky!

  2. The distinction between live and neutral wire puzzles me. Don’t you use an isolation transfomer anymore? Or did you ground one of the wires after the isolation transfomer?

    If it is the latter, then it would defeat the purpose of the isoltation transformer IMHO. I assumed that you use the isolation transfomer to have the potential on both wires floating, in order to avoid electric shock if you unintentionally touch one of the wires.

    • Correct – in this case, I went for a live hookup because of space/placement in the lab. With the isolation transformer, polarity should not make a difference.

  3. Some thoughts I would like to share:

    jcw, did you consider measuring the ac voltage as well (trough a divider), so that you can multiply its ADC reading with the reading from the current and get the effective power? This way, you don’t have to worry about rectification and non omic loads. Maybe it could also help with the noise problem, but this is just my guts feeling…

    The moving average procedure, that you presented here: does not take the average of the last 500 readings, but a weighted average of every reading from the very beginning. If you start with your initial guess x0, and collect the values x1, x2, x3, …, the average (avg) develops like this: x0 -> (x0 \* 499 +x1)/500 -> (x0 \* 499 \* 499/500 + x1 \* 499/500 + x2)/500. Notice, that the initial guess keeps a large weight for quite some time (over 3000 iterations until it is smaller than 1/500).

    • Oops, the asterisk I used for the multiplication was used for the markup. Are the markup symbols for this comments documented somewhere?

    • Formatting is – same as in the forum and wiki.

      You’re right about the moving average used for measuring differences against, but I’m averaging some 5000 x per second, so after a few seconds the initial value should have no weight. It’s never reset, just a startup value.

Comments are closed.