Zero crossing schematic

LTSpice Model of AC mains zero crossing detector

posted in: Arduino | 0

As part of an Arduino based AC mains dimmer controller, I’ve been investigating and modelling various zero crossing detectors, and I created an LT Spice model of this circuit which I found here

Zero crossing schematic

Note. R6 has been added to please LTSpice, its not really present, but both sides of the optocouple need to be connected to a GND in order for the simulator to run. The value could be set to 100Meg as this is probably more realistic in the real world.

I’ve modified the design slightly for operation on 240V with 1/4W resistors. 4 x 100k were used to ensure that no high voltage breakdown would occur as general purpose resistors are not rated at mains voltages.

Red trace is the output from the opto coupler collector

Green trace is the AC input (via the 2 x 100k resistors)

zero crossing simulation

 

As you can see this gives a quite good clean square wave on the output.

The only disadvantage of this circuit compared with basic circuits that just drive the opto via 2 x 30k resistors, is that the zero transition falling edge occurs quite a long time before the actual zero voltage crossing point.

However its possible to remove this offset in the Arduino using one of the timers.

I’ll post my Arduino code when I’ve had chance to tidy it up.

Zero crossing detector LTSpice file