Author Topic: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler  (Read 8268 times)

0 Members and 1 Guest are viewing this topic.

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
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 178 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.pdf

It 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 those
  • It 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 still

As opposed to the AC Optocoupler technique, which has these advantages:

  • Much higher level of isolation

Note that 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?



« Last Edit: August 12, 2020, 12:55:22 pm by oschonrock »
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 13218
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 a PIC12F1612 on 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.
 
The following users thanked this post: oschonrock

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
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 a PIC12F1612 on 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.

Thanks 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.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9323
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
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.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
You can sense from line to ground, using a string of resistors that satisfies isolation requirements.

Thanks, 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.
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9323
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Ground, not neutral.
Cryptocurrency has taught me to love math and at the same time be baffled by it.

Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
 

Offline Alti

  • Frequent Contributor
  • **
  • Posts: 404
  • Country: 00
I am doing AC mains zero cross detection for this project
IMHO 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?
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Ground, not neutral.

OK, 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?
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
I am doing AC mains zero cross detection for this project
IMHO 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.

Right.

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.
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8275
  • Country: ca
    • LinkedIn
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.
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #10 on: August 12, 2020, 08:07:01 pm »
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.

Yeah, 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/1689041

That 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.
« Last Edit: August 12, 2020, 08:32:14 pm by oschonrock »
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8275
  • Country: ca
    • LinkedIn
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #11 on: August 12, 2020, 08:33:54 pm »
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.
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #12 on: August 12, 2020, 09:01:07 pm »
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.

Sorry 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/213363

I 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.
« Last Edit: August 12, 2020, 09:33:33 pm by oschonrock »
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8275
  • Country: ca
    • LinkedIn
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #13 on: August 12, 2020, 10:42:11 pm »
Just use a 6N137 with a reverse polarity protection diode and do not talk about any delay.
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #14 on: August 12, 2020, 10:56:16 pm »
Just use a 6N137 with a reverse polarity protection diode and do not talk about any delay.

More 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 that

So 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

 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8275
  • Country: ca
    • LinkedIn
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #15 on: August 12, 2020, 11:44:00 pm »
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.
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #16 on: August 13, 2020, 12:25:18 am »
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.

The 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.


 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8275
  • Country: ca
    • LinkedIn
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #17 on: August 13, 2020, 02:21:09 am »
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.

The 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.

If 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.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 17429
  • Country: us
  • DavidH
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #18 on: August 13, 2020, 03:48:17 am »
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.
 
The following users thanked this post: Ian.M

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #19 on: August 13, 2020, 07:46:45 am »
Thank you David.

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?

You 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) , where   

A=sqrt(2) * 230 =  325V and
w (angular frequency omega) = 2 * pi * frequency = 314.159 rad/s

Its 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.

For a really accurate zero crossing measurement, the noise needs to be removed however sharp filters will create phase errors themselves.

Spot on, yes, filtering is a double edged sword. Similar to step-down transformers. They introduce new delays / phase shifts.

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.

Hadn'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?


« Last Edit: August 13, 2020, 09:47:17 am by oschonrock »
 
The following users thanked this post: Ian.M

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #20 on: August 13, 2020, 12:07:16 pm »
How accurate does your phase measurement need to be?

I 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 quantified
  • I 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 side
  • Pink: The AC mains lines via a HV diff probe -- note the 5V / div vertical scale
  • Green: Moment the rising and falling edge interrupts for the optocoupler input fire in the pic -- shows us the schmitt trigger hysteresis
  • Yellow: Fire trigger -- ideally this would be at same time that pink crosses zero

Results/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)
« Last Edit: August 13, 2020, 05:10:46 pm by oschonrock »
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 8275
  • Country: ca
    • LinkedIn
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #21 on: August 13, 2020, 02:51:13 pm »
How accurate does your phase measurement need to be?

I 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. More importantly it makes the pulse more symmetrical. -- not quantified
Now, 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...
« Last Edit: August 13, 2020, 03:05:00 pm by BrianHG »
 

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2431
  • Country: mx
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #22 on: August 13, 2020, 03:25:47 pm »
"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.
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #23 on: August 13, 2020, 04:53:07 pm »
Now, 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...

No. 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"?
« Last Edit: August 13, 2020, 04:56:18 pm by oschonrock »
 

Offline oschonrockTopic starter

  • Regular Contributor
  • *
  • Posts: 67
  • Country: gb
Re: Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
« Reply #24 on: August 13, 2020, 05:02:09 pm »
"Good Enough for Australia" Sounds like a Foster's beer commercial.

 ;D

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.

Yeah. That feature is only good for a tiny pcb which "floats high" and is totally enclosed. It's valid for that. Anything else = unsafe

What 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.....
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf