Zero crossing detector circuits - Page 1
Forum section: electronics / projects

author: knotlogic
author_rank: Regular Contributor
timestamp: July 13, 2017, 02:06:28 am
content: I need a zero crossing detector for a project I'm working on, and came acrossthis designmentioned here on EEVblog. I think I understand the basic operation of the circuit, but what I don't get is the advantages over directly hooking up the optoisolator input to the AC source, like in the attached image*. Is it just a matter of power consumption? (And an inverted polarity to the output pulse, but that doesn't matter to me.)* There are also optoisolators with crossed input LEDs, which I could use without the diode bridge I assume.

author: Circlotron
author_rank: Super Contributor
timestamp: July 13, 2017, 02:14:35 am
content: A good opto needs slightly more than 1mA to drive it on. Given that that needs to happen not too far from the zero crossing, the series resistor would need to be a relatively low value. This will add up to dissipation problems if the circuit is directly across the AC mains.

author: georges80
author_rank: Frequent Contributor
timestamp: July 13, 2017, 02:52:47 am
content: Yep, power dissipation, especially at 110VAC and worse at 240VAC is the issue with the 'simple' zero crossing circuit.The dextrel circuit (in the link) works very well and draws insignificant power which is significant if you want to reduce standby power in your product. You can enter the design into ltspice and then tweak values to reduce consumption even more and verify performance from say 80V (brownout 110VAC) to 270VAC for full range operation. You can also use ltspice to 'inject' noise into the circuit to see how it deals with nearby noise injection from things like microwave ovens, furnace igniters and other household items that can share a common mains feed.cheers,george.

author: knotlogic
author_rank: Regular Contributor
timestamp: July 13, 2017, 03:29:39 am
content: Thanks guys!*sigh* learning LTspice has been on my "to do" list a long time now, but I just haven't been able to get round to it. Soon. Maybe....I'm actually planning to use the detector at 48 VAC (or maybe 24 VAC), so I think I may have to tweak the values. Potentially R1, R2 and R4. Some questions though:Should C2 be a class X capacitor? Seeing as how it's lying across the mains. And does C1 have to be an electrolytic as it is in the dextrel circuit?Also, are there any specific diode types I should look at for D1-5?

author: floobydust
author_rank: Super Contributor
timestamp: July 13, 2017, 03:38:48 am
content: Hooking the opto to the input source (mains) has the advantage of no phase-shift error.If you connected this circuit on the secondary of a power transformer, your zero-cross signal would be delayed.The Dexrel circuit, I would use 1/4W resistors instead of 1/8W resistors, as their voltage rating is low to tolerate mains overvoltages.In a commercial product, these are flameproof/fusible parts.Edit: also 1N4148's are only 100PIV.

author: knotlogic
author_rank: Regular Contributor
timestamp: July 13, 2017, 05:18:41 am
content: Quote from: floobydust on July 13, 2017, 03:38:48 amHmm, but that would depend on the implementation, yes? In my case I'm planning to drive a resistive heater off 48 or 24 VAC, and implement pulse skipping to control it. So everything on my circuit would hang off the secondaries - zero cross detect and driving SSR. The only things I can think of that would go on the primary side are a fuse and a X/Y capacitor setup.I just realised that if I am going to run this of 24 VAC, it's possible I could get away with just using an optocoupler direct, though power consumption would still be higher than in using that circuit at 240 VAC! Another option to consider I suppose.

author: floobydust
author_rank: Super Contributor
timestamp: July 14, 2017, 03:17:07 am
content: I wasn't sure if your heater was mains powered. As long as the zero-cross detect is on the power to the SSR, so there is no phase (shift) error from a power transformer.I find resistive heaters do not need phase-control as you mention just pulse-skipping works good.At 24VAC it's much easier, you may not even need an optocoupler.

author: RoGeorge
author_rank: Super Contributor
timestamp: July 14, 2017, 07:28:33 am
content: If you want to make a zero cross detector, this is a good and tested one:http://www.dextrel.net/diyzerocrosser.htmAlso, there are optotriacs with internal zero cross detector, this is the recommended solution:https://electronics.stackexchange.com/questions/161133/why-do-we-prefer-zero-crossing-optotriacs-for-driving-triacs

author: Ian.M
author_rank: Super Contributor
timestamp: July 14, 2017, 07:55:48 am
content: If you are using an opto-TRIAC with internal ZC detection for heater power control, you still need a mains frequency reference as its advisable to keep the number of positive and negative half cycles skipped balanced to avoid a net DC current in the transformer secondary. However you don't need a true ZC detector feeding the MCU or controller, as all you need to do is make sure the command pulse to turn the TRIAC on roughly overlaps the zero crossing.If the control circuit is fed by a bridge rectifier, simply tap one of the AC terminals of the bridge via a series resistor and 4.7V Zener clamp, with a small capacitor across it to form a low pass filter, then put it through a comparator or Schmitt triger input gate to get a logic level mains frequency approximate squarewave, with a rising edge slightly after the zero crossing and a falling edge slightly before the next one (or possibly slightly after it, depending on the RC time constant). If your MCU has Schmitt trigger or comparator inputs this is a very easy way to get a suitable 50Hz or 60Hz reference signal.

author: KL27x
author_rank: Super Contributor
timestamp: July 14, 2017, 08:02:03 am
content: The zero crossing circuit in a Hakko 888 iron is a simple transistor. (Hakko decided to use a -5V rail for the logic circuitry, so it's actually a PNP, but I will reverse everything for sake of explaining it).Basically it's just NPN transistor with 3k pullup on the collector (which is the output), emitter directly grounded. 47K base resistor to the 26VAC. And a diode between base and emitter/ground, so that when the base voltage is negative, current is blocked. Well, it's diverted to the ground, instead of the base.At one point while playing with this board, I lost my zero crossing signal and thought I had burned out this transistor. I replaced it with 3906, and that worked fine, too (after fixing the real problem which was a bridge between the output of this signal and the -5V rail... which also explained the 60Hz ~1V dip that appeared on the Vdd... the original transistor still worked, lol).The signal is not perfectly symmetrical nor exactly at zero, but is plenty close enough to fire the TRIAC in time. For my app, I just synced my micro off only the one direction.

author: knotlogic
author_rank: Regular Contributor
timestamp: July 14, 2017, 08:17:47 am
content: Quote from: floobydust on July 14, 2017, 03:17:07 amUm, yes, I did forget to mention how everything was meant to be hooked up earlier.For this application I'm trying to keep the EMI as low as possible, so I'd like to avoid phase control if I can. I was actually initially going to use PWMed DC, but ran into some hiccups with the available heaters.And unfortunately for me, it's more likely I'm looking at 48 VAC.I think I'm going to have questions about how others implement pulse skipping. It occurs to me that with 8-bits at even 60 Hz, a "cycle" takes over two seconds. I'm wondering how the DIY soldering iron folk do it.Quote from: Ian.M on July 14, 2017, 07:55:48 amThanks for the pointers. I actually haven't looked at how I'm powering the control circuit yet. If i end up using 48V, running a linear reg off of that sounds like an ugly solution.I've had a go with LTspice, and have come up with a simulation that appears to do what I think it should. (Attached) If anyone wants to take a look, let me know if I've done anything silly with it...

author: Ian.M
author_rank: Super Contributor
timestamp: July 14, 2017, 09:32:50 am
content: Your sim looks plausible - I see you probably got the circuit from:Quote from: RoGeorge on July 14, 2017, 07:28:33 amIts going to need some serious tweaking to get it to work well from 24V or 48V RMS.You can improve its realism by adding the following models as a spice command, and changing the type of D6 to LED0.Code:.model D ako:1N4148*Typ IR LED from optocoupler: Vf=1.2V @10mA.model LED0 D (IS=1p N=1.999644 RS=0 BV=6 IBV=10u+ CJO=10p EG=1.424 TT=500n)For the control circuit PSU issue, well it depends how low power you can make it. If you only need 10mA @5V, a half wave rectifier from your 48V RMS secondary, feeding a split resistive dropper with a decoupling cap in the middle of it to get rid of the worst of the ripple, then a 5.1V Zener or shunt regulator will only dissipate about 600mW. Replace the first resistor with a 2.2uF non-polar capacitor driving a two diode charge pump feeding the decoupling cap and you can get the dissipation down to under 100mW.10mA is plenty for an 8 bit MCU if you keep the clock speed reasonable and for a bare glass LCD although its probably not enough for a LED display. As the DC supply has its 0V rail in common with one end of the transformer winding, you can drive a sensitive TRIAC direct from the MCU with no optocoupler. If you need more gate current than the 10mA PSU and MCU pin can provide, use an emitter follower off the unregulated DC decoupling capacitor but keep the duty cycle of the firing pulse train low so it doesn't brown out the MCU by dropping the unregulated voltage too low.Getting a good ZC input with a half wave rectified PSU is a little trickier. The best option is a resistor from the hot end of the secondary feeding the base of a NPN transistor, with an anti-parallel B-E diode to protect it on negative half cycles, and the collector pulling down the MCU input. That will give you a squarewave at the line frequency with both edges very close to the zero crossing points.

author: knotlogic
author_rank: Regular Contributor
timestamp: July 14, 2017, 12:44:56 pm
content: Quote from: Ian.M on July 14, 2017, 09:32:50 amYep.Actually I did mention that in the first post.Quote from: Ian.M on July 14, 2017, 09:32:50 amActually, I think I got lucky using 55k for R1 and R2, and 200r for R4. I think C1 could use 4.7u, but I was playing around and will need to recheck that. That's all for a 48 VAC circuit. I'll need to use actually available values of course. And I haven't yet tried the diode model you suggested. Also, it might benefit slightly from a tiny bit larger value for C2, but that might get swallowed by tolerance values.Quote from: Ian.M on July 14, 2017, 09:32:50 amHow do I fit that in? Place it somewhere in the .asc file?Quote from: Ian.M on July 14, 2017, 09:32:50 amThanks. I really need to look at all that - most of the half wave recitified circuit you described went right past me.Current plan is that the controller and heater will be in a headless box, and I'll have to pipe the status to elsewhere.

author: Circlotron
author_rank: Super Contributor
timestamp: July 14, 2017, 01:14:12 pm
content: Quote from: KL27x on July 14, 2017, 08:02:03 amThat would be a great ZCD for a heater application. When the collector goes high, generate a triac trigger pulse that lasts for 1.5 AC half cycles and that's it! The cct always triggers from the same polarity and with that trigger length you will always have a whole number of cycles to the load. End of story.

author: Ian.M
author_rank: Super Contributor
timestamp: July 14, 2017, 01:59:02 pm
content: There's a button near the right hand end of the LTspice toolbar to add a SPICE command to a schematic. Put the command(s) into the text box of the resulting dialog, click OK, then click to place it on the schematic.Try the attached circuit for a 5V 10mA PSU linear PSU from 48V RMS that only dissipates 120mW (less load dissipation). if you need a more accurate and stable 5V, replace the Zener with a TL431 shunt regulator and use a pair of 10K 1% resistors as the potential divider for its ref input.N.B. the charge pump acts as a current source, so the key to low dissipation is to make the dropper resistor small. OTOH a smaller resistor increases the output ripple.