• AVR Freaks

Hot!ZCD with PIC 18LF45K40

Author
saiprasad1996
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2019/04/05 00:10:09
  • Location: 0
  • Status: offline
2019/04/06 03:46:18 (permalink)
0

ZCD with PIC 18LF45K40

I want to implement phase angle control for a single phase ac fan. To achieve that we need a ZCD circuit interfaced with a microcontroller to get a pulse at zero crossing. As our circuit has some space constraints, we have implemented the same using PIC 18LF45k40 which has built-in ZCD circuitry which generates pulses at Zero Crossing. Below is the circuit for implementing zcd- PIC ZCD implementation circuit

The above circuit is referenced from Technical Brief document - Link here

As you can see, the circuit has a common ground with the AC Neutral which makes the circuit bit questionable as the whole circuit has to be treated as live and raises safety concerns. (Please correct me if I'm wrong)

Putting the above concern apart, the problem I'm facing is the pulses generated from microcontroller is not stable. It swings in the x-axis(time) in the oscilloscope. The code for generating pulse is as follows -

void __interrupt() ZCD(void)
{
if(ZCDIE && ZCDIF)
{
LATA1 = 1;
enableTimerInterrupt();
ZCDIF = 0;
}

if(TMR0IF)
{
TMR0IF = 0;
counter++;
if(counter==switchingValue)
{
counter=0;
disableTimerInterrupt();
LATA1 = 0;
__delay_us(200);
LATA1 = 1;
}
}

}
The ZCD Input when the ground is not connected with neutral is a plain DC line. When the ground is connected with Neutral, sine wave superimposes on the DC line as shown below-

DC voltage

The ZCD in pin gets the following waveform when neutral and dc ground are common -

ZCD In

Following are my questions -

1 - Is the ZCD waveform expected this way? There is a very limited resource available on this issue.

2 - The below is the circuit which I've implemented for Zero Crossing. Is this circuit safe and practical?

ZCD Circuit

Triac circuit -

Triac Circuit

3 - Please go through the code and let me know the issue.

4 - Please suggest any circuit or app note which implements the zcd.
#1

2 Replies Related Threads

    richardandrews23
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2018/01/18 14:53:01
    • Location: 0
    • Status: offline
    Re: ZCD with PIC 18LF45K40 2019/04/08 09:56:04 (permalink)
    0
    Unfortunately there are no pictures to accompany your text but you are correct that there is a big safety issue! In similar circumstances I would use a transformer to bring the voltage down to 30Vac or so with one end of the transformer secondary safely grounded. That way you can investigate and debug your circuit safely before scaling it back up to full mains voltage.
    #2
    jack@kksound
    code tags!
    • Total Posts : 3183
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: ZCD with PIC 18LF45K40 2019/04/08 10:23:34 (permalink)
    0
    It swings in the x-axis(time) in the oscilloscope.

    How much "swing"?. The data sheet talks about differences in ZCD timing for rising and falling slopes of sine wave inputs. Is this what you are experiencing or more random variations? Also have you taken variations in interrupt latency into account?
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5