Electronics > Projects, Designs, and Technical Stuff
Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
oschonrock:
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?
Ian.M:
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.
oschonrock:
--- Quote from: Ian.M on August 12, 2020, 12:58:22 pm ---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.
--- End quote ---
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.
NiHaoMike:
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.
oschonrock:
--- Quote from: NiHaoMike on August 12, 2020, 01:07:26 pm ---You can sense from line to ground, using a string of resistors that satisfies isolation requirements.
--- End quote ---
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.
Navigation
[0] Message Index
[#] Next page
Go to full version