Maker Pro
Maker Pro

simplest way to detect 120VAC using a microcontroller

S

SMS

Good luck getting that through UL.

Where did the o.p. state that he wanted to bring the design through UL?
I've brought a bunch of products through UL (and CSA and TUV) and have
the gray hair to prove it.

The o.p. is trying to monitor three different 120V signals. I don't
think he wants to use the Tektronix method, however clever.
 
J

Jamie

SMS said:
Use a quad AC Input opto-coupler, i.e. Vishay ILQ620 or NEC PS2505-4 or
equivalent. Look at page 5 of the app note at:
<http://i2c2p.twibright.com/datasheet/6n139_an.pdf>. You'll just need a
pull-up resistor on the collector of each output. Probably don't need
the inverter shown there since you can program the microcontroller for
high or low detection.

Be sure to look at the difference between a DC input and AC input
opto-coupler. You can use a DC input part for AC but you'll need an
external diode.

<http://www.jameco.com/webapp/wcs/st...ay?langId=-1&productId=320725&catalogId=10001>


<http://www.newark.com/jsp/search/productdetail.jsp?SKU=58K1694&CMP=AFC-GB100000001>


Note to our favorite troll: I have no association with Jameco or Newark.
It's about time some one came up with the correct answer!

Yes, the AC opto-coupler are the answer.

Jamie
 
R

Rich Grise

Jamie said:
I would like to detect if 3 different 120VAC signals are active using a
microcontroller, is it safe to just use a 1kV ceramic capacitor from the
120VAC signals and feed them into the microcontroller's ADC?

Probably not - the cap will send any line transients right directly into
your µP - PHUT!.

Stick any ol' diode (one that's good for at least 200V, 1N400x series is
cool) in antiparallel with the LED of an optoisolator, and 120K in series
with that parallel circuit, to the 120V.

Then, just read the output of the opto, and you're done. I know you can
get dual optoisolators, but I don't know if they come more than 2 to a
package.

Have Fun!
Rich
 
S

SMS

An optocoupler is only part of the answer, of course; you require
wired connections to all the AC signals, and current limiting
resistance for the optocoupler inputs, and pullup resistors
on the outputs. If the output has to remain stable, you'll
need a retriggerable monostable to stretch the AC pulses into
a static logic level.

An LED optocoupler requires typically 4 mA to reliably turn on,
and (from 120VAC) that means a maximum resistance of 36 kOhms,
so you'll dissipate about half a watt. Capacitive or inductive
probes are easier to make power-efficient.

A small signal transformer might be the same price as an optoisolator.

Unlikely, since he'll need three of them.

Yes, he'll need a resistor on the input, but on the output a capacitor
is sufficient to have a static logic level, no need for a retriggerable
monostable. Even the capacitor isn't really needed, as you could sample
the input on the micro-controller multiple times to be sure you detect
if there's a logic high at any time.
 
S

Spehro Pefhany

Where did the o.p. state that he wanted to bring the design through UL?
I've brought a bunch of products through UL (and CSA and TUV) and have
the gray hair to prove it.

The o.p. is trying to monitor three different 120V signals. I don't
think he wants to use the Tektronix method, however clever.

Threads wander. I thought it was an interesting aside, even if it
didn't precisely fit what the OP asked for.

If _both_ pieces of wire are UL/CSA approved for the full mains
voltage then I think they could avoid much further examination for
safety. But you couldn't have the mains wire snaking around near a PCB
or whatever without some care.


Best regards,
Spehro Pefhany
 
J

Jamie

Use a quad AC Input opto-coupler, i.e. Vishay ILQ620 or NEC PS2505-4 or
equivalent. Look at page 5 of the app note at:
<http://i2c2p.twibright.com/datasheet/6n139_an.pdf>. You'll just need a
pull-up resistor on the collector of each output. Probably don't need
the inverter shown there since you can program the microcontroller for
high or low detection.

Be sure to look at the difference between a DC input and AC input
opto-coupler. You can use a DC input part for AC but you'll need an
external diode.

<http://www.jameco.com/webapp/wcs/st...ay?langId=-1&productId=320725&catalogId=10001>


