Newsgroups: sci.electronics
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: 1Hz signals
Message-ID: <1988Oct22.234502.19779@utzoo.uucp>
Organization: U of Toronto Zoology
References: <2006@lll-lcc.llnl.gov> <931@ccnysci.UUCP> <2080@iscuva.ISCS.COM>
Date: Sat, 22 Oct 88 23:45:02 GMT

In article <2080@iscuva.ISCS.COM> jimc@iscuva.ISCS.COM (Jim Cathey) writes:
>The power line is a noisy place, and grunge on it will screw up your timing
>if it's for anything critical.  Just clipping the raw line is not the best
>thing to do...

Very true.  The diodes-and-opamp circuit I posted will probably have this
problem.  I finally dug out the circuit I used a couple of years ago when
I had to deal with this issue.  It's a bit more complex.  It is meant to
work off the raw 110V AC, but shouldn't be too hard to modify for a low-
voltage transformer output.  I won't try to draw this one -- drawing with
ASCII is too much of a hassle.

We start with two input lines carrying the AC, and work from left to right.
First, 100k resistor from the top line down to a 1N4148 diode pointing
up, the bottom of which is on the lower line.  Then a 68k resistor in the
top line.  Then, down from the top line, a 100k resistor leading to the
collector of a 2N3904 transistor, with emitter on the lower line and base
connected to the top of the 1N4148.  Then, 0.1uF across the two lines.
(I assume everyone realizes that this should be rated for at least 200V.)
Finally, the top line runs down into the LED of a 4N27 optoisolator,
pointing down, then through a 1.5k resistor, then through a 2N5062 (small
SCR) pointing down, to the lower line.  The gate input of the 2N5062 is
connected to the 2N3904 collector.

On the other side of the 4N27, the base is unconnected (and you might want
to clip the lead off to minimize noise pickup).  The emitter is grounded.
The output is from the collector, with a 10k pullup to +5.  It's probably
wise to put a 0.1uF bypass capacitor between +5 and ground nearby.  The
output is TTL and CMOS compatible, is thoroughly isolated from the AC, and
produces one low-going pulse per downward zero-crossing of the AC line.
The pulse trailing edge is pretty sloppy, but the leading edge is fairly
sharp; however, "fairly sharp" probably isn't good enough for a normal
digital input, so best use a Schmitt to clean it up.

How does it work?  The series 68k resistor makes the voltage on the 0.1uF
lag behind the AC line, so it's still 30-40V as the top line falls past
zero.  (All voltages with respect to the lower line.)  The 2N3904, which
is on when the top line is positive, turns off.  The second 100k pulls
the SCR's gate electrode up, and the SCR fires, dumping the charge on the
capacitor through the optoisolator.  The 1.5k limits the current.  I'm
not sure of the exact purpose of the 1N4148, but it may be to protect the
transistor when the top line goes negative.  (Digital logic I understand,
and op amps I can usually puzzle out, but these #@#%$# transistors are
still a mystery to me at times.)

The advantage of this circuit is that it's essentially noiseproof.  For
one thing, noise isn't common precisely at the zero crossing.  More
important, this circuit is guaranteed to give only one pulse per cycle,
because once the SCR has fired, it can't do it again until the next cycle
has recharged the capacitor.

I used this as the AC-line sensor for a fancy digitally-controlled dimmer.
It worked fine.

Credits:  this appeared in the 27 May 1981 issue of Electronics, contributed
by Peter Lefferts of Versatec.
-- 
The meek can have the Earth;    |    Henry Spencer at U of Toronto Zoology
the rest of us have other plans.|uunet!attcan!utzoo!henry henry@zoo.toronto.edu
