Computing stuff tied to the physical world

Capturing some test data

In Software on Oct 2, 2011 at 00:01

(Whoops, looks like I messed up the correct scheduling of this post!)

Coming soon: a bit of filtering to get better AC current readouts.

There are many ways to do this, but I wanted to capture some test measurements from the AC shunt first, to follow up on the 220V scope test the other day. That way I don’t have to constantly get involved with AC mains, and I’ll have a repeatable dataset to test different algorithms on. Trouble is, I want to sample faster and more data than I can get out over wireless. And a direct connection to AC mains is out of the question, as before.

Time to put some JeePlugs from my large pile to use:


That’s a 128 Kbyte Memory Plug and a Blink Plug. The idea is to start sampling at high speed and store it in the EEPROM of the Memory Plug, then power off the whole thing, connect it to a BUB and press a button to dump the saved data over the serial USB link.

Here’s the sketch I have in mind:

Screen Shot 2011-10-02 at 01.31.52.png

Note that saving to I2C EEPROM takes time as well, so there will be gaps in the measurement cycle with this setup. Which is why I’m sampling in bursts of 512. If that doesn’t give me good enough readings, I’ll switch to an interrupt driven mechanism to do the sampling.

Hm… there’s a fatal flaw in there. I’ll fix that and report the results tomorrow.

  1. What about using some sort of stream compression algorithm to reduce the amount of data you need to send wirelessly?

  2. I’m wondering why you are not sending the samples over the air?

    Also I was looking back at some of your early direct shunt-measurement articles and realize you didn’t have a decoupling cap on your Vcc/2 potential divider – you need a big decoupler here to Jeenode ground to short out capacitive coupling from the mains voltage (or given that the circuit is at mains voltage, coupling from the grounded surroundings ;). 330uF will take the 11k impedance of the resistive divider down to 10ohms or so at mains frequencies, should reduce capacitive interference 3 orders of magnitude – worth trying I think ;)

    (220Vac has a dV/dt of 100kV/s which means a few pF of stray capacitance injects significant noise into a high-impedance circuit, whether or not it has a ground plane behind it. Make the circuit low impedance is the easiest course of action I think.

    • I’ve been using a 1 kΩ / 1 kΩ resistive divider lately, with a 100 µF electrolytic cap between the center tap and ground. Similar to what you suggest, I think.

      Re: sending samples over the air. It’s a bit too much data for the RFM12B, and there will be packet loss when the airwaves are hijacked 100% (many other devices – especially OOK transmitters – just send stuff when they feel like it). I’m now switching to a low-voltage AC hookup for testing. Once it all works, the final “it’s on” or “it’s off” signal will be sent wirelessly, of course.

      Thanks for the background info. I understand your point about low impedance circuits shorting out unwanted stuff. Hopefully this can be done in some low-power way later (a 1k/1k divider draws too much for a battery powered device, if that ever turns out to be feasible). If nothing else, I could put the divider on two output lines, and enable them only while measuring.

Comments are closed.