Author Topic: Hey, actually figured something out on my own! (zero-crossing detector)  (Read 2791 times)

0 Members and 1 Guest are viewing this topic.

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Last night laying in bed I thought, for some strange reason, about how would a guy implement a zero-crossing detector? Odd, since I have no current use for such a thing, but an interesting intellectual exercise nonetheless.

I first thought, as I always do, how would a guy do this using only discretes? Diodes, BJTs, stuff like that.
Couldn't think of how that could possibly be done.
Then it struck me: how 'bout an op-amp a comparator? So I came up with the following scheme:



Now this is totally bare-bones, just a basic proof of concept thing.
This morning at breakfast I cracked open my copy of Horowitz & Hill (The Art of Electronics), looked up "zero-crossing" in the index and found this:



So hey, maybe I'm not as dumb as I think (or as others might accuse me of being). Now of course this is a fully-fleshed-out circuit, just about ready for use, with input protection (and hysteresis!).

I put that inverter after the op-amp because I figured that the output was going to be low, not high, on a zero crossing, but H&H, those clever dogs, just used the inverting configuration of the amp. Doh!

Anyhow, it gave me a slight boost this am. Now if I can just find a project that needs this thing ...
 
The following users thanked this post: BILLPOD

Offline CaptDon

  • Super Contributor
  • ***
  • Posts: 2132
  • Country: is
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #1 on: December 23, 2024, 02:34:39 pm »
These were used in older 60Hz digital clocks but line noise caused 'extra' clocking. I have even seen some low grade audio frequency counters that used the line frequency as the time base, in fact I owned an old Heathkit D.M.M. who's accuracy depended on line frequency! That D.M.M. was useless in our mobile broadcast studio when running on generator!
Collector and repairer of vintage and not so vintage electronic gadgets and test equipment. What's the difference between a pizza and a musician? A pizza can feed a family of four!! Classically trained guitarist. Sound engineer.
 

Offline xvr

  • Frequent Contributor
  • **
  • Posts: 539
  • Country: ie
    • LinkedIn
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #2 on: December 23, 2024, 02:52:17 pm »
Quote
I put that inverter after the op-amp because I figured that the output was going to be low, not high, on a zero crossing,
Output will be both a low and high on zero crossing, so inverting doesn't matter.
This circuit doesn't generate pulses on zero crossing, it produces edges (both positive and negative) on zero crossing. So to obtain classic zero crossing detector you need to add edge detection circuit on output (it could be one XOR element + RC network)
 
The following users thanked this post: tooki

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13069
  • Country: ch
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #3 on: December 23, 2024, 05:15:18 pm »
These were used in older 60Hz digital clocks but line noise caused 'extra' clocking. I have even seen some low grade audio frequency counters that used the line frequency as the time base, in fact I owned an old Heathkit D.M.M. who's accuracy depended on line frequency! That D.M.M. was useless in our mobile broadcast studio when running on generator!
Mains-clocked clocks are still super common in appliances (like ovens). Perhaps modern implementations use a bandpass filter to reduce spurious clocking?
 

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #4 on: December 23, 2024, 08:38:56 pm »
Quote
I put that inverter after the op-amp because I figured that the output was going to be low, not high, on a zero crossing,
Output will be both a low and high on zero crossing, so inverting doesn't matter.
This circuit doesn't generate pulses on zero crossing, it produces edges (both positive and negative) on zero crossing. So to obtain classic zero crossing detector you need to add edge detection circuit on output (it could be one XOR element + RC network)

By "this circuit" you mean my dreamt-up one, not the H&H one, right?
I assume theirs produces pulses.
Still learning here.
 

Offline xvr

  • Frequent Contributor
  • **
  • Posts: 539
  • Country: ie
    • LinkedIn
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #5 on: December 23, 2024, 10:12:55 pm »
Both
 

Offline SteveThackery

  • Frequent Contributor
  • **
  • Posts: 759
  • Country: gb
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #6 on: December 24, 2024, 09:11:03 am »
I don't understand. Referring to the original "bare bones" circuit, why doesn't it just convert the sine wave to a square wave? Where do the pulses come from?
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13069
  • Country: ch
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #7 on: December 24, 2024, 10:13:38 am »
Quote
I put that inverter after the op-amp because I figured that the output was going to be low, not high, on a zero crossing,
Output will be both a low and high on zero crossing, so inverting doesn't matter.
This circuit doesn't generate pulses on zero crossing, it produces edges (both positive and negative) on zero crossing. So to obtain classic zero crossing detector you need to add edge detection circuit on output (it could be one XOR element + RC network)

By "this circuit" you mean my dreamt-up one, not the H&H one, right?
I assume theirs produces pulses.
Still learning here.
Take a look at the waveforms in these crude sketches of mine, attached. The first one is what you mistakenly think a comparator circuit would output. But in actuality you get the second one. In the second one, I have added arrows to the edges so you really see what xvr meant about edges (rising and falling) and how you get both highs and lows at zero crossings.
 

