Square wave at line frequency. How does it work?

I found the following circuit next to a switching power supply in an electrophysiology amplifier (AXOPATCH 200A, an instrument for a technique called "patch clamp").

References to power outlet:

• L: line
• N: neutral
• G: ground

SEAL is then connected to an AND gate input (pin 9 in a 74HC08), the other input (pin 10) of the gate comes from a selector in the front panel: "SEAL TEST (5 mV line frequency)".

I think the purpose of this circuit is to generate a square wave with line frequency (50 or 60 Hz), 5V and 50% duty cycle, but I'm not completely sure. Can any of you analyze the way this circuit works? What should be the ratings on the zener diodes?

Edit: I desoldered D1 and D2 to see the markings and found that it reads 1N914 which is an older version of the general purpose diode 1N4148. I mistakenly thought it was a zener for its transparent appearance. Resistors are just one (not two or three in series), they are 1% precision, 1/4 W as you can see on the following picture (with one of the desoldered diode).

If we assume that N (neutral) is grounded at the incoming electrical connection point somewhere (where exactly varies from country to country) then N is at the same potential as G and we can ignore R2 and N for now.

• L will alternate positive and negative with respect to ground on each mains cycle. On the positive half-cycle the voltage at SEAL will rise until it reaches a little over 5 V. At that point D1 will be forward biased to the +5 V rail and prevent the SEAL voltage rising any further.

• On negative half-cycles D2 will be forward biased almost immediately L drops below zero. This, because it's a Schottky diode (see below), will limit the SEAL voltage to -0.3 V on negative half cycles.

• R2 and N will work in exactly the same way in the event that the L and N connections are reversed as would easily happen with reversible mains connectors used in North America and most of Europe.

Be careful with this type of circuit.

• The G connection would have to be grounded for it to work properly.
• Most small resistors are not rated for mains voltage. The 3 MΩ resistor should be made of two or three resistors in series.
• You'll have mains on the circuit board. Good layout with adequate isolation is required.

I think the purpose of this circuit is to generate a square wave with line frequency (50 or 60 Hz), 5V and 50% duty cycle ...

Correct.

What should be the ratings on the zener diodes?

simulate this circuit – Schematic created using CircuitLab

I think they should be Schottky diodes rather than Zeners although Zeners would work, provided they had a breakover voltage > 5 V.

• Schottky diodes are not a good fit here due to their leakage and the high impedance they are working against. The 1N914 the OP found is a ordinary silicon diode, which makes sense in this application. May 26, 2016 at 17:48
• I can't find a connection between G and the reference ground of the +5V circuit and obviously, measuring SEAL with respect to that GND doesn't give the 0 to 5V rectangular signal. There must be something I'm not seeing on the board, but it's so simple I doubt what is going on, I can't find anything. May 27, 2016 at 15:32

It should be noted that D1 and D2 are probably schottky diodes with a forward volt drop of maybe 0.4 volts

R1 and R2 form a potential divider halving the mains input voltage. D1 then prevents that voltage rising above 5.4 volts and D2 prevents it falling below -0.4 volts.

You therefore have a square wave of amplitude 5.8 volts peak to peak capable of supplying low current (due to the size of the 3 Mohm resistors).

It's a dangerous circuit nonetheless and care should be exercised when probing onto it.

D1 and D2 clamp the incoming signal (the mains waveform) at ~0 and ~5V (depending on the voltage drop in whatever diode you are using).

It is not clear what the R2 and the [N] connection are for. They don't appear to serve any useful function.

This is a common function for phase-angle lamp dimmers (and motor speed controls, etc.) Where you need to know where is the zero-crossing of the mains power so that you can control the phase of the trigger.

Atmel (who make the microcontroller used in Arduino, et.al.) actually publishes an Application Note on this function: AVR182: Zero Cross Detector