Sensing state of AC line voltage - how to?

Rbeech

New Member
I have a need to sense whether an AC circuit is on or not, with a logic level output.

I have tried a neon bulb coupled to a phototransistor, but that was only slightly succesful. The neon was not bright enough.

I thought about using an optocoupler like the and driving the LED side from the mains with appropriate capacitor to drop the voltage. I think that the 60Hz AC will be to slow for the response time of the optocoupler, and will result in a pulsed signal rather than a logic high.

Any ideas?
 

moxhamj

New Member
There are lots of circuits but optoisolation is a good thing. The signal would be pulsed with the led optocoupler circuit but you could fix that on the optocoupler transistor side with a low pass filter (resistor and capacitor).

But I think your neon idea is worth pursuing further. It doesn't matter about the brightness - the main thing is to put it into a totally lightproof box. Perhaps a film canister? Use an LDR and measure the resistance when on and off and couple it to a resistor of about that value so the output is about 2.5V.
 

BCJKiwi

Senior Member
Theres always the relay approach!

You can also wrap a few turns of mains wire around a reed switch to get an isolated contact. A limiting resistor might help to improve safety.

Most available packaged reed relays only have low voltage DC coils

The problem with caps on mains is they would likely rise to peak value of the AC voltage under various circumstances, blasting your low voltage circuit.
 

premelec

Senior Member
I've had good results using a neon [or LED for lower v] and Light Dependent Resistor as DrAc suggests... for best sensitivity use a 10K R from V+ to an ADC input and LDR to V- forming a voltage divider - then look for a READADC << 255 value.

There are LED 'night lights' in the USA now that draw close to no watts - perhaps .1 and are VERY bright - they would drive any LDR and take a bit more current than a neon. A common problem with neons is their eventual higher ignition voltage and flickering when they are in the dark - they actually will detect ionizing radiation or light when at this stage [they are built with a small radioactive source internally to keep ions available - the source decays...].
 

Michael V

Senior Member
Careful of the big wires

Optocoupling with neon lights sounds pretty cool, but still requires connection to the 240V (or 110) to mahke the light go. To reiterate a warning heard often with good reason - Don't muck around with mains voltage unless you really know what you are doing. - it can Kill.

Following on from kiwi's reed relay idea, In Siliconchip.com.au some time ago there was a power detecting circuit which switched a relay based on the magnetism created through current flowing through a wire. eg, if you turned your computer on, it could turn on your monitor, desk light, radio etc. I can't recall the detail, but i know that involved a a split ferrite core or RF supression core, and had a hall effect sensor in there. Uses on the same principle as a clamp meter that measures current, but was used to swich a relay.

In the wonderful world of picaxe you can connect the 2.5V output of a UGN3503U hall effect sensor, which runs off 4.5 - 6V and costs $5 AUD, directly to the analog input of a picaxe o8M. Actually the data sheet shows how to wire up a current monitor - but it could be for DC. I have connected this device to a picaxe, but to measure a narrow angle using a magnet rather than current.


In Aus we can them from www.jaycar.com.au part number ZD-1902, but i sure you could get them just about anywhere.

You might even get the original circuit from Silicon Chip, and work out how to picaxe it.
 
Last edited:

BeanieBots

Moderator
How about a simple 5v wall-wart or any other voltage with appropriate divider. Very cheap and more importantly very safe.
 

hippy

Technical Support
Staff member
I'm with BeanieBots and BrendanP on this one; use a plug-in wallwart/PSU. They are designed and tested for safety, offer isolation and deliver output voltages which through a suitable resistor delivers a logic output usable by a PICAXE. It doesn't even matter what voltage the PSU puts out or whether regulated or not providing the right resistor is used.

This has to be the safest, easiest, fastest and most likely cheapest solution.

Don't forget to fit a suitable fuse between the mains power and the socket the PSU plugs into.
 

Mycroft2152

Senior Member
The wall wart is a good idea, except you still need an outlet for it to plug into.

This is useles if you are checking current flow to a device plugged into the mains.

Let's say I ant to separately monitor the fuel pump and the blower on a furnace. the best sensor would be a clamp on current monitor for each wire.

A quick GOOGLE search came up with the following:

http://www.redcircuits.com/Page62.htm

http://www.electronicsforu.com/electronicsforu/lab/ad.asp?url=/EFYLinux/circuit/nov2003/CI-03-power.pdf&title=Non-Contact Power Monitor
 
Last edited:

hippy

Technical Support
Staff member
In the case of detecting current flow, assuming mains power is switched on or off to some part being controlled, I'd add a cable to an extension socket from there ( eg across the motor or compressor ) and plug the PSU into that.
 

tikeda

