LED's or Optocouplers on 230v AC mains voltage...

Grogster

Senior Member
This is slightly off topic, but I want to be able to run an LED from the mains without any transformer.
There used to be a circuit in the Dick Smith catalog, but this is long gone.

Can someone enlighten me?

I want to be able to connect the mains to an optocoupler, and use it's output as a "Mains-failed" alert on a system.
The mains drives the LED in the opto - if the mains fails, the opto drops out and the PICAXE circuit picks up on this.
An opto with the right isolation figures should be happy enough with this idea, but how to drive the LED?

I currently do this with a industrial relay with 230v coil, but they get quite hot when energized all the time, which I am uneasy about.

I am dubious of the single resistor idea at mains potential...
 

SAborn

Senior Member
I dont ever recall a circuit for a mains powered led in the DS cataloge, although there was a opto-coupled triac driver circuit in the earlier DS data section, but this is not suitable to what you require.

Some time back i did come across theis circuit for a mains led.

Mains led.JPG

I have never used the circuit so can not comment on the reliability of it.
 

zoo12

New Member
Grogster
I have used this circurt for the past 4 years as a cursor for a variac transformer . it illuminates from 9volt to 260 volts AC with no trouble. normal safety precautions needed with 240 Volts.
mains led.JPG

Hope its of use, by the way adapted from some web site long gone
John
 

hippy

Technical Support
Staff member
As noted in SAborn's attached circuit; make sure you use the specified capacitor (X2) which fails open circuit.

I'd personally use a mains PSU that doesn't get hot when running and use its output through the opto or just a current limiting resistor. You may as well power the PICAXE from that supply too while mains is present.
 

Dippy

Moderator
The capacitor method is well used method for acting as your mains 'resistor'.
You can calculate the value required to provide the current limit. (Clue: there's a pi in it).
The relatively low value real resistor 'absorbs' surges (transients/inrushes).
The circuit style supplied by flyingnunrt would be my choice.
Note the spec of the capacitor as highlighted by hippy - it's crucial that people are aware.

A mod to the circuit can be made to give a supply for many low-power circuits.
Extra protection can be provided using a varistor type device and even a fuse.

And, as I'm aware that newbies may look at this, PLEASE remember there is no isolation at this stage so be careful.
 

Grogster

Senior Member
@ flyingnunrt - that was the circuit I was looking for!!! :) I remember seeing it in earlier catalogs, but back then I was just a little kid, so playing with mains was definitely out.
 

Grogster

Senior Member
And, as I'm aware that newbies may look at this, PLEASE remember there is no isolation at this stage so be careful.
Yes, indeed - this is not a circuit for beginners to play with, as it is potentially lethal to the inexperienced. I am actually a licensed Electrical Service Technician, which is a Government regulated practicing license here in NZ, and you can't get it without doing electrical safety and first-aid courses every two years to keep your training up to spec.

The circuit will consist of this DSE circuit driving the LED in a suitable opto-coupler, all inside a potting box and sealed up with potting compound to insulate it and make it safe.
 

Dippy

Moderator
Ah, that's good to hear. I'm sure some people would see a capacitor in the circuit and go and hack one out of grandpa's radiogramme and try that ;)
(shortly followed by 'bang' and a 999 call).

Don't forget your capacitor calcs as the value can depend on your mains voltage. I'd be tempted to operate the opto LED current well below max rating but generously above the min required (usually in Data Sheet).
In fact, I've just remembered, if you use an AC optocoupler/isolator (LEDs back to back in the chip) you can dump that 1N400x diode.
It's there to protect the Vr of the LED, so with an AC opto you don't need it.
 

Grogster

