News:

;) This forum is the property of Proton software developers

Main Menu

Zero Cross Detection peripheral or diode rectifier and interrupt pin?

Started by trastikata, Jan 01, 2023, 10:19 AM

Previous topic - Next topic

trastikata

Do you see any advantage of using the ZCD module over a simple diode bridge and any interrupt pin?

shantanu@india

Never used a PIC with ZCD module. Always used to connect the A. C mains(230V) directly to the IOC pin through a 2.2MOhms series resistance for phase control of triac. Never malfunctioned or burnt off due to overvoltage.
PICs are rugged enough to work in live potentials without isolation.
Regards
Shantanu

tumbleweed

It would be good to read both of these app notes from Microchip.
They discuss some of the pitfalls of IO pin abuse and using the ZCD.

TB3013 https://ww1.microchip.com/downloads/en/AppNotes/93013a.pdf
TB3138 https://ww1.microchip.com/downloads/en/AppNotes/90003138A.pdf

trastikata

Quote from: tumbleweed on Jan 01, 2023, 01:28 PMIt would be good to read both of these app notes from Microchip.
They discuss some of the pitfalls of IO pin abuse and using the ZCD.

Thank you tumbleweed but those are not really pertaining to my question.

As I said I've been using so far bridge rectifiers without smoothing capacitors, tailored to one of the interrupt pins and this works flawless in theory and in practice - simple and elegant solution.

I only recently paid attention to the ZCD module and as far as I understand, the ZCD module only generates an interrupt flag but has no other special registers.

There I thought the ZCD interrupt can be used as automatic trigger for other peripherals for example HPM or ADC etc but it seems not to be the case and only spares the need for an external bridge rectifier?


Ivano

I did some tests at the beginning of December with zcd with some problems perhaps due to the flying connections but I didn't go deeper.
This peripheral did not excite me, in any case you must always use the bridge
This is the link

https://protoncompiler.com/index.php/topic,1409.msg10873.html#msg10873


ken_k

I have always used BAT-54S diodes and a suitable input resistor as suggested in one of the links tumbleweed posted. With about 100uA (limited by Rin) the pic input pin should normally see +/- < 250mV beyond the supply rails to the pic.

For absolute galvanic isolation from the input signal I would try one of the low input current optocouplers with back to back LED's on the input, each LED clamps the input voltage for the other. The device will zero cross detect an AC input with no bridge or diodes and provide absolute protection for the microcontroller.
IXYX LDA100 is an example of this class of device.
https://www.ixysic.com/home/pdfs.nsf/0/E6593A46E1DC6DA985256A2C0069199A/$file/Lda100.pdf



ken_k

Off topic as allways.
A spice file of a two LED optocoupler could not be found so a sim was created using a standard sensitivity cheap optocoupler with a diode bridge on the input do demonstrate function. Legally compliant isolation from the mains can easily be obtained.
 ZCD opto schem.png

waveforms opto PIC input.png

ZCD opto.txt   

Change ZCD opto.txt  to ZCD opto.asc to run spice

The first trace is 240VAC input, the second trace is the voltage TP_A to TP_B note the voltage is clamped so low voltage diodes are fine, the third trace shows the pic 5V supply and the pic input waveform, any voltage micro could be used, obviously this would work better with a more suitable optocoupler. Placing R2 in the emitter of the optocoupler will reverse the polarity of the output, the output will drop to zero volts at the zero crossing point.
BTW do all these sims annoy people? Its a bit hot to be out in the garden working.

ken_k

Two optocouplers give a better "OFF" to the input LED's as they are reverse biased about 1 volt, the AC input optos do this by default. Once again change *.txt to *.asc

Tried working in the garden and overheated! back to back ZCD opto.txt

Yasin

I would recommend. Using a bidirectional opto element like PC814 makes D1,D2,D3,D4 unnecessary.

ken_k

Quote from: Yasin on Jan 02, 2023, 09:18 AMI would recommend. Using a bidirectional opto element like PC814 makes D1,D2,D3,D4 unnecessary.
You are correct.
I recommended using an AC input optocoupler (see link) in post # 6, I did the simulation with standard opto's as I could not find a model for a low current AC optocoupler, the two simulations demonstrated function.

ken_k

Hi this is a very crude simulation in LTspice of an AC input optocoupler used when one is too lazy to create a proper model.
It features a very crude LED model and some behavioural current sources feeding a NPN transistor. This may be of some benefit to newbies learning spice.
In reality one should make a proper spice model, sometimes an approximation will do.
Purchasing a low input current AC input opto is the best option if no model from the manufacturer is availiable.

Experiment ZCD.png

experiment ZCD opto.txt

change *.txt to *.asc to run spice


trastikata

Thank you all for the replies. We are going a bit off topic, it's not question of isolation rather functionality - here's what my point is for the devices I had in mind:

- ZCD module only generates an interrupt flag, from there the ISR has to take over,

 whereas

- The Bridge-Interrupt pin configuration allows to directly chain hardware triggers for Timers and PWM.

So I was surprised to see that the ZCD module is more an advertising trick for additional functionality than real hardware acceleration for Zero Cross Detection implementations.

tumbleweed

Depending on the device, the ZCD output can control various timer functions or be used as an input to the CLC modules where you could do pretty much any function with it.

It also gives you better control over the trigger point vs a TTL logic input.

HAL

Hello Ken

The sims are great.  I don't see how anyone could find them annoying.  There should always be time for a short trip slightly off topic...  Some of the trips prove quite interesting.   ;) 

Regards
Hal