<http://www.newark.com/jsp/search/productdetail.jsp?SKU=58K1694&CMP=AFC-GB100000001>


Note to our favorite troll: I have no association with Jameco or Newark.

Hi,

Thanks for the links, the AC input optocoupler method is probably the
way to go since the AC lines are already connected to the PCB. The
series capacitor method is more cool and uses less power (no power
wasted in the LED series resistors) but has the drawback of requiring an
ADC and/or comparator, and also is probably not as immune to voltage
spikes as an optocoupler. I will try to use the optocouplers at 1mA
input current to save power and hope that works :D

cheers,
Jamie
 
S

SMS

Threads wander. I thought it was an interesting aside, even if it
didn't precisely fit what the OP asked for.

If _both_ pieces of wire are UL/CSA approved for the full mains
voltage then I think they could avoid much further examination for
safety. But you couldn't have the mains wire snaking around near a PCB
or whatever without some care.

Yet it's done all the time on boards that have the power supply and
logic together on one board, and these systems get UL approved, with the
appropriate warning labels and the infamous "finger test,"
<http://www.ergonomicsusa.com/accJFP10.html>.

UL wants to look at all boards, even those without high voltage on them.
I used to work for a large Taiwanese motherboard company. There were
several UL issues on motherboards even though there was no high voltage.
You needed picofuses near the KB and Mouse connectors because they were
worried about shorts in the KB and Mouse cables with 20+ amps of +5V
available from the power supply. You needed two levels of protection to
prevent the board from trying to charge the non-rechargeable lithium
backup battery. You needed UL approved material for the board. You
needed a UL approved back-up battery.
 
J

John Devereux

Jamie said:
Hi,

Thanks for the links, the AC input optocoupler method is probably the
way to go since the AC lines are already connected to the PCB. The
series capacitor method is more cool and uses less power (no power
wasted in the LED series resistors) but has the drawback of requiring
an ADC and/or comparator, and also is probably not as immune to
voltage spikes as an optocoupler. I will try to use the optocouplers
at 1mA input current to save power and hope that works :D

It may not matter for your application, but I have run into trouble by
making "AC inputs" *too* low current. The problem is that many sources
have a significant leakage current even when nominally "off". For
example any switch with a contact arc suppressor across it, like many
industrial PLC outputs. So the leakage current is enough to energise
your "low current" input.
 
S

Spehro Pefhany

Yet it's done all the time on boards that have the power supply and
logic together on one board, and these systems get UL approved, with the
appropriate warning labels and the infamous "finger test,"
<http://www.ergonomicsusa.com/accJFP10.html>.

I remember having to put UL-approved sleeving on some special (low
voltage) wires, even though there was no conceivable safety issue even
if they were to short directly to the mains.
UL wants to look at all boards, even those without high voltage on them.
I used to work for a large Taiwanese motherboard company. There were
several UL issues on motherboards even though there was no high voltage.
You needed picofuses near the KB and Mouse connectors because they were
worried about shorts in the KB and Mouse cables with 20+ amps of +5V
available from the power supply. You needed two levels of protection to
prevent the board from trying to charge the non-rechargeable lithium
backup battery. You needed UL approved material for the board. You
needed a UL approved back-up battery.

Yes, they will want to look at everything, particularly if you ask
their opinion on what they need to look at.


Best regards,
Spehro Pefhany
 
Yet it's done all the time on boards that have the power supply and
logic together on one board, and these systems get UL approved, with the
appropriate warning labels and the infamous "finger test,"
<http://www.ergonomicsusa.com/accJFP10.html>.

UL wants to look at all boards, even those without high voltage on them.
I used to work for a large Taiwanese motherboard company. There were
several UL issues on motherboards even though there was no high voltage.
You needed picofuses near the KB and Mouse connectors because they were
worried about shorts in the KB and Mouse cables with 20+ amps of +5V
available from the power supply.

Sure, but that's all common sense. I've done a few UL approved products in
the last couple of years. The process involved a fair amount of paperwork but
there were no modifications needed to the hardware for UL (CE caused some
issues unrelated to safety).
You needed two levels of protection to
prevent the board from trying to charge the non-rechargeable lithium
backup battery. You needed UL approved material for the board. You
needed a UL approved back-up battery.