Senior Member
Oh God, I know. :(
I have seen some real horror stories.

One I still get shivers over the YouTube vid of the 12-year old "Welding"(well, really just making lots of sparks) with a home-made welder made from a Microwave Oven transformer - he was using the 3kV end - this 3kV can supply anything up to around half an amp or so - one wrong move, and that boy is dead.
 

rob235

New Member
There is a software package called Misc EL which can help you with the component values based on your situation.

http://www.miscel.dk/MiscEl/miscelLeds.html

As mentioned before, make sure you use the right capacitor, for example the Jaycar X2 series and of course please be careful.

I built one of these recently to replace a 12v power lamp in an appliance. The lamp was across 240v with a 10k 10w resistor!
 

hippy

Technical Support
Staff member
The capacitor method is well used method for acting as your mains 'resistor'.
You can calculate the value required to provide the current limit. (Clue: there's a pi in it).
And its reactance is also frequency dependant. Not sure how much that affects things but it would be worth considering / calculating the affect of varying frequency for applications which might not have a fixed AC frequency; wind turbines etc.

The circuit will consist of this DSE circuit driving the LED in a suitable opto-coupler, all inside a potting box and sealed up with potting compound to insulate it and make it safe.
I'm not sure that such an extreme is required. Providing it is safe from prying fingers, properly secured, insulated, accidental contact is prevented, with a mains / 'danger of death' warning label, that should probably suffice.
 

Dippy

Moderator
Yes,but, if there are other significant loads on the system then that particular teeny vector will be 'swamped'.
Do the maths or a graph.
 

Grogster

Senior Member
I'm not sure that such an extreme is required. Providing it is safe from prying fingers, properly secured, insulated, accidental contact is prevented, with a mains / 'danger of death' warning label, that should probably suffice.
Heh, heh - yeah, well, maybe. ;)
I'll still do it that way in any rate - I tend to be a LITTLE overcautious with respect to the mains. A good idea to pay it the respect it deserves. :D
 

bluejets

Senior Member
As an Electrical contractor I would advise the idea of a small transformer.

It is a much safer road in the first instance and secondly, the mains capacitor is going to cost you more than a small tranny anyhow.
 

flyingnunrt

Senior Member
The potting is probably not such a good idea.
With the heat generated by this type of circuit,
that heat may not dissipate out of the componets too well.
 

Grogster

Senior Member
As an Electrical contractor I would advise the idea of a small transformer.

It is a much safer road in the first instance and secondly, the mains capacitor is going to cost you more than a small tranny anyhow.
Can't agree with that.

470nF(0.47uF) 630v capacitor - $1.50 in our money, or about US$1.20 at current exchange rates.

Find me a small mains transformer for $1.50 or so, and I will use it. :)
(must be new - I don't use 2nd hand parts in any project or product - it's bad practice IMHO)

Perhaps you have a better source for high voltage caps then I do?
 

Grogster

Senior Member
The potting is probably not such a good idea.
With the heat generated by this type of circuit,
that heat may not dissipate out of the componets too well.
A good point.

I will build the circuit, and run it inside an air-tight plastic box for an hour or so, and then check the temperature of the caps etc(with juice off, naturally!).

The potting compound I was planning to use was proper heat-conducting type for electronic use, not just a resin from the hardware shop. The proper stuff should help conduct the heat away from the parts, if they do get hot.

But, I was unaware that this circuit gets warm or hot, so I will do some bench tests before any encapsulation of any kind.
 

bluejets

Senior Member
Grogster,
Up to you if you want to play with 240v, use a cheap mylar cap. and suffer the consequences.
You might get away with it this time but practises like this will get you in the end.

Just be aware that mains supply has very large fault currents that can ionize metal and create rather large explosions, not to mention severe burns, blindness and potentially fatal consequences.
 

Grogster

Senior Member
You don't need motor-start caps to do this kind of thing.
I think you might be confusing those expensive fully-encapsulated caps they use to kick-start electric motors.
You certainly would not want to use a cheap mylar cap for those, as they would self-destruct.

Not sure I can agree with your argument that this will also "Get me in the end" either. This method has been used for decades, by many many people. If the circuit was really such a death trap, they never would have printed it in the DSE catalog, and other members here would also have told me as much rather then saying they use it themselves.
 

Dippy

Moderator
I wouldn't pot it - spend the extra pennies on a good quality enclosure.
Where did this "cheap mylar cap" come into it?
Surely the solution has already been given wrt components?
X2 capacitor (or suitable high voltage cap) and a correctly rated resistor.
But PLEASE do the simple maths on component values, you could probably use a lower value cap.
Groggy, what value ohms , voltage and wattage res are you going to use?
Which opto-coupler (recommend AC style)? Checked the current rating?

A transformer will get warm and it is likely to be less energy-efficient than a capacitor based circuit.
A cheapo transformer will probably be less reliable than a proper X2 capacitor - and certainly larger.
(And, based on years on this Forum, PICAXErs will tend to use the cheapest CH Fleabay specials they can find).

Bluejets would go potty on a circuit design I did. For 240V mains to 12V I used electrolytics and bucked it down using a MOSFET based circuit. Not for newbies.

The capacitor method is used in most of the energy monitoring circuits I've seen.
If, of course, people here know more than Microchip, ST Microelectronics, Analog Devices etc. then please let us (and them) know :)
 

hippy

Technical Support
Staff member
It shouldn't get warm but, as noted, don't even think about touching it to check when powered up or even plugged in !

Take all the usual precautions, have someone else with you, use a mains isolating transformer, etc.

The caps aren't expensive but you may have to hunt around to find the value and ratings wanted. The essential requirement is X2 rating ...

http://www.rapidonline.com/Electronic-Components/X2-Metallised-polyester-film-capacitors-71097

This is one of those cases where I would seriously caution against buying cheap from eBay and similar.
 

Grogster

Senior Member
Groggy, what value ohms , voltage and wattage res are you going to use?
Which opto-coupler (recommend AC style)? Checked the current rating?
I was planning to just copy the circuit that was in the Dick Smith catalog, that was kindly posted here earlier on the thread.
In that one, they specify a 470n 630v cap, but I would be using a 470n X2 cap as already mentioned:

http://www.jaycar.co.nz/productView.asp?ID=RG5240&keywords=RG5240&form=KEYWORD

As for the resistor, standard carbon half-watt resistor as per the value in the circuit.

