EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: Analog Kid on December 23, 2024, 03:11:18 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:
[attachimg=1]
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:
[attachimg=2]
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 ...
-
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!
-
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)
-
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?
-
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.
-
Both
-
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?
-
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.
-
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,
-
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.
[attachimg=1]
Here's the output, just like someone said above: just a square wave:
[attachimg=2]
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).
-
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.
-
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 (https://www.worldradiohistory.com/UK/Everyday-Electronics/90s/Everyday-Electronics-1990-01-S-OCR.pdf)
-
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.
-
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.
-
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:
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.
-
What about a schmidt trigger
Schmitt trigger.
-
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...
-
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 (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:
[attachimg=1]
Does a pretty damn good job of what H&H's circuit above does:
[attachimg=2]
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:
[attachimg=3]
-
Now, if a guy wanted to turn that output into short pulses--one pulse per zero crossing--how would he go about doing that?
[attach=1]
IC is 1/4 of 74HC86 or 1/4 of CD4070 or 74LVC1G86
-
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.
-
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.
-
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?
-
What about a schmidt trigger
Schmitt trigger.
I got the spelling from Schmidt beer, honest mistake for a Minnesotan
-
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!
-
Nah, it's Grain Belt for me.
-
I miss the animated Hamm's bear.
-
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?
I don't know.
I had a project in mind that needed this, can't think of it now.
Why don't y'all just humor me, consider this an interesting electronic challenge.
How could a guy generate short-ish pulses from that nice square wave at each zero crossing?
Surely you smart guys can come up with something.
-
I miss the animated Hamm's bear.
[Indian drums: BOOM boom boom boom BOOM boom boom boom]
From the land of sky blue waters,
From the land of pines, lofty balsams,
Comes the beer refreshing—Hamm's, the beer refreshing.
-
My favorite ad from that era has the bear playing hockey goalie and flirting with a cute lady beaver in the stands.
Her bratty kid-brother beaver chews a puck-clearing hole in his goalie stick.
-
Apparently that beaver also owns a chainsaw:
https://www.youtube.com/watch?v=EZh66cyCCE8 (https://www.youtube.com/watch?v=EZh66cyCCE8)
-
Here’s one I cooked up many years ago. Used it quite successfully in SCR soft starters for three-phase induction motors.
-
Surely you smart guys can come up with something.
Once more???
https://www.eevblog.com/forum/beginners/hey-actually-figured-something-out-on-my-own (https://www.eevblog.com/forum/beginners/hey-actually-figured-something-out-on-my-own!-(zero-crossing-detector)/msg5760003/#msg5760003)
-
That's only halfwave. Here's a fullwave solution, which is designed to work from a bridge rectifier.
[attachimg=1]
EDIT: I attached the wrong .asc file. Here's the correct one.
-
Very precise and robust detector from: http://web.archive.org/web/20170704120431/www.dextrel.net/diyzerocrosser.htm (http://web.archive.org/web/20170704120431/www.dextrel.net/diyzerocrosser.htm)
[attachimg=1]
FEATURES:
highly accurate mains zero crossing detection
fully isolated and low voltage safe output
ultra-low power consumption; worst case power dissipation < 120mW
produces symmetrical pulses around zero crossings
output pulse stays constant, independent of the mains voltage
very low parts count, no precision components required
all components can be low voltage SMD
works over all voltage ranges (100VAC/240VAC), without modification
50Hz/60Hz compatible
50Hz produces a 1ms ZC pulse, 60Hz produces 0.83ms ZC pulse
highly stable with varying temperature and aging
-
The only drawback I find to this circuit is that it is necessary to count only the even pulses (or odd pulses) to accurately measure the network frequency, because the time from an even pulse to an odd pulse is not the same as from an odd pulse to an even pulse.
-
That's only halfwave. Here's a fullwave solution, which is designed to work from a bridge rectifier.
I loves it. Thanks!
Same old story here: I post a question, get a few answers, then the naysayers come out at night, accusing me of being a troll (!?!?!) but posting nothing of use.
Then someone posts a simple and elegant solution to my question. Which proves my theory that there are indeed people who not only know more than I do about electronics here, but who are willing to share their knowledge without condescension, carping or chiding.
Good job, @Zero999!
-
> but posting nothing of use.
I give up. Why you ask a question when don't want to see an answer?
-
> but posting nothing of use.
I give up. Why you ask a question when don't want to see an answer?
Au contraire, mon ami.
I did want an answer, and I got it from comrade @Zero999.
OK?
What I don't want is a rash of shit saying "why bother asking that question?" or "what, are you nuts?" or things along those lines.
-
You got 3 answers in total, but ignore 2 of them
-
You got 3 answers in total, but ignore 2 of them
That's because I only got one that provided the solution I asked for (pulses on all zero crossings).
-
Once again - you got 3 answers for your question - pulses on each edge of conparator output. And ignore (or didn't understand) 2 of them
-
Once again - you got 3 answers for your question - pulses on each edge of conparator output. And ignore (or didn't understand) 2 of them
To be fair, @Circlotron did post such a solution, but it looked a bit too complex for my taste (4 op-amps!).
We are allowed to pick and choose which solutions we like, yes?
Or are now subject to CCP rules that mandate that we accept all solutions equally?
-
Post #19 and post #35 was ignored. Yes, you have a right take in account or ignore any solution on your choise, but don't be surprised to be taken as a troll in this case.
-
I'm trying to simulate #19 in LTSpice. Unfortunately, can't seem to do it, as for some reason the program doesn't recognize some of its own models (trying to use CD4030 or CD4070, since I don't have any of the 74HCT models).
-
That's only halfwave. Here's a fullwave solution, which is designed to work from a bridge rectifier.
I loves it. Thanks!
Same old story here: I post a question, get a few answers, then the naysayers come out at night, accusing me of being a troll (!?!?!) but posting nothing of use.
Then someone posts a simple and elegant solution to my question. Which proves my theory that there are indeed people who not only know more than I do about electronics here, but who are willing to share their knowledge without condescension, carping or chiding.
Good job, @Zero999!
This was suggested in post 8, all due respect to zero999
Just stuff the output of a bridge rectifier into the AoE design and you have what you asked for.
There have been several other perfectly sound suggestions all ignored.
If you want to discuss a topic, do so, but FFS stop weaving a bullshit story into it and keep dismissing those who try to help, making pedantic comments about their answers, spelling, prose and wasting their time.
You are a troll, just not a very clever one.
I was a little puzzled about why he preferred my design over the others. It's nothing special. Plenty of other sensible suggestions have been posted. My design has its downsides, the main one being that it isn't isolated, but that wasn't a requirement. I just wanted something which will work with a bridge rectifier and doesn't require an additional diode in series with the load, so the zero crossing circuit is isolated with the smoothing capacitor.
Perhaps it's because I included a clear simulation and plot?
-
Here is a low parts count design.
Note you have to size the resistors according to the input line.
Also note that R8 and R9 may be needed to decrease the fall time because the 4N35 opto's are pretty slow.
There maybe a little phase shift (test that) so it also depends exactly how accurate you need to detect the zero crossing point.
I used the schematic from post #35 as a starting point for the drawing itself.
-
This was my mistake not his (Analog Kid), as I didn't read whom the OP author was when first replying as I thought I had put the user on the ignore list so I didnt interact any more and get pissed at him.
Please, by all means do put me on your ignore list.
You're just a snob, and an unhelpful asshole to boot.
-
Here is a low parts count design.
Note you have to size the resistors according to the input line.
Also note that R8 and R9 may be needed to decrease the fall time because the 4N35 opto's are pretty slow.
There maybe a little phase shift (test that) so it also depends exactly how accurate you need to detect the zero crossing point.
I used the schematic from post #35 as a starting point for the drawing itself.
Thanks.
My zero-crossing detector wouldn't need any line isolation like that.
If you wouldn't mind, could you tell us what the output waveforms look like? And how would we deal with the two separate outputs?
-
Here is a low parts count design.
Note you have to size the resistors according to the input line.
Also note that R8 and R9 may be needed to decrease the fall time because the 4N35 opto's are pretty slow.
There maybe a little phase shift (test that) so it also depends exactly how accurate you need to detect the zero crossing point.
I used the schematic from post #35 as a starting point for the drawing itself.
I would just use an opto-coupler with an AC input, rather than two opto-couplers.
https://www.vishay.com/docs/83608/83608.pdf (https://www.vishay.com/docs/83608/83608.pdf)
Here is a low parts count design.
Note you have to size the resistors according to the input line.
Also note that R8 and R9 may be needed to decrease the fall time because the 4N35 opto's are pretty slow.
There maybe a little phase shift (test that) so it also depends exactly how accurate you need to detect the zero crossing point.
I used the schematic from post #35 as a starting point for the drawing itself.
Thanks.
My zero-crossing detector wouldn't need any line isolation like that.
If you wouldn't mind, could you tell us what the output waveforms look like? And how would we deal with the two separate outputs?
What are you talking about? There is only one output. Take another look at the circuit.
-
This was my mistake not his (Analog Kid), as I didn't read whom the OP author was when first replying as I thought I had put the user on the ignore list so I didnt interact any more and get pissed at him.
Please, by all means do put me on your ignore list.
You're just a snob, and an unhelpful asshole to boot.
Thank you! I did, but for some reason the forum started to display them again.
It's sorted now though.
I dont know why unhelpful? I suggested upthread that you just feed a bridge rectifier waveform into the AoE circuit and it's job done... but not realising it was you that was TS.
As you don't appreciate people being helpful, (don't understand, or have another agenda), I've saved you from reviewing my posts and have had them deleted in this thread.
Please accept my profound appologies for interupting your trolling.
Regards.
X (Dr Asshole)
-
I dont know why unhelpful? I suggested upthread that you just feed a bridge rectifier waveform into the AoE circuit and it's job done...
In fairness it's not as simple as taking the output from the bridge rectifier and connecting it to the AoE circuit. Note D1 & D2 and R6 & R7 in my circuit.
-
I dont know why unhelpful? I suggested upthread that you just feed a bridge rectifier waveform into the AoE circuit and it's job done...
In fairness it's not as simple as taking the output from the bridge rectifier and connecting it to the AoE circuit. Note D1 & D2 and R6 & R7 in my circuit.
[attach=1]
Regards,
X.
-
The only addition is a diode that isolates the bridge rectifier from the subsequent reservoir capacitor, however the basic circuit will work as I describe.
Like this?
[attachimg=4]
[attachimg=1]
That's the part I wanted to avoid, because it introduces an additional voltage drop.
Another option is to use two bridge rectifiers, with eliminates the additional diode drop. There are always several ways to solve the problem.
[attachimg=2]
[attachimg=3]
-
The only addition is a diode that isolates the bridge rectifier from the subsequent reservoir capacitor, however the basic circuit will work as I describe.
Like this?
(Attachment Link)
(Attachment Link)
That's the part I wanted to avoid, because it introduces an additional voltage drop.
Another option is to use two bridge rectifiers, with eliminates the additional diode drop. There are always several ways to solve the problem.
(Attachment Link)
(Attachment Link)
Thank you!
Yes, (almost) exactly. I messed up putting the circuit in the previous post, but it's there now, just lost the body of text, (no loss).
The diode drop being a problem would depend on application. IME no real problem as theres usually headroom for the ubiquitous regulators anyhow.
X
-
The only addition is a diode that isolates the bridge rectifier from the subsequent reservoir capacitor, however the basic circuit will work as I describe.
Like this?
(Attachment Link)
(Attachment Link)
That's the part I wanted to avoid, because it introduces an additional voltage drop.
Another option is to use two bridge rectifiers, with eliminates the additional diode drop. There are always several ways to solve the problem.
(Attachment Link)
(Attachment Link)
In the second circuit with two bridges, D2 and D4 are unnecessary.
-
The only addition is a diode that isolates the bridge rectifier from the subsequent reservoir capacitor, however the basic circuit will work as I describe.
Like this?
(Attachment Link)
(Attachment Link)
That's the part I wanted to avoid, because it introduces an additional voltage drop.
Another option is to use two bridge rectifiers, with eliminates the additional diode drop. There are always several ways to solve the problem.
(Attachment Link)
(Attachment Link)
In the second circuit with two bridges, D2 and D4 are unnecessary.
That's true, as they're in parallel with D6 & D8. When I drew the schematic, I assumed D1 to D4 and D5 to D8 are bridge rectifier ICs, not discrete components. I suppose you could go for a high power bridge rectifier for D1 to D4, skip D6 & D8 and use low power diodes for D5 & D7.
I also forgot the hysteresis resistor.
For completeness here's the schematic and simulation.
[attachimg=1]
-
The only addition is a diode that isolates the bridge rectifier from the subsequent reservoir capacitor, however the basic circuit will work as I describe.
Like this?
(Attachment Link)
(Attachment Link)
That's the part I wanted to avoid, because it introduces an additional voltage drop.
Another option is to use two bridge rectifiers, with eliminates the additional diode drop. There are always several ways to solve the problem.
(Attachment Link)
(Attachment Link)
In the second circuit with two bridges, D2 and D4 are unnecessary.
That's true, as they're in parallel with D6 & D8. When I drew the schematic, I assumed D1 to D4 and D5 to D8 are bridge rectifier ICs, not discrete components. I suppose you could go for a high power bridge rectifier for D1 to D4, skip D6 & D8 and use low power diodes for D5 & D7.
I also forgot the hysteresis resistor.
For completeness here's the schematic and simulation.
(Attachment Link)
Very good, thank you.
The advantage of the scheme is that in the conjuction a fast enough diode type is used in the position of D5/D7 of your circuit, the input frequency that can be sampled giving a directly proportional output pulse that is then only likely to be limited by the slew rate of the comparator, overcoming the problems associated with a fixed pulse period, as in Tooki's scenario of the Aircraft 400Hz system, or slow rectifier diodes.
In other words, in higher frequency applications, don't use 1Nx400X series rectifiers.
X
-
The classic case, using logic, could just be implemented in discrete parts.
In the classic edge detect, your logical AND will have a direct input, that maybe just came up, (to a logical 'one', and that is paired with a slightly delayed copy.
With this, you've got a window of a short time, (and also thru an inverter), so that the opportunity is short, and, soon that logical 'and' function won't have both inputs in the correct form (that is, both logical 'one').
But a rising edge will make it through that, for the short time, before the AND gate stops.
Of course, you will need to do that in logical equivalents, when using discrete parts, including the negative Boolean logic, where a logical 'OR' will act as a 'negative logic' AND gate.
That means that a zero with a zero will satisfy the AND, in negative logic sense.