All components also need to be traceable back to the manufacturer's UL
approval at any production inspection (quarterly).
 
The reason I really like the heatshrink method is that you don't have to
have the AC wiring on your board at all, which removes all sorts of worries.

I agree. It is slick, though could be a manufacturing nightmare.
 
I used some Avago units last year, 10MBPS IIRC, spec'd for 1mA.

Wish I had those three years ago. I used some that were spec'd for 10mA. The
curves fell off the chart at 1mA but that's where I used 'em anyway. I
couldn't stand the impedance loss otherwise. Today I'd likely use one of the
ADI thingies.
 
S

SMS

Sure, but that's all common sense. I've done a few UL approved products in
the last couple of years. The process involved a fair amount of paperwork but
there were no modifications needed to the hardware for UL (CE caused some
issues unrelated to safety).

You're lucky. If there's high voltage AC on the board or inside the box,
they have all sorts of requirements, down to the type of nuts to use for
grounding to the chassis. I recall at one point they were being stubborn
about some new rule they had and I told them that we would just stick
with CSA and not do UL because our customers would accept either
certification. They backed down.
 
You're lucky. If there's high voltage AC on the board or inside the box,
they have all sorts of requirements, down to the type of nuts to use for
grounding to the chassis. I recall at one point they were being stubborn
about some new rule they had and I told them that we would just stick
with CSA and not do UL because our customers would accept either
certification. They backed down.

There is AC in the box but it was engineered properly the first time. ;-)

There was an issue about which nut to put the ground connection under, but no
big deal. The only other issue was labeling.
 
S

sms88

Have you ever seen a keyboard cable catch fire? I have, on a IBM
built XT computer that I had just sold to someone. No damage to the
computer, but the keyboard was destroyed. If the cord had been on a
flammable surface, it would have started a fire.

I haven't seen it happen, but the threat was real enough to require
those fuses. Those power supplies are capable of a lot of current,
though I'd think that the board trace would fry before the cable would
catch fire. What was kind of bad is that people often blew the fuses by
powering stuff of the +5V from keyboard and mouse connector since the
picofuses were only 1/2 amp. At least with USB, the port shuts down only
temporarily if there's an over-current condition.

What was surprising is that there were customers that didn't care about
UL/CSA/TUV and we built boards with a zero ohm resistor instead of the
fues for them. This could not have saved more than 4-5 cents (for two
fuses), but the margins on motherboards are so terrible that they were
watching the pennies. Ditto for the back-up batteries. The Tadiran UL
approved batteries were more expensive than the non-UL batteries so the
Tadiran batteries were used only on boards going to customers that cared.

We sold boards to a major computer store chain (now defunct) who had
every store become a UL certified factory, and UL inspectors went to
their stores to inspect their "factory." Once some boards got shipped to
them from Taiwan with non-UL batteries and the UL inspectors caught it.
I had to explain to the factory why they had to use the more costly
batteries because they couldn't fathom it.
 
S

Spehro Pefhany

We sold boards to a major computer store chain (now defunct) who had
every store become a UL certified factory, and UL inspectors went to
their stores to inspect their "factory." Once some boards got shipped to
them from Taiwan with non-UL batteries and the UL inspectors caught it.
I had to explain to the factory why they had to use the more costly
batteries because they couldn't fathom it.

Ah, these days you just explain that they must be "UL marked" and the
factory takes care of the rest.


Best regards,
Spehro Pefhany
 
J

Jamie

Rich said:
Probably not - the cap will send any line transients right directly into
your µP - PHUT!.

Stick any ol' diode (one that's good for at least 200V, 1N400x series is
cool) in antiparallel with the LED of an optoisolator, and 120K in series
with that parallel circuit, to the 120V.

Then, just read the output of the opto, and you're done. I know you can
get dual optoisolators, but I don't know if they come more than 2 to a
package.

Have Fun!
Rich
Actually, what works very well and I do this at work to protect
inputs is to use TVS diodes, the bipolar types in the 1.5k class. Just
select
the value you need for it to clamp at and they work very nicely.

Jamie
 
Top