Electronics > Projects, Designs, and Technical Stuff

Mains zero cross detect alternatives - pic18 ZCD vs AC input optocoupler

<< < (3/7) > >>

oschonrock:

--- Quote from: BrianHG on August 12, 2020, 07:37:24 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.

--- End quote ---

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.

BrianHG:
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.

oschonrock:

--- Quote from: BrianHG 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.

--- End quote ---

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.

BrianHG:
Just use a 6N137 with a reverse polarity protection diode and do not talk about any delay.

oschonrock:

--- Quote from: BrianHG 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.

--- End quote ---

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

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod