Searching \ for '[PIC]: PIC <-> 240VAC' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'PIC <-> 240VAC'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: PIC <-> 240VAC'
2003\10\26@110836 by Mohit Mahajan

flavicon
face
Hi,

Refering to Microchip's AN521, it shows a PIC connected to AC supply
line (of "several hundred volts") using just a 5 megaohm resistor in
series in between. Safety issues apart, it looks too simple to be true.
Is this enough to detect a zero-crossing (eg. for a PIC based triac
dimmer)or   should I put two clamping diodes on the pin detecting the
zero-crossing? I'm using a PIC16F870. I've read the manual and I believe
it doesn't have protection diodes in its i/o pins.

                             --->|---o Vdd
                 R           |
240VAC o-------/\/\/\---o----o---------o PIC i/p
                5 M     |    |
                        |    ---|<---o Vss
                        \
                    R   /
                   100K \
                        |
                        o
                       Gnd

Btw, the PIC in my dimmer is powered from a transfomer on the same AC
line (and bridge rectifier) so both the commons are going to be same.

Off topic, sitting here in India I can only guess what is "HOT OUT" and
"HOT IN"... its LINE and NEUTRAL, right? Pity we don't have such
interestingly graphic lingo down here.

Mohit.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\10\26@113116 by Olin Lathrop

face picon face
Mohit Mahajan wrote:
> Refering to Microchip's AN521, it shows a PIC connected to AC supply
> line (of "several hundred volts") using just a 5 megaohm resistor in
> series in between. Safety issues apart, it looks too simple to be true.
> Is this enough to detect a zero-crossing (eg. for a PIC based triac
> dimmer)or   should I put two clamping diodes on the pin detecting the
> zero-crossing? I'm using a PIC16F870. I've read the manual and I believe
> it doesn't have protection diodes in its i/o pins.
>
>                               --->|---o Vdd
>                   R           |
>  240VAC o-------/\/\/\---o----o---------o PIC i/p
>                  5 M     |    |
>                          |    ---|<---o Vss
>                          \
>                      R   /
>                     100K \
>                          |
>                          o
>                         Gnd

Actually PICs do have protection diodes on most pins.  The exceptions are
MCLR because is needs to tolerate 13V during high voltage programming, and
RA4 when it is open drain.  Aside from those pins, you don't need external
diodes in the circuit above.

However, while the protection diodes are there and they work, I would try
not to rely on them unless this is a very high volume product where every
penny matters.  I've also seen strange A/D readings on one channel when
another had a little current going thru its protection diode.  I don't
know how universally the issue applies.

Barring very high volume design, I would do what you showed above, but
then add a 10Kohm resistor in series with the PIC pin.  Diode forward
voltages can vary, and if your clamping diodes clip at a little higher
voltage than those in the PIC, you can still get some current thru the PIC
diodes.  With the 10Kohm resistor in series, the difference in diode
voltage will be divided by 10Kohms to make the PIC diode clamp current.
That will be so small you can ignore it.

After that, there are many other refinements.  Whether they make sense
depends on price, risk of failure, noise immunity, etc.  For example, some
hysteresis will be useful in some applications.  Other applications might
benefit from filtering high frequency noise.  You might also consider
splitting the 5Mohm resistor into two separate resistors to increase
creapage distance and immunity to dirt and humidity.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\10\26@151034 by

picon face
Mohit Mahajan wrote :

> Hi,
>
> Refering to Microchip's AN521, it shows a PIC connected to AC supply
> line (of "several hundred volts") using just a 5 megaohm resistor in
> series in between. Safety issues apart, it looks too simple to be true.
> Is this enough to detect a zero-crossing (eg. for a PIC based triac
> dimmer)or   should I put two clamping diodes on the pin detecting the
> zero-crossing? I'm using a PIC16F870. I've read the manual and I believe
> it doesn't have protection diodes in its i/o pins.

Hi,
If your desisgn can stand a few extra $ (or cent or whatever)
you could take a look at some of the "AC-opto-couplers". They
was designed for this specific use. You will get true isolation
between the mains and the PIC.

One of them are the the SFH628 from Vishay.

Product documentation page :
http://www.vishay.com/optocouplers/list/product-83722/

There you can scroll to the bottom and press the
"combine checked documents into one PDF", or just
select the basic data sheet.

(B.t.w, that "combine" function is realy nice, I havn't seen
it on other producers product pages...)

Jan-Erik.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\10\26@160718 by Steve Smith

flavicon
face
I do a 12K per year job with a 12c508 and the internal diodes work fine.
I use 2 x 4m7 in series and a small cap (470p) on the pin. You have to
watch the voltage rating of the resistors they are at best 200v and the
peak voltage is 1.707 x 240 (350 ish) particularly on 0805 smd parts.

Regards Steve...

{Original Message removed}