Member
Regarding the system described in Mycroft2152's first URL, I like the idea of using a minature inductor as the pickup coil. Some other circuits I've seen call for wrapping a few hundred turns of wire around a snap-on torroid or a u-clamp. Using a manufactured inductor would be a lot less messy. Honeywell (& others) also make current monitors based on Hall-effect sensors (e.g Honeywell #CSLA2CD). It's less of a 'roll your own' solution to the one described by Michael V.
 

Rbeech

New Member
There's some great ideas in here. It's going to take me a little while to digest them all, and try a few out...

Just to fill you all in on what I am trying to do here:

I want to build a stopwatch that is triggered by an AC circuit (110VAC) being turned on. When the circuit goes off, the count stops and holds the value. When the circuit goes on again, it resets the count, and starts again. The main circuit works, I just am up against getting it to trigger properly.

The circuit in question is the pump circuit in an espresso machine. Not only is there mains voltage, but there's hot water, and high pressures as well. :eek: I am comfortable with it. The machine already has modifications to the mains circuits for more stable temp control. Eventually, I aim to remake all the control circuits under one microprocessor circuit.

The reason to make this stopwatch mod, is that the length of time to pull the espresso shot is an indicator of quality, and indicates what changes must be made to make the next shot better. Right now I use a seperate kitchen timer, but this will make the whole process smoother.
 

Rbeech

New Member
But I think your neon idea is worth pursuing further. It doesn't matter about the brightness - the main thing is to put it into a totally lightproof box. Perhaps a film canister? Use an LDR and measure the resistance when on and off and couple it to a resistor of about that value so the output is about 2.5V.
I have the pair optically isolated inside heatshrink. I will try an LDR though...
 

craigcurtin

Senior Member
LDR and LED from Walwart

I am doing exactly this for sensing when a Off peak electric circuit is live.

I have a wall wart that is driving an LED inside a short length 100mm of Plastic conduit - then end is sealed with tape.

At the other end is an LDR (again sealed with tape) - the value at the input on the picaxe is close enough to 0 when off and more importantly a huge jump when on

Craig
 

Dippy

Moderator
He only wanted to see if AC mains is on or off Myc. Whilst i agree about current sensing we don't want to go Off-Thread too quick huh?

Either of the opto iso methods above looks fines as long as it is remembered that we are using AC. As mentioned above a 'rectifier' is needed to make sure about sensing.
Also, if using an LED opto isolator type arrangement with dropping C/Rs please remember that is a good idea to have a reverse diode/LED across the main LED, noting reverse voltage (LED Vr) and inrush of AC+C/Rs.

And, of course, if using C/Rs for dropping you, of course, be using suitably rated components won't you.

I agree, wall wart is safest. But, personally, I always think its a great lump and a waste of a wall socket... but it is the safest. Unless you get a cheap Beijing Banger that goes up in smoke (like some units marked 'CE' fraudulently that were being imported to UK a few years ago being sold as low-cost mobile phone chargers).
 
Last edited:

sedeap

Senior Member
NEON Vs Microlamp

I used to use one minilamp 220v from sewing machine or fridge to detect mains.
Once I buy one commercial wall switch module (I don't remember the brand) with light, and NOT be neon, is used in elevators to provide visual location and is 220v. Bright far more than neon. Looks like one FAT glass tubular Fuse.

IF I can find one photo... I post it
(Not sure but I bet for Sylvania brand)

Bye.
 

gengis

New Member
There's some great ideas in here. It's going to take me a little while to digest them all, and try a few out...

Just to fill you all in on what I am trying to do here:

I want to build a stopwatch that is triggered by an AC circuit (110VAC) being turned on. When the circuit goes off, the count stops and holds the value. When the circuit goes on again, it resets the count, and starts again. The main circuit works, I just am up against getting it to trigger properly.

The circuit in question is the pump circuit in an espresso machine. Not only is there mains voltage, but there's hot water, and high pressures as well. :eek: I am comfortable with it. The machine already has modifications to the mains circuits for more stable temp control. Eventually, I aim to remake all the control circuits under one microprocessor circuit.

The reason to make this stopwatch mod, is that the length of time to pull the espresso shot is an indicator of quality, and indicates what changes must be made to make the next shot better. Right now I use a seperate kitchen timer, but this will make the whole process smoother.
That sounds like a fun project.

The place I worked at had a need for several gizmos that would work an external circuit when current was flowing in a monitored circuit. Things like heaters coming on when they weren't supposed to, rotating beacons that needed to sense current in an X-ray machine etc..

We bought a number of 12V step down transformers with side by side windings (so called "flat pack" mains transformers for pcb mounting). We cut the primary winding off with a hack saw and use the secondary as the sense winding. You need to wrap a turn or two of the current carrying wire through the core where the primary had been.

The secondary winding puts out an AC voltage proportional to the current flow. It takes a little tinkering with a meter to judge how may turns to use, but the idea scales up or down well. I'd use my soldering iron (40 watts) on the workbench to determine how many turns it needed then calculate the turns the device to be monitored would need based on its current requirements.

Then it was just a matter of hanging a load to the secondary - usually a full wave rectifier and cap to convert it to DC then route that to a solid state relay to switch the second circuit. But that output could run an LED indicator and we even used cheap store-bought quartz clocks to show accumulated run times on some compressors pumps and heaters.

The output of the DC supply can be used to measure current accurately if one uses a "precision rectifier" op amp circuit to massage the signal. The only time one might run into a problem is if the monitor loop is running enough current to saturate the iron in the home made current transformer - then it still works for things like monitoring current flow, but the accuracy won't be good enough for current measuring. That only happened when we tried to use a ferrite high frequency transformer at 60 HZ . . .
 

Rbeech

New Member
All the talk of transformers and coils, etc got me thinking. The AC in this case is operating a solenoid valve. Therefore there is a coil there already. One of the little magnetic switches that is used in home security systems to sense the open or closed state of doors and windows was a quick hardware store source of a reed switch. It got zip tied to the side of the solenoid, and it worked first try!

Thanks so much for all your ideas. They put me on the right track. Now I have a fully functional circuit, and have just to tidy it up and get on to the next stages of micro control...
 
Top