Electronics > Projects, Designs, and Technical Stuff
Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler
oschonrock:
--- Quote from: David Hess on August 13, 2020, 03:48:17 am ---How accurate does your phase measurement need to be?
--- End quote ---
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)
BrianHG:
--- Quote from: oschonrock on August 13, 2020, 12:07:16 pm ---
--- Quote from: David Hess on August 13, 2020, 03:48:17 am ---How accurate does your phase measurement need to be?
--- End quote ---
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
--- End quote ---
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...
schmitt trigger:
"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.
oschonrock:
--- Quote from: BrianHG on August 13, 2020, 02:51:13 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...
--- End quote ---
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"?
oschonrock:
--- Quote from: schmitt trigger on August 13, 2020, 03:25:47 pm ---"Good Enough for Australia" Sounds like a Foster's beer commercial.
--- End quote ---
;D
--- Quote from: schmitt trigger on August 13, 2020, 03:25:47 pm ---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.
--- End quote ---
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.....
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version