2003\10\26@193724 by Russell McMahon

face
flavicon
face
> Refering to Microchip's AN521, it shows a PIC connected to AC supply
> line (of "several hundred volts") using just a 5 megaohm resistor in
> series in between. Safety issues apart, it looks too simple to be true.
> Is this enough to detect a zero-crossing (eg. for a PIC based triac
> dimmer)or   should I put two clamping diodes on the pin detecting the
> zero-crossing? I'm using a PIC16F870. I've read the manual and I believe
> it doesn't have protection diodes in its i/o pins.

Peak current is about 65 uA for a 230 VAC supply, 30 UA for a 110 VAC
supply.

Yes - it will detect zero crossing "OK"

BUT !!!!!!!!!!!!!!!

I think I'll make this a standard answer to trot out each time this question
occurs ... :-)

______________________

Standard answer number one - Why you should NEVER allow PIC pins to be
driven outside voltage rails * during normal operation if you want normal
operation to be guaranteed.


This is not a system you should use without extra protection, if you want
the PIC to operate
correctly at all times. If you don't care if the PIC malfunctions then by
all means use it - it's very cheap, simple and effective and often may work.
More or less.

There are good solid engineering reasons why this system MAY cause problems.
It doesn't matter how many people tell you that it worked OK for them - it
is a non guaranteed mode of operation. It may work differently under
different circumstances and if it ever does you have no grounds for
complaint.

The problem is that this scheme operates the PIC in a condition in which the
data sheets do not guarantee its correct operation. It can cause trouble and
in some cases it does - on other occasions users detect no problems.

The PIC has (as have all other processors) two data sheet sections relating
to allowable voltages on pins. One section relates to worst case voltages
etc that are guaranteed to not actually destroy the PIC. These parameters
include allowable voltages that make currents flow in the protection diodes.

The second section applies to allowable voltages etc under which proper
OPERATION is guaranteed. You will find that a maximum voltage of perhaps 0.2
volts outside supply rails is allowed on pins in this section (except eg RA4
on eg 16F84x and similar which are high voltage pins with no upper
protection diode.)

IF you operate the PIC so that the protection diodes pass current while it
is running it MAY still work OK. BUT the currents flow in the silicon along
paths that are utterly different than those which are normal. Any part of
the IC may have transistors turned off or on and anything can happen
(include latch up, turn off, pretty coloured smoke and more).

The worst and most probable ill effect is that the processor will act
strangely and in an ill defined manner. I have had this happen using
resistor values suggested by the providers of a PIC compiler for
implementing an "RS232" port.

YMMV and if it works for you and you are happy with it that's nice.
It would be most inadvisable for any application in which you wanted the PIC
to run correctly with any certainty. (Not, I hasten to add, that certainty
is a part of engineering in any manner :-) ).

"Proper" protection consists of constraining the pin voltages so they stay
in spec.
There are simple and cheap schemes that "almost" do this and that offer
several orders of magnitude improvement over a single resistor. They still
are not "proper" but the statistical probability of failure is far far far
lower. One such is TWO series resistors into the pin with silicon diodes to
either rail from the midpoint. There are proper schemes that use a few more
parts and may be worth the effort.

Change the silicon diodes above to Schottky diodes and you have a "fully
proper" scheme with proper resistor choice. Even Schottky diodes from the
pin to either rail allows the spec to almost be met. Truth be known the 0.2
volt limit is conservative to keep you WELL away from the protection diode
knee but specs are specs :-) . If you use a scheme that shunts input
currents to rails, do have a clamp on the supply rails (as Peter suggested)
so that they don't get "pumped up" by the RS232 voltages. OR design so the
power supply load is ALWAYS greater than pump up currents.

Anyone wishing to rebut the general gist of the above (as opposed to any
deficient fine points)(of which there will be several :-) ) should first
read carefully so that they don't look too silly :-)

E&OE of course ;-)
(Hmmm. Does that cover my back enough .... ?)



       Russell "been there, bitten by that" McMahon



* Actual spec sheet value is typically about 0.2v outside rails - value may
vary with spec sheet and device. The main aim is to ensure that, for
practical purposes, the protection diodes NEVER conduct during normal
operation.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\10\26@235006 by gtyler

flavicon
face
Do it at your peril! I have been burt by this one badly. Remember that even
if you use a zener on the input at some stage at start up the pin will be
outside the supply voltage range. It is better to not drive the pin directly
at all, i.e. have a buffer of some kind. Obviously not another ic that can
be affected by voltages outside the supply range, use a transistor cct or
better, an opto.

George

{Original Message removed}

2003\10\27@084816 by Mohit Mahajan

flavicon
face
How's this for zero detection ...

                                o Vdd
                                |
                                / 4k7
                                \
                                /
                                |-----o Zero Detection
                               /n
  220VAC                     |/
  o--------/\/\/\-------o----|p   BC547
            330K        |    |\
                        |     _\/n
                        |       |
                        |--|<---o
                         1N4001 |
                                o Gnd

