• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Damage to PIC16F18856 by doing mains zero cross detection with its ZCD module?

Status
Not open for further replies.

Flyback

Well-Known Member
Hello, Will we potentially damage our PIC16F18856 by setting it up to do mains zero crossing detection as in the attached schem?

We have a 40W offline , non-isolated LED lamp. We have a PIC16F18856 in it which has circuitry to do zero crossing detection (ie circuitry inside the micro itself) . Therefore, we set it up as in the attached schem to do mains zero cross detection.

However, we are not sure if this is OK?...after all, the Microchip datasheet and App Note examples never show mains zero crossing detection…but only show examples where the AC source that’s being “zero-cross-detected” has the same reference ground as the PIC16F18856.

……In our case, the AC source being “zero-cross-detected” is the mains, and obviously its not referenced to the same ground as the PIC16F18856.
Do you think we could potentially damage our PIC16F18856 by connecting up the PIC16F18856’s zero cross module in the attached shown way that we have?

My post on the microchip forum about the Zero crossing detector inside the PIC16F18856…
http://www.microchip.com/forums/m1006813.aspx

PIC16F18856 datasheet
(ZCD module on page 305 )
http://www.microchip.com/wwwproducts/en/pic16f18856

Microchip App Note on ZCD module….
http://ww1.microchip.com/downloads/en/AppNotes/90003138A.pdf
 

Attachments

alec_t

Well-Known Member
Most Helpful Member
Looks as though it should work, albeit with ~1.27 ms delay between actual zero crossing and it being detected.
 

dknguyen

Well-Known Member
Most Helpful Member
Your circuit seems really extravagant. I just don't see the point. Have you read this app note?
http://ww1.microchip.com/downloads/en/AppNotes/93013a.pdf

Can't you just use another pin with no analog features and add a couple of isolation capacitors for hot and neutral at the inputs of the regular current limiting resistor and diode clamp ZC circuit? Because the ZC peripheral seems to exist, not as an optimal solution for ZC detection, but as a workaround in case a user was cornered into needing to use an analog pin for ZC detection. Do you have no other choice of pins?

I attached some alternatives for use with a regular non-analog I/O . You could modify these circuits by replacing the capacitors at the input with an opto at the output for more safety. I tend to use the top version just because I don't like to rely on the threshold voltage of the digital input and it also clamps the voltage to a lower value, but requires more parts.
 

Attachments

Last edited:

Nigel Goodwin

Super Moderator
Most Helpful Member
Because the ZC peripheral seems to exist, not as an optimal solution for ZC detection, but as a workaround in case a user was cornered into needing to use an analog pin for ZC detection. Do you have no other choice of pins?
I would disagree, the ZCD has been added as a superior system, and there's never any reason to be 'forced' to use an analogue pin as they are all digital as well - the device in question also has PPS allowing you lot's of scope for moving pins to where you want them, plus all I/O can be analogue, digital (TTL or schmitt), have individual pullups, and loads of other options. The ZCD only requires a single resistor to operate, with the option of a single capacitor as well.
 

dknguyen

Well-Known Member
Most Helpful Member
I would disagree, the ZCD has been added as a superior system, and there's never any reason to be 'forced' to use an analogue pin as they are all digital as well - the device in question also has PPS allowing you lot's of scope for moving pins to where you want them, plus all I/O can be analogue, digital (TTL or schmitt), have individual pullups, and loads of other options. The ZCD only requires a single resistor to operate, with the option of a single capacitor as well.
By "forced" to use analog pins, I mean when all available digital-only pins have been consumed and the only pins remaining for zero-cross detection are analog-capable pins. It is irrelevant whether or not the pin itself has been set to digital or analog modes. What matters is that the pin is analog-capable because that means it has analog pass transistors present.

TB3138 specifically says that the ZCD was added in order to allow analog-capable pins to perform zero-cross detection, because the presence of analog pass gates does not lend itself well to the small overvoltages present in typical zero-cross clamping circuits, regardless of whether the pin itself has been set to digital or analog. It's not the mode that's been set to that matters, but it's capability.

Then TB3013 states that it is best to choose a digital pin whenever possible for overvoltages.
 
Last edited:

cmartinez

New Member
Hello, Will we potentially damage our PIC16F18856 by setting it up to do mains zero crossing detection as in the attached schem?

We have a 40W offline , non-isolated LED lamp. We have a PIC16F18856 in it which has circuitry to do zero crossing detection (ie circuitry inside the micro itself) . Therefore, we set it up as in the attached schem to do mains zero cross detection.

However, we are not sure if this is OK?...after all, the Microchip datasheet and App Note examples never show mains zero crossing detection…but only show examples where the AC source that’s being “zero-cross-detected” has the same reference ground as the PIC16F18856.

……In our case, the AC source being “zero-cross-detected” is the mains, and obviously its not referenced to the same ground as the PIC16F18856.
Do you think we could potentially damage our PIC16F18856 by connecting up the PIC16F18856’s zero cross module in the attached shown way that we have?

My post on the microchip forum about the Zero crossing detector inside the PIC16F18856…
http://www.microchip.com/forums/m1006813.aspx

PIC16F18856 datasheet
(ZCD module on page 305 )
http://www.microchip.com/wwwproducts/en/pic16f18856

Microchip App Note on ZCD module….
http://ww1.microchip.com/downloads/en/AppNotes/90003138A.pdf

Here's a far better ZCD circuit for your to consider, I've used it in the past and it's extremely reliable:

ZC-schema.gif
This circuit is not of my design, and it was posted in a page called www.drexel.net, which seems to be out of line now. Luckily, I had considered it relevant enough to save the image to my library before the page was put down.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top