Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler - Page 1
Forum section: electronics / projects

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 12:26:46 pm
content: Sorry to dig up this much discussed topic, but couldn't actually find anything that discusses these tradeoffs.I am doing AC mains zero cross detection for this project:https://www.eevblog.com/forum/projects/mains-switching-research-break-out/I am currently doing zero cross detect with an "AC Optocoupler" (2 antiparallel leds). See simplified attached schematic - the top half.ZCDAlternatives-ZCD.pdf(27.18 kB - downloaded 252 times.) -- Sorry inline attach didn't work..see link at bottom of post.This works OK, and gives me a "soft pulse" which is about ~700us wide at the pic18 Schmitt Trigger input levels. Internal to the pic18 I am using the SMT (Signal measurement timer) to get the pulse width and period -- a simple timer driven from interrupts also works, but why not. Gives me a check on the 50/60Hz and allows me to calculate the middle of the pulse as my best estimate for the zero cross. It's very close, within 10us or so, when checked on the scope, against the actual mains input using HV diff probe.I am now considering switching to the pic18s ZCD (Zero cross detect) device. Proposed schematic in bottom half of attached file.The ZCD is specialised for this task. This App note describes the detail of how to use it, but appears to be silent on the critical isolation point below.http://ww1.microchip.com/downloads/en/Appnotes/90003138A.pdfIt has the following advantages:It is "probably" more accurate, as the above pulse has quite soft edges (I haven't quantified this)It can detect positive and negative going edges, and give separate interrupts for thoseIt draws much less current. ~ 300uA vs ~3mA, so 10x less. Not critical as application draws up to 10A RMS. But still, low quiescent is good.It saves on BOM - not that critical, but stillAs opposed to the AC Optocoupler technique, which has these advantages:Much higher level of isolationNotethat it is entirely possible, even likely, that a human user of the device, or a mains earth referenced oscilloscope, will touch/be connected to the low voltage pic circuit GND or +5V, or even that ZCTrigger signal, which is only separated from Mains Phase by a 500k resistor.I split the required 1M Ohm resistance into 2 x 500kOhm to semi-protect against Phase and neutral being reversed. But this reduces isolation in the "correctly wired" case even further (earthed neutral system assumed here). And now the uC is floating at half mains potential. Did I make it worse?The ZCD is technically attractive, but is it even a viable option from a safety / isolation POV? Or could it be made safe? How?Or is this ZCD only intended for, and safe in, applications where the LV uC circuit can "float up anywhere it likes" and is in an enclosure that 100% ensures proper isolation from humans or other equipment?

author: Ian.M
author_rank: Super Contributor
timestamp: August 12, 2020, 12:58:22 pm
content: The Microchip ZCD peripheral is only usable when isolation is not required, or if you can tolerate the cost and phase shift of an instrument transformer or a high enough bandwidth analog isolator to drive it. If you *REALLY* want to use it, you should consider adding aPIC12F1612on the non-isolated side, programmed to output a line-synchronous squarewave on ZCD1OUT you could optocouple to your isolated side. Use it direct on an interrupt capable pin on you main PIC or for testing ZCD application software, couple it to the main PIC's ZCD pin via a resistor and capacitor to 'fake' the expected ZCD signal.Its got another four pins available, (two analog capable) so you could also use it to monitor temperature and possibly peak current, lock out the gate drive and drive a FAULT signal optocoupler.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 01:04:03 pm
content: Quote from: Ian.M on August 12, 2020, 12:58:22 pmThanks Ian. Yup, that exactly what I suspected. Not good for my application, which requires isolation, so stick with the optocoupler.But thanks for those other ideas. A second uC floating high side could become useful in this project, and if I do that, then I may revisit ZCD.

