I wanted to make a zero crossing sensor that would give a pulse every time the mains crossed through zero. I know there are opto-coupler zero-crossing sensors (eg H11AA1, which I have), but there are reasons I don’t want to use one.
I decided to make the following …
The top section is a 5V PSU.
The idea was that the LM393 comparator develops a square wave, synchronised with the mains, and the second XOR gate makes a pulse by comparing that square wave with a version of itself that is delayed by the RC network on the lower leg. While the XOR inputs are different (during the delay), the output goes high, giving a pulse every time the mains goes through zero. The first XOR is there partly for buffering and partly for convenience, because it was built on stripboard, and the pins lined up.
The circuit containing the transformer secondary and the diode-limited AC on the comparator inputs would be floating without the pot, but with the pot, it can be swung from 0V to 5V. I originally had one leg tied to ground, but the LM393 didn’t like that.
It works OK, but the pulse that comes out of the XOR bounces for a couple of uS. I traced it back to the comparator, which rings on each transition.
In case you can’t read the writing on the image,
Top left : Diode-clamped input to comparator. Top right : Apparently clean output of comparator. Bottom right : edge of comparator output expanded. This is a falling edge, but the rising edge looks similar.
I examined the top left waveform meticulously. The rise time is slow, taking about 220uS, but it is clean – no ringing there.
Browsing around for a solution to my problem, I found that a lot of LM393 users have a similar problem. There have been suggestions to put a 10uF and a 10nF across the 5V rails close to the comparator, but I haven’t found that it helps. It’s on a breadboard, which isn’t the ideal environment, but connecting the capacitors doesn’t noticeably improve matters, so I don’t think that putting it on Veroboard will help either. It was originally on Veroboard, but although I have added the pot and unlinked the transformer secondary circuit from ground, the ringing is the same.
Is this an artifact of the LM393? Is there another comparator I should be using? Maybe an op-amp? Any other suggestions?
I decided to make the following …
The top section is a 5V PSU.
The idea was that the LM393 comparator develops a square wave, synchronised with the mains, and the second XOR gate makes a pulse by comparing that square wave with a version of itself that is delayed by the RC network on the lower leg. While the XOR inputs are different (during the delay), the output goes high, giving a pulse every time the mains goes through zero. The first XOR is there partly for buffering and partly for convenience, because it was built on stripboard, and the pins lined up.
The circuit containing the transformer secondary and the diode-limited AC on the comparator inputs would be floating without the pot, but with the pot, it can be swung from 0V to 5V. I originally had one leg tied to ground, but the LM393 didn’t like that.
It works OK, but the pulse that comes out of the XOR bounces for a couple of uS. I traced it back to the comparator, which rings on each transition.
In case you can’t read the writing on the image,
Top left : Diode-clamped input to comparator. Top right : Apparently clean output of comparator. Bottom right : edge of comparator output expanded. This is a falling edge, but the rising edge looks similar.
I examined the top left waveform meticulously. The rise time is slow, taking about 220uS, but it is clean – no ringing there.
Browsing around for a solution to my problem, I found that a lot of LM393 users have a similar problem. There have been suggestions to put a 10uF and a 10nF across the 5V rails close to the comparator, but I haven’t found that it helps. It’s on a breadboard, which isn’t the ideal environment, but connecting the capacitors doesn’t noticeably improve matters, so I don’t think that putting it on Veroboard will help either. It was originally on Veroboard, but although I have added the pot and unlinked the transformer secondary circuit from ground, the ringing is the same.
Is this an artifact of the LM393? Is there another comparator I should be using? Maybe an op-amp? Any other suggestions?