Offline StrayElectrons

  • Contributor
  • Posts: 19
  • Country: ca
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #8 on: December 24, 2024, 10:29:50 pm »
ZVS (zero voltage crossing) was used on the RCA CTC-203 SMPS.    Only I think 2 transistors, 431 and MOSFET, this circuit is self oscillating.

It doesn't have op-amp at all.

Cheers,
 

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #9 on: December 24, 2024, 11:12:03 pm »
I don't understand. Referring to the original "bare bones" circuit, why doesn't it just convert the sine wave to a square wave? Where do the pulses come from?

First of all, thanks for paying attention here.
Answer: they don't.
Feel like I've got a little egg on my face here.
So my attempt was obviously a shot in the dark that missed its mark.
But the Horowitz & Hill circuit? I assumed that it would work as advertised.
Guess what? It doesn't.
I simmed it in LTSpice. Was careful to make the circuit exactly as in the book, except for the comparator: I don't have a model for the LM393, so I used a LT part (LT1720) that should work the same: it's a single-supply (3.3-5V) rail-to-rail device.



Here's the output, just like someone said above: just a square wave:



I'm really surprised that this comes from the esteemed H&H. Is there an error in their circuit? Will it only work with an LM393? What's going on here?

I've attached the .asc file in case someone wants to play around with this (and you can check my rendition for errors).
 

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #10 on: December 24, 2024, 11:27:16 pm »
ZVS (zero voltage crossing) was used on the RCA CTC-203 SMPS.    Only I think 2 transistors, 431 and MOSFET, this circuit is self oscillating.

Could you possibly provide that circuit, or help me find it? Definitely interested in anything that uses discretes.
Although that doesn't sound like a zero crossing detector so much as an oscillator that has something to do with zero crossing.
 

Offline themadhippy

  • Super Contributor
  • ***
  • Posts: 3199
  • Country: gb
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #11 on: December 24, 2024, 11:42:52 pm »
A good source for ole skool  zero-crossing  circuits is the disco lighting controller circuits published by  the hobby mags ,one to get you started https://www.worldradiohistory.com/UK/Everyday-Electronics/90s/Everyday-Electronics-1990-01-S-OCR.pdf
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13069
  • Country: ch
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #12 on: December 24, 2024, 11:48:46 pm »
I'm really surprised that this comes from the esteemed H&H. Is there an error in their circuit? Will it only work with an LM393? What's going on here?
Why do you think it’s an error? It’s doing precisely what one would expect the circuit to do. Comparators compare, they aren’t timers.
For use with an MCU, no further circuitry is needed — an MCU can easily be programmed to react to edges instead of levels. (In fact, it is often beneficial to do so even in situations where levels could also be used.)

For circuits that aren’t MCU-based, there are ways to generate pulses from that.
 

Offline antenna

  • Frequent Contributor
  • **
  • Posts: 410
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #13 on: December 25, 2024, 12:08:16 am »
What about a schmidt trigger (for hysteresis), bias the input using a regulated DC source through a potentiometer, then AC couple the signal to the pot wiper and to the schmidt trigger input.  The pot would control the bias and therefore the crossing point making it easy to set to zero, and then if the output needs to be a different duty cycle, use the rising edge of the output to trigger a 555 or something else.
 

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #14 on: December 25, 2024, 12:26:38 am »
I'm really surprised that this comes from the esteemed H&H. Is there an error in their circuit? Will it only work with an LM393? What's going on here?
Why do you think it’s an error? It’s doing precisely what one would expect the circuit to do. Comparators compare, they aren’t timers.

My bad, I guess. Yes, I know what comparators do, but I had assumed (hoped?) that the output would be tailored to create a pulse instead of just squaring the wave.

Shoulda paid more attention to H&H's description:
Quote
The circuit shown in Figure 3.68 generates an output square wave for use with TTL logic (zero to +5V range) ...

And that it does, very well.

I'm looking at that Everyday Electronics article now.
 

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #15 on: December 25, 2024, 12:27:30 am »
What about a schmidt trigger

Schmitt trigger.
 

Offline MrAl

  • Super Contributor
  • ***
  • Posts: 1653
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #16 on: December 25, 2024, 02:55:05 am »
Last night laying in bed I thought, for some strange reason, about how would a guy implement a zero-crossing detector? Odd, since I have no current use for such a thing, but an interesting intellectual exercise nonetheless.

I first thought, as I always do, how would a guy do this using only discretes? Diodes, BJTs, stuff like that.
Couldn't think of how that could possibly be done.
Then it struck me: how 'bout an op-amp a comparator? So I came up with the following scheme:

(Attachment Link)

Now this is totally bare-bones, just a basic proof of concept thing.
This morning at breakfast I cracked open my copy of Horowitz & Hill (The Art of Electronics), looked up "zero-crossing" in the index and found this:

(Attachment Link)

So hey, maybe I'm not as dumb as I think (or as others might accuse me of being). Now of course this is a fully-fleshed-out circuit, just about ready for use, with input protection (and hysteresis!).