author: NiHaoMike
author_rank: Super Contributor
timestamp: August 12, 2020, 01:07:26 pm
content: You can sense from line to ground, using a string of resistors that satisfies isolation requirements.Another option is to put the microcontroller on the nonisolated side and use optoisolators on the user accessible I/O.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 01:29:20 pm
content: Quote from: NiHaoMike on August 12, 2020, 01:07:26 pmThanks, yes. But since there is a very small chance of incorrect external wiring, ground may actually be phase, and then the whole LV side would be at phase.

author: NiHaoMike
author_rank: Super Contributor
timestamp: August 12, 2020, 01:32:22 pm
content: Ground, not neutral.

author: Alti
author_rank: Frequent Contributor
timestamp: August 12, 2020, 01:49:44 pm
content: Quote from: oschonrock on August 12, 2020, 12:26:46 pmIMHO this is a circuit with low survivability rate of the end-user.Did you consider what happens when for example a neutral gets disconnected/damaged? Would you stick your fingers to a 500V rated resistor connected to Line? It might be 500k but only up to rated voltage, if safety rated.Are you still there?Hello?

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 01:52:18 pm
content: Quote from: NiHaoMike on August 12, 2020, 01:32:22 pmOK, fair enough. That is even less likely to be incorrectly wired I guess. And 300uA won't trip RCDs.Doesn't make me comfortable though. You can feel "tingling" at 0.5mA apparently - I am not trying it. 300uA is awfully close to that?

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 01:56:04 pm
content: Quote from: Alti on August 12, 2020, 01:49:44 pmRight.So you are saying 500k to phase is not "human safe" - neutral really doesn't come into it? I agree. Although it takes more than that to kill you (> 30mA) this is not what I would call safe...Hence I am sticking with the optocoupler.I was just asking under what circumstances the ZCD device can be made safe.Conclusion, in brief: It can't... unless you physically isolate the entire circuit.

author: BrianHG
author_rank: Super Contributor
timestamp: August 12, 2020, 07:37:24 pm
content: Why not just tap the you 5v supply transformer's AC winding's?Nice safe isolated 6-12vac to feed your MCU input through a series resistor.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 08:07:01 pm
content: Quote from: BrianHG on August 12, 2020, 07:37:24 pmYeah, that would be convenient, but there is no transformer here. Just HV MOSFETS and a sealed, all-in-one 1W SMPS.Although it's only about 1W, so maybe a linear supply could work, with a tiny transformer like this..https://uk.farnell.com/myrra/44049/transformer-6v-1va/dp/1689041That could work. Some more components (rectifier, caps, regulator), and a bigger footprint, etc...But then again, that transformer will introduce phase shift, which defeats the purpose..? I'll order one and play with it, but I suspect the phase shift is a variable we don't want for exact timing.