Regards,
Mohit.

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body

2003\10\27@090029 by Russell McMahon

face
flavicon
face
> How's this for zero detection ...
>
>                                  o Vdd
>                                  |
>                                  / 4k7
>                                  \
>                                  /
>                                  |-----o Zero Detection
>                                 /n
>    220VAC                     |/
>    o--------/\/\/\-------o----|p   BC547
>              330K        |    |\
>                          |     _\/n
>                          |       |
>                          |--|<---o
>                           1N4001 |
>                                  o Gnd


Good.

The 330k should be rated for greater than main peak voltage. Most single
resistors aren't rated for 230 VAC mains use, regardless of power
dissipated, and using two in series would often be wise.

The 4k7 could be higher if desired - draws less current.



       RM

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body

2003\10\27@111825 by Olin Lathrop

face picon face
Mohit Mahajan wrote:
> How's this for zero detection ...
>
>                                  o Vdd
>                                  |
>                                  / 4k7
>                                  \
>                                  /
>                                  |-----o Zero Detection
>                                 /n
>    220VAC                     |/
>    o--------/\/\/\-------o----|p   BC547
>              330K        |    |\
>                          |     _\/n
>                          |       |
>                          |--|<---o
>                           1N4001 |
>                                  o Gnd

That should work without violating any PIC specs.  A few suggestions
though:

1  -  I would use a 1N4148 diode instead.  It has a quicker reverse
recovery time, is dirt cheap, and can certainly do the job.  You don't
need a 1A diode there.

2  -  I would break up the 330Kohm resistor into two separate resistors.
Compare the max voltage spec of the resistor to the max line voltage.  You
will probably find the voltage is too high.  Even if not, two resistors in
series will be much more tolerant of dirt and humidity.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamKILLspammitvma.mit.edu with SET PICList DIGEST in the body

2003\10\27@114819 by Eric Christensen

picon face
On Mon, 27 Oct 2003 11:16:20 -0500
Olin Lathrop <.....olin_piclistKILLspamspam.....EMBEDINC.COM> wrote:


>
> 2  -  I would break up the 330Kohm resistor into two separate
> resistors. Compare the max voltage spec of the resistor to the max
> line voltage.  You will probably find the voltage is too high.  Even
> if not, two resistors in series will be much more tolerant of dirt and
> humidity.
>
>


This is heading off topic from the original thread, but...  How does
dirt and humidity affect resistors?  I'm not challenging you, I've heard
things like this before and would like to know more about it.  Does the
humidty just cause the resistor to break down over time?  How does dirt
come in to play?

Thanks,
Eric

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email EraseMElistservspam_OUTspamTakeThisOuTmitvma.mit.edu with SET PICList DIGEST in the body

2003\10\27@142716 by Rick C.

flavicon
face
Dirt and moisture will not directly affect conventional resistors. It is the
accumulation of dirt and moisture on the surface of the resistors and on the
circuit board that you have to worry about. I have seen dust and carbon
create "bridges" from the high voltage traces to ground or other traces that
have destroyed circuits. This is more so to happen with high voltage DC but
it does happen to AC too. Especially in automotive applications where dirt,
dust and moisture are present in high amounts. The idea in designing such is
to provide either insulation from air using a conformal coating, or break up
the circuit board in such a way that the bridges have a longer path to
travel.
Rick

Eric Christensen wrote:

{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email listservspamspam_OUTmitvma.mit.edu with SET PICList DIGEST in the body

2003\10\27@143129 by Olin Lathrop

face picon face
Eric Christensen wrote:
> This is heading off topic from the original thread, but...  How does
> dirt and humidity affect resistors?  I'm not challenging you, I've heard
> things like this before and would like to know more about it.  Does the
> humidty just cause the resistor to break down over time?  How does dirt
> come in to play?

Dirt and humidity don't effect the resistors as much as the stuff around
them.  Dirt is a source of ions and humidity (water) gives them mobility.
In other words, humid dirt can provide an alternate path for current.  The
resistance of this leakage is usually high enough so that you can
generally ignore it for nets with impedences from 1Mohm and below.

However in this case the leakage current isn't the issue as much as the
insulation strength.  The dirt can effectively reduce the spacing between
the nets at the two ends of a resistor, which can lead to arcing in the
worst case.  Because of these issues, resistors have a maximum voltage
spec that is independent of power dissipation.  I don't remember off the
top of my head, but I think 310V (peak voltage of 220V AC line) is either
near or above the spec for an ordinary 1/4 watt thru hole resistor.
That's why using two of them in series with proper placement is a good
idea at these voltages.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email @spam@listservKILLspamspammitvma.mit.edu with SET PICList DIGEST in the body

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...