I put that inverter after the op-amp because I figured that the output was going to be low, not high, on a zero crossing, but H&H, those clever dogs, just used the inverting configuration of the amp. Doh!

Anyhow, it gave me a slight boost this am. Now if I can just find a project that needs this thing ...

Here's a commercial example...
 

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #17 on: December 25, 2024, 03:23:00 am »
A good source for ole skool  zero-crossing  circuits is the disco lighting controller circuits published by  the hobby mags ,one to get you started https://www.worldradiohistory.com/UK/Everyday-Electronics/90s/Everyday-Electronics-1990-01-S-OCR.pdf

Thanks. I looked at that. Extracted the following circuit fragment from it:



Does a pretty damn good job of what H&H's circuit above does:



Now, if a guy wanted to turn that output into short pulses--one pulse per zero crossing--how would he go about doing that?
Thinking of playing around with gates: flip-flop?
We want a pulse on each zero crossing. Like what @Tooki drew:

« Last Edit: December 25, 2024, 03:29:39 am by Analog Kid »
 

Offline xvr

  • Frequent Contributor
  • **
  • Posts: 539
  • Country: ie
    • LinkedIn
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #18 on: December 25, 2024, 09:42:53 am »
Quote
Now, if a guy wanted to turn that output into short pulses--one pulse per zero crossing--how would he go about doing that?
2469699-0

IC is 1/4 of 74HC86 or 1/4 of CD4070 or 74LVC1G86
 

Offline SteveThackery

  • Frequent Contributor
  • **
  • Posts: 759
  • Country: gb
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #19 on: December 25, 2024, 10:09:13 am »
Quote
Now, if a guy wanted to turn that output into short pulses--one pulse per zero crossing--how would he go about doing that?
(Attachment Link)

IC is 1/4 of 74HC86 or 1/4 of CD4070 or 74LVC1G86

Do we need a diode across R8 to help discharge the capacitor? Actually, no, I can see that it's unnecessary provided the capacitor is small enough to produce a pulse which is very short compared with the sine wave period.
 

Offline xvr

  • Frequent Contributor
  • **
  • Posts: 539
  • Country: ie
    • LinkedIn
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #20 on: December 25, 2024, 10:58:31 am »
Quote
Do we need a diode across R8 to help discharge the capacitor?
Definitely no. Diode across R8 will shrink pulse width for negative edge. Circuit should be symmetrical for both edges, so diode SHOULD NOT be used.
 
The following users thanked this post: SteveThackery

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13069
  • Country: ch
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #21 on: December 25, 2024, 11:16:39 am »
I'm really surprised that this comes from the esteemed H&H. Is there an error in their circuit? Will it only work with an LM393? What's going on here?
Why do you think it’s an error? It’s doing precisely what one would expect the circuit to do. Comparators compare, they aren’t timers.

My bad, I guess. Yes, I know what comparators do, but I had assumed (hoped?) that the output would be tailored to create a pulse instead of just squaring the wave.
There well may exist a chip designed to do just that, but it wouldn’t be sold as a general-purpose comparator. A comparator’s job is to compare. Doing other things falls outside its purview, and besides, would need other components to configure it. (E.g. how long is the pulse? For 50/60Hz mains, where you’d get pulses at 100/120Hz, a pulse length of 5ms is no problem. But at the 400Hz used for aircraft systems, 5ms is longer than the entire period. Never mind at higher frequencies. So you would need a configurable pulse length.)

I checked, and zero-crossing detector (ZCD) ICs do exist, but every one I found outputs a square wave like the comparator.

Given that zero-crossing detection is also used for things like phase measurement, where you need to distinguish between the rising and falling zero-crossings, it seems reasonable to me that ZCD circuits and ICs don’t default to making pulses, since pulses are less flexible, and pulses can be created from the square wave, but phase-accurate square waves cannot be reconstructed from the pulses.

We want a pulse on each zero crossing. Like what @Tooki drew:

(Attachment Link)
Why do we want that? What is an application where we need two pulses per period and cannot accomplish the same thing with the square wave?
 

Offline antenna

  • Frequent Contributor
  • **
  • Posts: 410
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #22 on: December 26, 2024, 12:11:55 am »
What about a schmidt trigger

Schmitt trigger.
I got the spelling from Schmidt beer, honest mistake for a Minnesotan
 

Online TimFox

  • Super Contributor
  • ***
  • Posts: 8881
  • Country: us
  • Retired, now restoring antique test equipment
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #23 on: December 26, 2024, 12:13:25 am »
What about a schmidt trigger

Schmitt trigger.
I got the spelling from Schmidt beer, honest mistake for a Minnesotan

The beer that grew with the great north-west!
 

Online Analog KidTopic starter

  • Frequent Contributor
  • **
  • Posts: 862
  • Country: us
Re: Hey, actually figured something out on my own! (zero-crossing detector)
« Reply #24 on: December 26, 2024, 12:22:35 am »
Nah, it's Grain Belt for me.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf