Mains voltage zero crossing detector with optical isolated output

Feb 15, 2012 482 Replies

time in a hundred, or one time in a billion.

The runt hazard is inherent in the way the PEs are generated. They will happen very roughly one time in every 50,000 zero crossings. The slow comparator edge makes things even worse than the race condition. There are multiple unnecessary hazards.

It's cute, but I don't see the advantage to working further up on the sinewave slope, or of timing one cycle to determine the center of the next. In real life, the width measurement won't be very accurate.

And it is badly implemented. It has real, serious asynchronous glitch hazards.

John Larkin, President Highland Technology, Inc jlarkin at highlandtechnology dot com http://www.highlandtechnology.com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom laser controllers Photonics and fiberoptic TTL data links VME thermocouple, LVDT, synchro acquisition and simulation

time in a hundred, or one time in a billion.

So, elaborate

If you believe race conditions exist in my circuit, then you should show where and why instead of merely gushing platitudes.

time in a hundred, or one time in a billion.

Run the sim and zoom in on any of the PE pulses. Next, fiddle with the initial delay of the clock generator. You can tune the delay to narrow down the PE pulse to a runt, much narrower than the counters are spec'd to work with.

The alignment between the comparator output and the clock is random, so sooner or later it will see a clock edge in the danger zone. I'd expect it to screw up roughly a couple of times per hour.

Try it.

In real life, with the slow comparator edge, things will be even worse. That hazard is hard to see in Spice, since all the CMOS parts probably have identical modeled thresholds.

The same hazard exists on every PE pulse.

It has bugs. They are easily fixed, but not if you refuse to look at them. A lot of things fail because people refuse to look at the hazards. That is something you have to fight all the time. It helps to have design reviews with semi-competitive people to catch the stuff that you shy away from seeing.

This bug is a classic beginners' mistake, namely bringing an async signal into a synchronous state machine in multiple places. Serious logic designers spot this hazard instantly.

John Larkin, President Highland Technology, Inc jlarkin at highlandtechnology dot com http://www.highlandtechnology.com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom laser controllers Photonics and fiberoptic TTL data links VME thermocouple, LVDT, synchro acquisition and simulation

Did you just learn that word? Better look it up again.

Your data is asynchronous with the clock; bingo metastability. Any second-year EE should see that.

Prevail? Convince you? That's not going to happen. You don't care to learn.

Try your second year of EE again. The problem is obvious.

time in a hundred, or one time in a billion.

Dickless.

Objective, reasoned discourse. Thanks for that.

That's a different discussion. It's cute, but not necessarily useful. There's probably an analog way to do the same function, probably also not useful. In fact, one of my customers did almost exactly that to find the center of a pulse, an optical reflection off a particle.

Wrong is wrong. No personality is involved in that. We did tell you, about a dozen times, that your circuit has some fundamental logic hazards, and you turned that into some sort of personal challenge.

I still kinda like my 2 or 3 part totem-pole ZCD.

John Larkin, President Highland Technology, Inc jlarkin at highlandtechnology dot com http://www.highlandtechnology.com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom laser controllers Photonics and fiberoptic TTL data links VME thermocouple, LVDT, synchro acquisition and simulation
[snip]

Useless as it may be. ...Jim Thompson

-- | James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at

formatting link
| 1962 | I love to cook with wine. Sometimes I even put it in the food.

Stupid old fool. My circuit is cheap, elegant, and works. You took a shot at it, posted an incomplete hairball, and gave up.

John Larkin, President Highland Technology Inc www.highlandtechnology.com jlarkin at highlandtechnology dot com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom timing and laser controllers Photonics and fiberoptic TTL data links VME analog, thermocouple, LVDT, synchro, tachometer Multichannel arbitrary waveform generators

Platitude/obfuscation #7 ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

Is that all you can say any more? Endless repetition is a sure sign of senility.

You did post a hairball, and you did give up. Hey, that deserves repeating. Call that #8.

Stupid old hen. #9.

John Larkin, President Highland Technology Inc www.highlandtechnology.com jlarkin at highlandtechnology dot com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom timing and laser controllers Photonics and fiberoptic TTL data links VME analog, thermocouple, LVDT, synchro, tachometer Multichannel arbitrary waveform generators

Poor demented SOB. I'm really getting under your skin, and enjoying it immensely ;-) ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

You enjoy being a buffoon and a failure? Go for it.

Are you going to ruin my career, like you bragged you did to someone else, even though it took you 18 years to "get even"? OK, I give you until 2030 to ruin mine.

John Larkin, President Highland Technology Inc www.highlandtechnology.com jlarkin at highlandtechnology dot com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom timing and laser controllers Photonics and fiberoptic TTL data links VME analog, thermocouple, LVDT, synchro, tachometer Multichannel arbitrary waveform generators

"15" years. You need to improve your reading comprehension. ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

You're slowing down, so let's go with the 2030 deadline.

John Larkin, President Highland Technology, Inc jlarkin at highlandtechnology dot com http://www.highlandtechnology.com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom laser controllers Photonics and fiberoptic TTL data links VME thermocouple, LVDT, synchro acquisition and simulation

Even more simple than my LM339 version, yet with a strong pulse into the opto-couplers at the ZC...

formatting link
...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

how is it useless? it produces an isolated square wave in sync with the mains. You might complain it is sensitive to noise around the zero crossing, but in that regard your schematic with a flipflop is exactly the same.

you just use more parts and they are not needed since the OP said it was going to a pin on an MCU

-Lasse

Good grief. Power hog. Component-rich. Misses the zero cross by a couple of volts. The HC04 will probably oscillate in its linear region. Why didn't you at least use an HC14?

A minor tweak would at least nominally nail the zero crossing.

John Larkin, President Highland Technology, Inc jlarkin at highlandtechnology dot com http://www.highlandtechnology.com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom laser controllers Photonics and fiberoptic TTL data links VME thermocouple, LVDT, synchro acquisition and simulation

--- OK, you've got the sim, so why not modify the schematic and post your solution instead of just alluding to vagaries?

After all, if this is a design review, opinions take a back seat to facts, yes?

-- JF

Less than 1°. Why is your 1° better than my 1°?

There's actually a better way.

Show us. ...Jim Thompson

| James E.Thompson, CTO | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine. Sometimes I even put it in the food.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required