Clock & Timer Circuit Diagrams
Zero-Crossing Detector for Microcontrollers Schematic Circuit Diagram
In lighting controllers and clock circuits that need the mains frequency as a parameter for evaluations carried out within a microcontroller, you will often find a transistor stage to convert the mains voltage (reduced by the transformer) into a 50-Hz square wave signal that is suitable for input to the microcontroller.
Generally speaking, this stage is unnecessary with modern microcontrollers if the port input is wired as a Schmitt trigger. The only additional component that is needed is a resistor to limit the port current to a safe value, as specified by the data sheet. The Schmitt trigger ensures reliable edge detection by the software.