Computing stuff tied to the physical world

A simpler direct connection

In Hardware on Sep 21, 2011 at 00:01

Now that direct connection to AC mains is no longer out of the question (at least to establish a baseline), I decided to create a much simpler hookup:

DSC 2633

That’s a 0.1 Ω resistor in series with the load and two diodes, all in parallel. The diodes are not that useful for load protection (anything over 1000 W will be a problem), but they may help with transients and spikes:

DSC 2633  Version 2

Note that the sense wires are attached to the shunt resistor. If anything were to get yanked loose by accident, then it would be those wires, not the shunt itself. As usual, this is all hooked up via an isolation transformer.

A quick check tells me that this setup does not perform any better than the previous direct connection with the sketch I’ve been using all along.

Even without anything plugged in, I can affect the readings by moving my hands close to the circuit:

    reading:RF12-868.5.17:oneLong:value = 28250
    reading:RF12-868.5.17:oneLong:value = 28247
    reading:RF12-868.5.17:oneLong:value = 28184
    reading:RF12-868.5.17:oneLong:value = 28637
    reading:RF12-868.5.17:oneLong:value = 33743
    reading:RF12-868.5.17:oneLong:value = 77924
    reading:RF12-868.5.17:oneLong:value = 92240
    reading:RF12-868.5.17:oneLong:value = 50233
    reading:RF12-868.5.17:oneLong:value = 30663
    reading:RF12-868.5.17:oneLong:value = 28476
    reading:RF12-868.5.17:oneLong:value = 28176
    reading:RF12-868.5.17:oneLong:value = 28145
    reading:RF12-868.5.17:oneLong:value = 29082
    reading:RF12-868.5.17:oneLong:value = 34851
    reading:RF12-868.5.17:oneLong:value = 43977
    reading:RF12-868.5.17:oneLong:value = 54547
    reading:RF12-868.5.17:oneLong:value = 62388
    reading:RF12-868.5.17:oneLong:value = 61987
    reading:RF12-868.5.17:oneLong:value = 61366
    reading:RF12-868.5.17:oneLong:value = 62199

So the next step will be to add filtering. Either analog or digital, we’ll see!

  1. Good series!

    Some fear keeps creeping up on me that the posts one day suddenly stop…

    be careful!

  2. What is the measurement interval? Keep in mind that you are measuring AC-current, not DC! If the sampling interval is not sync’d to the mains frequency, you will get values that are not related.

    • Yes, I also think this is one of the problems, but a rather small one, as the sampling interval is around one second (?) and this is ‘long enough’ to make the error small (around 100 half waves sampled).

  3. JC, from what you say (moving the hand near to the circuit changes measuring values), I am pretty sure that it would help tp AC-couple the controller GND to the line (any of the two sides of the shunt) with a capacitor. Did you try this?

    BR, Jörg.

  4. The sampling interval must be EXACT at increments of 20mS (50 Hz), if not this creates sampling errors and gives erroneous results. Best is to create a 50 Hz trigger pick-off from 220V to synchronize the sampling OR the rectify the AC signal and measure the DC equivalent. This needs a one time calibration at full scale.

    • I disagree. The way JC does the measuring (averaging), it is only important, that the whole sampling interval (1s?) is always the same length. If you want to be really exact, than it would not be enough to synchronize to zero crossings but also the interval between samples has to be exact (means interrupt driven) and not in the main loop.

      BR, Jörg.

      PS: but I also think that the analog circuit has to be done decently first before further measures on the digital side.

  5. ok, this means he integrates all values over 1 second period. Still the question remains: what is the sampling rate?

    • In the posting from Sep 15 you can see that the ‘count’ was ~6000, which would correspond to one sample every ~150us, if the assumption of 1s sampling interval is correct (I do not know what ‘report.poll(1000)’ means exactly). This would at least be a decent figure for AC sampling.

      BR, Jörg.

  6. Just saw this http://hackaweek.com/hacks/?p=380 and thought about your constant quest of being smart enough not to kill yourself while trying.

  7. Might I suggest at least twisted pair from the shunt to the ADC input? That will reduce the hum pickup in what is currently an open loop picking up any stray magnetic fields. Better would be screened twin, with the braid connected to your local ADC ground, to reduce capacitive coupling also.

    Of course, trim the sheath well back at the shunt end, an inch unshielded won’t make much difference. Good quality microphone cable is rated better than 250vac between sheath and cores.

  8. I think the problem might be the high common mode voltage and inadequate common mode rejection. It looks like the whole millivolt measurement circuit rides on the 220VAC line voltage. The CPU A/D is single-ended, where common mode voltages can cause large measurement errors, depending on the whether the power supply is decoupled from ground and the mains.

    • You’re on to something I think. There’s no direct path to ground though: the while setup is only connected to a battery-powered wireless JeeNode, transmitting its averages once a second.

      But I get the point – with some resistance and impedance between the point I’m measuring and the power source downstairs, it’s east 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. I’m going to try some things with shielding and grounding (while remaining super careful!).

  9. Just in case you have not seen it, ATMEL has application note AVR465, Power/Energy Meter. It talks about front end, noise etc. It is a design of single phase electricity meter up to 10 A using Atmega88 and transformerless PS. I realise it more that you require, but there may be something in it, you never know.

  10. The 0.1 Ohm resistor works as (is equivalent to) a really low-impedance voltage source so hand-waving is not likely to introduce interference into this side of the circuit. On the other side you probably have a high-impedance ADC input or an even higher-impedance op-amp and I would look there for the culprit.

Comments are closed.