As for the opto, I have not yet researched it, but will post on what I plan to use for others to comment on before I use it.

I do have a packets of 4N25's, CNY17-3's and H11G2's, but I have not researched their datasheets for high-voltage isolation, but will - maybe one of these would be OK. Rest assured, I will not use any of them if they don't have the correct isolation.

Bluejets would go potty on a circuit design I did. For 240V mains to 12V I used electrolytics and bucked it down using a MOSFET based circuit. Not for newbies.
I don't think he will be impressed with that!!! :D
 

Buzby

Senior Member
The capacitor method is used in most of the energy monitoring circuits I've seen.
If, of course, people here know more than Microchip, ST Microelectronics, Analog Devices etc. then please let us (and them) know :)
The capacitor method is frequently used by the vintage radio restorers, to replace the 'mains dropper resistance' cable used on many AC/DC sets.

It is a perfectly normal and safe technique for powering circuits, especially those with low current requirements, but poor choice of components or bad construction methods can turn it into a killer.

This is no different to any other mains connected device.
Remember the 5v wall wart supplied with the cheap USB hub shown in this forum recently ?

It looks like Grogster knows enough to not make a silly mistake, but I would like to know why he needs any type of mains fail detection which is separate from the PSU for the PICAXE anyway.

Cheers,

Buzby
 

Grogster

Senior Member
It looks like Grogster knows enough to not make a silly mistake, but I would like to know why he needs any type of mains fail detection which is separate from the PSU for the PICAXE anyway.
Simple really.
I have an emergency system, based on the PICAXE, which is fed from a battery-backed regulated PSU.
The PSU powers the whole system, and charges a 7Ah Gel-Cel at the same time. If power fails, the battery takes over immediately.

Normally in the past, I have connected the aforementioned relay with the 230v coil in parallel with the mains so that it is energized at all times while the mains is on. The NO and COM connections on the relay connect back to the PICAXE circuit and one of it's inputs via the standard 1k/10k resistor arrangement between the 5v supply and input.

As the connections are NO and COM, with the relay energized, this becomes a closed circuit.

If the mains fails, the relay drops out, the circuit is opened and the PICAXE detects this and sends a message that: "Main power failure at base - now running on backup battery."

When the mains is restored, the relay pulls back in, restores the circuit to the PICAXE input, and the system sends another message: "Main power restored at base."

That's all there is to it. :)

It works just fine using the relay, but now I want to use the cap and resistor and opto method.

This is also why I wanted to pot the circuit - to keep it safe from any fingers touching it, and also for mains-voltage seperation from the main low-voltage PICAXE ciruit. The LED circuit would be totally separate from the mainboard, in other words, just to keep things safe(no mains lurking around on the mainboard).

I guess, when I think about it, I COULD just tap into the output from the PSU BEFORE the battery, and using a potential divider to bring the 13.8v output from it, down to a 5v reference voltage, as when the mains fails, the output from the regulator will drop off anyway, which would mean exactly the same thing...

Actually, re-reading post #5 is making me think: "Why don't I just do it that way?"...

Funny how sometimes you are so set in what you are trying to do, you don't see the obvious. :p

Comments still welcome, but I am starting to rethink the whole opto on mains concept in favour of a simple potential divider off the 13.8v suppy, to the PICAXE input at about 5v or so...
 

Buzby

Senior Member
Comments still welcome, but I am starting to rethink the whole opto on mains concept in favour of a simple potential divider off the 13.8v suppy, to the PICAXE input at about 5v or so...
That's the way I would do it !.

I've done it before by putting a diode between the output of the unregulated supply and the input of the regulator.
(This drops about 0.6v, but that's not a problem with mains powered stuff. )
Then put the top end of the resistor divider to the unregulated side of the diode.

When the mains fails the unregulated side drops quickly, and the diode prevents backfeed from the capacitor keeping the voltage up.
( If you can get to the output of the transformer before the bridge rectifier, you don't even need the diode. )

It's basically the circuit I used to get a timebase from the mains for a PICAXE clock.

Much easier than messing about with mains.

Cheers,

Buzby
 

hippy

Technical Support
Staff member
Comments still welcome, but I am starting to rethink the whole opto on mains concept in favour of a simple potential divider off the 13.8v suppy, to the PICAXE input at about 5v or so...
I also agree that's probably the easiest, safest and best way.

You can possibly even just use a current limiting resistor straight to the 13V8 line though a potential divider keeps the pin voltage below +V and holds at 0V if the 13V8 appears 'floating' rather than clamped to 0V when it fails so not much in it for the sake of one resistor.
 

Grogster

Senior Member
Yeah, I concur.

Attached is the planned circuit.
The 22k/10k is just how it happened to be - I did actually measure voltages, and with 13.8v, the voltage that will be on the PICAXE pin is about 4.5v, rising to 5v if the input goes up to about 16v, but it would never get that high.

The PSU is fully regulated, and the PICAXE-based mainboard is also fully regulated.
 

Attachments

Top