I'm not sure, but this may already have come up on the list. If so
please direct me to the archive and I will look there. However, any
ideas would be great full.
What I will be having to do is synchronize to the incoming AC. To do
this I will have to detect RMS voltage, Detect the zero crossing,
generate the sine wave reference and then synchronize to the line.
Any ideas on detecting the zero crossing?À I want to do it software not
hardware. I've already done it in hardware using 2 pins on the micro.
I want to do it with 1 pin now.
John Bellini
Product Development, Firmware Technologist
How about this....run the thing as fast as you can.
Count the number of tics between cycles, then divide in half. Or does
the PIC detect at the 90 phase? If I remember right, it looks at the
full cycle. In fact, you should be able to calculate the number of tics
(knowing the clock and the frequency of the AC), and find a edge and
count the number of clocks till you get there.
I'm not sure, but this may already have come up
on the list. If so
please direct me to the archive and I will look
there. However, any
ideas would be great full.
What I will be having to do is synchronize to
the incoming AC. To do
this I will have to detect RMS voltage, Detect
the zero crossing,
generate the sine wave reference and then
synchronize to the line.
Any ideas on detecting the zero crossing?À I
want to do it software not
hardware. I've already done it in hardware
using 2 pins on the micro.
I want to do it with 1 pin now.
John Bellini
Product Development, Firmware Technologist
Harrison Cooper wrote:
>
> How about this....run the thing as fast as you can.
> Count the number of tics between cycles, then divide in half. Or does
> the PIC detect at the 90 phase? If I remember right, it looks at the
> full cycle. In fact, you should be able to calculate the number of tics
> (knowing the clock and the frequency of the AC), and find a edge and
> count the number of clocks till you get there.
The only problem with this approach is that you're somewhat susceptible
instantaneous deviations in the voltage. However, you can average
consecutive runs to help filter this kind of noise.
A digital phase lock loop is (sometimes) a better approach. Perhaps
someone else will care to explain digital PLL's in more detail?
Essentially though, you vary your sample rate until the tone you're
sampling matches the frequency of an internally generated tone. In my
experience (not on a PIC), you have to be VERY careful on how you vary
the sampling rate. I'm sorry for being vague, but this is not a very
easy subject (for me) to explain.