Computing stuff tied to the physical world

GLCD scope on 220V

In Hardware, Software on Sep 27, 2011 at 00:01

I’m not willing to hook my Mac up to 220V through USB, whether through the DSO-2090 USB scope I have, or any other way – even if it’s tied to a galvanically isolated setup such as the recent current measuring setups. One mistake and it’d go up in smoke – I’d rather focus all my attention on keeping myself safe while fooling around with this AC mains stuff.

But there’s this little 100 KHz digital sampling scope sketch, based on the Graphics Board. Looks like it could be a great setup for this context, since it can run detached off a single AA battery.

It took some hacking on the original sketch to get a system which more or less syncs to the power-line frequency (well, just the internal clock, but that turns out to be good enough). Here’s what it shows with the input floating:


Definitely usable. The three different super-imposed waves are most likely an artifact of the scanning, which takes place every 60 ms. One huge improvement for this type of repetitive readout is “digital phosphor”, like the professional DSO’s do: leaving multiple traces on the screen to intensify the readout. Single traces on a GLCD like this one end up with very little contrast, due to the lag of liquid crystals. What I do now, is leave pixels on for 10 scans before clearing the display. It’s not quite digital phosphor (where each scan fades independently), but it’s pretty effective as you can see. And this setup is a tad cheaper than that Agilent 3000X MSO I dream of…

Here’s a readout with this setup tied to the 0.1 Ω shunt in the AC mains line, with the power off:


That’s three pixels of noise, roughly, i.e. some 10 mV.

With a 60 W light bulb turned on, we get this:


Not bad at all! It looks like with a bit of smoothing and averaging, one could turn this into an ON / OFF signal.

Alas, the sensivity does leave to be desired. With a 25 W light bulb:


That’s barely above the noise threshold. It might be difficult to obtain a reliable detection from this, let alone at lower power levels. The 1W power brick showed almost no signal, for example.

Note that with North-America’s 110V, the readout would be twice as sensitive, since it’s measuring current.

Still, these results look promising. Here is the <cough> DSO with digital phosphor </cough> sketch I used:

Screen Shot 2011-09-26 at 15.52.38.png

This code can be found as “glcdScope50″ example in GLCDlib on GitHub.

Fun stuff. Just look how simple it is to gain new insight: a few chips, a few lines of code – that’s all it takes!

  1. Maybe that’s the key – noise won’t be at 50Hz in general, but a current flowing will. Can you do some kind of frequency analysis – see if the current flowing at 50Hz is significantly above that at other frequencies?

  2. It just hit me… All the power you are saving with the battery fed Jeenodes and the sleep-state-tweaking is undone with one little test with an 100W bulb. :-)

    Regarding the frequency-analysis. If AM demodulation around 50Hz would be possible in a sketch you could even do some kind of fingerprinting of you devices.

  3. I wonder what you will see when you implement FFT.

  4. JC, I’ve been away from your site for a while, and I’m a little alarmed at the way your current sense experiments are going. There is a low-cost way to do mains current sense, and you were almost onto it with the Allegro ACS714 (or whichever device it was, that’s one of a family). The way to do current-sensing at rock-bottom cost is to use a three-pin Hall-effect sensor on one side of a PC board and etch a current loop for your mains current on the other side. With regular old FR-4 board you’ll get a few kV of isolation (FR-4 is rated at 20 kV/mm if memory serves).

    The application note at gives the basic idea. The A1321 device that it describes is at end of life, but the A1324 is a similar replacement: has the data sheet. It’s a lot cheaper than the ACS7xx series of devices, to say nothing of a current transformer!

    Since the PCB trace will be passing the full supply current to the mains-operated device, it’ll need to be a big wide one. Use something like to calculate how wide.

    • Thanks – great links. Let me make clear that I’m not doing the current 0.1 Ω shunt trials to actually use that circuit. Just trying to figure out how sensitive that would be.

      The loop-under-pcb is indeed a great idea. It still exposes high voltage, but indeed quite safely It might not be sufficiently sensitive, however. I’d prefer to get at least 10 W detection, i.e. under 50 mA currents. Not sure it’s possible, but then again my aim is not quantitative measurement, just an ON / OFF signal. I have some of those Allegro sensors you refer to, and was planning to experiment with those later on. The PCB idea is definitely good, I could raise the sensitivity with 0.8 mm material, though 50 mA seems way out of range. A meandering path with multiple sensors and some sort of signal processing? I’m getting the impression that magnetic detection at such low levels is not feasible.

  5. What kind of current range are we talking about here? 50 mA at the low end seems a trifle low. That’s in the range of what a lot of devices draw as standby current. What’s up at the high end, 10 A or so? I don’t think you’re going to get very good readings at 0.5% full scale.

    Wait! D’oh! Detection of 5 mA currents on the high side of line voltage is routine. Can you scavenge the differential transformer from a ground fault circuit interrupter (residual current detector, or whatever you Dutchmen call it) and use that? A lot of times, those things have 1000 secondary turns and output 1 mA/A. Drop that down a correctly sized resistor, buffer the result with an opamp, run the D/A off that. (Or configure the opamp as a transresistance amp and save a resistor.)

    • Ooh, brilliant, the aardlekschakelaar !

      It’ not really low-cost, but this could indeed do the trick!

      Re the low current detection level target – power consumption of many modern devices is going down. Computers, monitors, chargers, etc. It’s probably far too much to ask, but wouldn’t it be neat if one could detect whether a cell-phone charger is active?

      On the hight end, 1000 W would be enough, i.e. 5 Amps.

Comments are closed.