author: BrianHG
author_rank: Super Contributor
timestamp: August 12, 2020, 08:33:54 pm
content: Phase shift?Arent you using an MCU?They have PWM timers and comparitors so you can correct/adjust the delay from your source detection circuitry and sync up your power mosfet driving PWM.Just use the cheapest high speed optocoupler with a logic output, not an AC input one.Then just add a reverse polarity protection diode on the LED input.You will get a square wave output at very close to 45/55% duty cycle output.Now adjust the MCU pwm capture timer input to detect whether you are at 50/60hz and correct for the turn-on delay of the optocoupler LED.You can also current-regulate drive the LED input from the mains side and get a really close to a 50/50 duty cycle shortening the turn-on time and slightly extending the time before turn off. This may be only useful for universal 120v/240v support with minimal phase timing error between the 2 voltage systems. But the difference is so little, your design should be able to software detect and correct.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 09:01:07 pm
content: Quote from: BrianHG on August 12, 2020, 08:33:54 pmSorry not quite clear what you are saying. You seem to be mixing LV and HV options here?I don't have a transformer (as you know from original project), but only a sealed SMPS which powers the MCU. I wasn't really keen to add a linear PS. I could, but only if there is a clear advantage. What I have with the AC optocoupler already works, the questions is about doing it more easily and and/or more precisely. It's not bad now. Like I say within 10us or so and quite stable.There is a finite phase shift through any transformer right? In an ideal transformer the phase shift is 180 which would be fine. This can be considered zero if you swap connections. But in a real transformer with losses (if memory serves me correctly), it is not 180 and therefore some unknown amount dependent on the exact properties of that specific transformer (and also the load from memory).https://electronics.stackexchange.com/a/230403/213363I can compensate for all that in the MCU, obviously. But that would need calibrating, and unlike the width of the AC Optocoupler pulse I can't easily "measure" how much phase shift there is from within the MCU. With the soft pulse from the AC Optocoupler, I can just halve the width. Because the 2 LEDs are very similar there is symmetry and halving it gets me very very close. With the transformer I would need to put the scope on it, measure the phase shift and then compensate for it in software by adjusting some constant. What if the load changes (ie the MCU or the MOSFET trigger DC-DC converters draw more current), or if I go to 60Hz or the voltage dips... etc etc.That brings me to your other suggestion of (effectively) half-wave rectifying the AC (HV or LV wasn't quite clear to me from what you wrote) and then using a high speed DC optocoupler. Fine. Would work, but more components and only a disadvantage as far as I can see. Because the delay would be non zero, and because I now don't have the "width of a symmetric pulse" which I can halve, I am dealing with an unknown which I have to calibrate out (ie adjust some constant in the software, by measuring it on the scope). Can I get better than 10us without calibrating? I doubt it?So I would have to full wave rectify the AC to get the symmetry. Yet more components (or a single bridge). But if I wanted to tighten the pulse while otherwise doing the same halving maths in the MCU, then this would be the way to go. Same for any active transistor based current regulation to get a sharper pulse. It would need to be full-wave, ie symmetrical, but could help - at the expense of a lot more complexity.Is that what you mean?My current system will cope with 50/60Hz and 240/120VAC just by using the symmetry of the situation.Regarding the PWM driving of the MOSFETs. Yeah sure the MCU has tons of such functionality and I am working to find the best way to use that to deliver the 3 modes (from original project link at top) with as much flexibility as possible. But that is a separate subject, and not for this post.If I have misunderstood, please explain.

author: BrianHG
author_rank: Super Contributor
timestamp: August 12, 2020, 10:42:11 pm
content: Just use a 6N137 with a reverse polarity protection diode and do not talk about any delay.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 12, 2020, 10:56:16 pm
content: Quote from: BrianHG on August 12, 2020, 10:42:11 pmMore than happy to try it. You mean a "drop in replacement" to a similar circuit? With just the large dropper resistor(s) direct from mains?So if base it on 10mA (20mA current is absolute max) for the peak AC voltage of 330V , and the datasheet says that min high level current is 5mA, then that will occur when the AC voltage is 115V ..or thereabouts....It could switch the output to low at any point after thatSo we call that "zero delay, zero-cross detect"?I don't get where you're coming from, sorry. Just because the the optocoupler is "fast", ie it can switch very quickly, doesn't mean anything in this situation,. does it?Some other active current control circuit would be necessary. What do you suggest exactly?This person has thought about it. but it's non-trivial:https://cdn.hackaday.io/files/1597066832861504/SimpleIsolatedZeroCrossDetector.pdf

author: BrianHG
author_rank: Super Contributor
timestamp: August 12, 2020, 11:44:00 pm
content: Use the other guys circuit this way you don't need to engineer anything.There is more than 1 way to skin a cat.I would use this part: ISO7310CDR.The data input side has only a 10ua input current while it only requires a supply current of 1ma.Now, you should be able to work out on you own how to wire this guy up and with what components. If not, just use the other guys circuit.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 13, 2020, 12:25:18 am
content: Quote from: BrianHG on August 12, 2020, 11:44:00 pmThe issue is not the optocoupler. Throwing a different part number out there, doesn't solve the issue.Anyway, I am quite happy with the solution I engineered already, thanks.

author: BrianHG
author_rank: Super Contributor
timestamp: August 13, 2020, 02:21:09 am
content: Quote from: oschonrock on August 13, 2020, 12:25:18 amIf you are working with mains voltage and do not understand why the '10ua input current while it only requires a supply current of 1ma' capability of the part I mentioned is useful when designing a mains crossover detection circuit and the number of ways this can be used and be useful compared to using any optocoupler, you better be very careful with what you are working on. Working with mains can be very dangerous, potentially lethal and it is usually frowned upon any of us offering guidance with such projects here at EEVBloog.

author: David Hess
author_rank: Super Contributor
timestamp: August 13, 2020, 03:48:17 am
content: How accurate does your phase measurement need to be? The power line is pretty noisy making an exact zero crossing measurement difficult but does it need to be better than a simple optocoupler can deliver?For a really accurate zero crossing measurement, the noise needs to be removed however sharp filters will create phase errors themselves. High performance designs phase lock a clean oscillator to the power line allowing the loop filter to remove the noise without creating phase error but I think that is way overkill for your application.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 13, 2020, 07:46:45 am
content: Thank you David.Quote from: David Hess on August 13, 2020, 03:48:17 amYou are right about the noise. Particularly since I am introducing more of it by switching up to 10A mid cycle with MOSFETs. -- see project link at top.I don't need extreme accuracy. Lets, for the sake of the thread, estimate the required accuracy (I already did this).A 50Hz 230VAC RMS line has an equation of V(t) = Asin(wt) , whereA=sqrt(2) * 230 = 325V andw (angular frequency omega) = 2 * pi * frequency = 314.159 rad/sIts slope equation (ie first derivative) will be V'(t) = Awcos(wt)At very small angles, wt ~ 0 => cos(wt) ~ 1. So the slope is just V'(0) = Aw ~ 100kV/s (confirmed on the scope for those who prefer that). Note that 110V 60Hz is obviously slower => easier (20% higher w but only half the A).If, during trailing edge dimming, for example, (mode2 see original project link at top) I want to turn on the MOSFET pair at the crossover, then I would like to do it, when the line voltage is less than, say, Vswitch, because this will help reduce EMI, inrush currents for capacitive loads etc.So my timing for firing the MOSFET, needs to have the following accuracy (I am not going to worry about small, known, constant offsets here, like time for the MOSFET to fire or time for the MCU to process the interrupt):Lets shoot for Vswitch =< 10V as a first goal, ie fire MOSFET when mains voltage is less than 10V, How close to the true zero cross do we need to be in time?dt = 10 / 100000 = 0.1ms or 100us.My current method with the AC optocoupler gets me a pulse width of ~ 800us (using Schmitt trigger inputs on the pic), but the key is that this is very stable. ie it is almost symmetrical and of nearly constant width and of very consistent shape (ie any slight asymmetry is nearly constant). The standard deviation of the width at 50% of peak is < 10us, as measured on scope over half an hour.The first estimate of the true zero cross is at 50% of the width after the leading edge. This gets me to within ~100us of the zero cross. It turns out, I am firing consistently late. However, I have already met my goal of 10V Vswitch - again confirmed on scope. It's not right on zero due to the slight asymmetry in the pulse and the Schmitt trigger levels. If I use the knowledge I have of the asymmetry, and pick a time ~40% through the (pic detected!) pulse, I can get within ~ 10us (the random error in my signal).There are any number of circuits / devices which could give a narrower pulse. The issue is that a narrower pulse, by definition, is detecting a smaller mains voltage, and that smaller mains voltage will be more subject to noise (see below). So actually using a device that triggers repeatably and symmetrically at a higher voltage, and then halving its pulse width, is not a bad approach.For my application, there doesn't seem to be much point aiming for more accuracy than I have (unless I get it "for free", see below). If I can get within 5V of zero cross (ie about 50us) that would be more than enough, because any EMI will be completely swamped by what happens when I turn the MOSFET off again when the mains are at 325V and 10A is flowing! Plus for "mode3" (see original project link at top), which is switching the sine wave at 10kHz+, it almost doesn't matter at all.Quote from: David Hess on August 13, 2020, 03:48:17 amSpot on, yes, filtering is a double edged sword. Similar to step-down transformers. They introduce new delays / phase shifts.Quote from: David Hess on August 13, 2020, 03:48:17 amHadn't seen that, so thank you, but yes, agree that sounds like overkill.So why this thread? This thread was not about designing a hyper accurate zero cross detector. This post was to clarify whether I can simplify my design, and get more accuracy, lower power consumption and software convenience for free, by using already existing, specialised circuitry in the form of the pic18 built in ZCD peripheral.We established the answer in the first reply: No, not safely. Which is what I thought. I just wasn't clear why Microchip bothered at all, and the answer is: If you can let your MCU float then it's OK. I can't, so that's not an option for me.Case closed?

author: oschonrock
author_rank: Regular Contributor
timestamp: August 13, 2020, 12:07:16 pm
content: Quote from: David Hess on August 13, 2020, 03:48:17 amI made a couple of small tweaks and tried to get some good oscilloscope screenshots, for the benefits of others, who want to know what the accuracy limits of the basic AC optocoupler are.Changes:I Changed the series resistors from 47k to 22k. This doubles the power consumption and halves the pulse width, and should make it more noise resistant. Importantly, it also makes the pulse more symmetrical. -- not quantifiedI finished the firmware for my "self learn mode", where, for the first second after power up, it builds an average of the pulse width before firing the MOSFETS. It continues to "learn" and adjust the average, but it's a slow rolling average. Reduces noise.For debugging I am now outputting a digital edge when the pic's schmitt triggers detect the soft pulse (ie when the interrupt fires). This is just to learn about where those threshholds are and to understand the symmetry. That output is in the scope shots below.I discovered that the symmetry is not identical for the rising and falling edges. Not much I can do about that with the current setup. But I am still well within target ZCD accuracy. (I am getting with within 25-30us either side of the true zero, or 2.5-3V in the vertical).Scope shots below. One of rising, one for falling.Traces are:Blue: the raw LV signal from the AC Optocoupler -- with 22k resistors on the HV sidePink: The AC mains lines via a HV diff probe -- note the 5V / div vertical scaleGreen: Moment the rising and falling edge interrupts for the optocoupler input fire in the pic -- shows us the schmitt trigger hysteresisYellow: Fire trigger -- ideally this would be at same time that pink crosses zeroResults/Stats: The FRFF and FRFR meausurements are the ones to focus on. They are the delay between the zero cross of the pink AC mains signal and the positive edge of the yellow fire trigger.Summary: avg of 30us early on falling AC mains edge, avg of 23us late on rising AC mains. The std dev of those is just 1.5us. So if it weren't for the rising/falling edge asymmetry I could probably get a lot closer. The firmware is triggering at 30% between 2 green edges, which is a compromise for rising and falling AC mains.Dave would say: "Good enough for Australia".... (and certainly for my application: YMMV)

author: BrianHG
author_rank: Super Contributor
timestamp: August 13, 2020, 02:51:13 pm
content: Quote from: oschonrock on August 13, 2020, 12:07:16 pmNow, if your optocoupler had a 10ua input drive current instead of a 5ma drive current, digitally cleaned on the mains side triggered at the mains crossing a <2v threshold, how narrow and accurate could you make that crossover window with even a 1 megaohm series resistor feeding that input from the mains...

author: schmitt trigger
author_rank: Super Contributor
timestamp: August 13, 2020, 03:25:47 pm
content: "Good Enough for Australia" Sounds like a Foster's beer commercial.Now seriously. I applaud the microcontroller companies making a lot of effort integrating many ancillary functions within a package. I am old enough to remember having to employ external UART chips, but I am a stickler for safety, and also recommend the optocoupler approach when connecting a powerline to a microcontroller port.It will not only provide a safety barrier during normal operation, but most importantly, during a powerline fault.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 13, 2020, 04:53:07 pm
content: Quote from: BrianHG on August 13, 2020, 02:51:13 pmNo. Have you checked the max/min forward voltage spec? I am not sure you have understood how this circuit actually works.Should I put a step down transformer in there too for some nice Australian "phase shift sauce"?

author: oschonrock
author_rank: Regular Contributor
timestamp: August 13, 2020, 05:02:09 pm
content: Quote from: schmitt trigger on August 13, 2020, 03:25:47 pmQuote from: schmitt trigger on August 13, 2020, 03:25:47 pmYeah. That feature is only good for a tiny pcb which "floats high" and is totally enclosed. It's valid for that. Anything else = unsafeWhat I don't like, is that Microchip are not actually explicit about this problem in their Application notes etc. So, inevitably, what do you get? A whole bunch of hobbyists who wire the ZCD straight to the mains and think that's OK.....

author: BrianHG
author_rank: Super Contributor
timestamp: August 13, 2020, 07:59:49 pm
content: Quote from: oschonrock on August 13, 2020, 04:53:07 pmEverything will work fine.When your ac source is above 1.5v, the mcu output side will be high.When your ac is below 1.5v, your mcu output side will be low.The control input is already diode clamped in both directions.That data input tied to the mains hot and through a 330k resistor with a 100pf to 1nf cap to the GND1 where the mains neutral is connected. That input's protection diodes will be pushed to +/-1ma max and the cap will remove any spikes during the transition.The mains hot will also go through a 100k resistor -> 1N4007 diode -> VCC1 which has a 3.3v zener diode & 10uf cap in parallel with GND1 creating a regulated 3.3v supply capable of sustaining the required 1ma during both phases.That's your input phase detector.Only a +1.5v offset of error.No transformer.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 15, 2020, 06:58:52 pm
content: Quote from: BrianHG on August 12, 2020, 07:37:24 pmI received a little isolation transformer in the mail yesterday, which I had ordered just to try out just how much phase shift you get, for the benefit of others who are considering this option.The results are not authoritative for anything except this exact transformer and the load which I applied. It may be that more suitable transformers are available which introduce less error. So YMMV, do your own measurements. But it's probably fair to say that before looking seriously at trying to zero cross detect on the LV side of a transformer that you should be aware that asignificant amount of phase shift may exist and that this varies significantly with loadThis is the transformer used:Myrra 44049, Isolation Transformer, EI 30 x 10.5, 1 VA, 6V, 167 mA, 1 x 230V, PCB MOUNTED 44xxx Serieshttps://uk.farnell.com/myrra/44049/transformer-6v-1va/dp/1689041I just hooked it up to 230V 50Hz and measured mains (via HV diff probe) at the input as well as the LV output on the scope. I have no way of determining whether the HV probe introduced phase shift. I would hope not, it's a 100Mhz probe. Screenshots below.Summary:The LV outputleadsthe HV by ~ 300uS. Or about 6 degrees of phase angle. At no load.If I apply a 22Ohm resistive load (roughly rated load, a bit over actually, ooops) the phase shift reduces to only about 1.1degrees or 65us.These are not huge figures, but the fact that they vary both with specific transformer and with load, by ~ 250us (or 25V in the vertical, see above) means that will need calibrating out. This is a manual calibration as it cannot be estimated with pulse width averaging or similar. And then it still varies with load...

author: schmitt trigger
author_rank: Super Contributor
timestamp: August 15, 2020, 07:17:48 pm
content: The primary current is the *vector sum* of both the reflected load current and the core magnetization current.The latter current is not only phase shifted but has considerable distortion.When that current flows thru the primary winding resistance, it will cause a voltage drop which is vector subtracted from the mains applied voltage.What you require to do is that the magnitude of the primary reflected load current to be much larger than the magnitude of the magnetization current, such that its contribution dominates.In practical terms:Procure yourself a small, 1 or 2 watt transformer, and load it to its full rated current with a resistor. Do not use this transformer to also obtain a rectified DC.Of course, if you can obtain a transformer with a higher rated primary than the applied voltage, it is even better, as the flux density is reduced. I live in a 120v country and use 240v primary transformers with good results.

author: oschonrock
author_rank: Regular Contributor
timestamp: August 15, 2020, 07:20:57 pm
content: Quote from: schmitt trigger on August 15, 2020, 07:17:48 pmYup spot on! As per link above to the stackexchange answer which has the full transformer equivalence model, so you can do the maths -- get your complex number calculator out. Luckily I still have mine from Uni days -- or just use spice and friendsPersonally, I would not do this for zero cross detect. Just a whole bunch of unknowns / variables and a bunch of heavy copper and iron, which I have to keep warm, for nought.... . Even for the "ideal case" of a "fully, resistively loaded 1VA transformer" above, I am still getting 50us of shift which I know nothing about when sensing on LV side. So this is purely additive with the detection errors. Just less accurate...

author: oschonrock
author_rank: Regular Contributor
timestamp: August 15, 2020, 08:03:10 pm
content: Quote from: BrianHG on August 13, 2020, 07:59:49 pmNow we can see what you are suggesting is basically one of these "sub 10 component trigger circuits".And therein lies the problem. Why is no one else triggering at 1.5V? Everyone goes for about 10V+ and a pulse width between 100us and 1ms and takes the mid point. Why?David Hess put it very simply above. The mains are noisy. If you put a super low voltage triggering and super fast optocoupler in there. It may well trigger multiple times..all over the place. Then you need to LP filter that....blah blah. I haven't drawn up your proposed circuit, but just from following the words it sounds like this would trigger on positive cycle only? Ie I only get one edge. So no pulse width averaging? Maybe not needed but given the spread but given the noise issue, might have allowed some safety reject logic...again, more complications.Basically the AC optocoupler is very very simple, robust, resilient and plenty accurate enough for my application, with minimum component count. YMMVAnd just to be clear and honest Brian. I stopped listening to you, when you became insulting:Quote from: BrianHG on August 13, 2020, 02:21:09 amYou have made multiple incorrect and poorly thought through suggestions on this thread. So please think about who you talk down to....As we say in EnglandRespectfully yours

author: BrianHG
author_rank: Super Contributor
timestamp: August 15, 2020, 09:05:37 pm
content: Quote from: oschonrock on August 15, 2020, 08:03:10 pmThe AC optocoupler turns on and off an LED based on current in the LED, not voltage. It works by the voltage going though a resistor illuminating the LED strong enough for a 'transfer' to the detector side of the optocoupler. This only shows a small window opening while the LED doesn't have enough current to shine bright enough to drive the photo-transistor. This also doesn't tell you the current AC phase which might be useful.The opto-isolator part and connection example I recommended goes high when the AC phase goes effectively above 1v into the positive, and goes low when the AC phase goes below 1v down into the negative. The optional 100pf cap will do a little cleaning, but I cannot imagine the design messing up or getting noisy as this is so close to the 0 transition point, really bad noise from loads like light dimmers and switching supplies occur above or below this voltage window where it is too late on the digital output transition has already taken place.Make no mistake, instead of the data isolator, you can use a RE1C002UN or SSM3K35AMFV (mosfet 1vgs switch on) or equivilant small signal mosfet & diode protection clams on it's gate input & using it's Drain to drive a normal optocoupler's led & you would get similar results.You would still need a RE1C002UN or SSM3K35AMFV (mosfet 1vgs switch on) , 6N137 or equiv, 1N4007 diode, a 5v zener diode, a 22k resistor for powering the zener, a 470k resistor to drive the gate, a 1k ohm resistor to drive the optocoupler LED at ~4ma, 1 47uf 6.3-16v cap, a BAT54S double diode for gate clamp protection, and an optional 100-1000pf cap for the AC line filter tied to gate & GND. That's 9 components.All components are bottom end cheap ones.The data isolator part count is 6 components, however, the data isolators cost much more alone than the 9 components listed above.