[time-nuts] Building a mains frequency monitor

Graham / KE9H ke9h.graham at gmail.com
Tue Apr 12 11:04:24 EDT 2016


For all you Powerline Time nuts, and maybe GPSDO time nuts, too.

Consider this new PIC.    PIC16F1619
$1.60 USD, quantity one at Mouser.

It was designed to be an AC motor controller.

So has some interesting built in hardware peripherals:
    Mains Zero crossing detector.
    Runs up to 32 MHz master clock, which says you could time stamp with 8
MHz resolution. ~125 ns.
    Hardware PID engine and Math Accelerator.
    CRC engine
    Band gap voltage reference
    Configurable Logic Cell (for small amount of custom logic.)
    Angular Timer
    Signal Measurement Timer

Plus all the other normal PIC stuff: A->D, D->A, PWM, multiple other
timers,
comparators, serial, SPI and I2C communications.

I think the Angular Timer and/or Signal Measurement Timer hardware
peripherals
could be used as high accuracy 1 PPS phase detectors for GPSDO.

--- Graham

==

On Tue, Apr 12, 2016 at 7:25 AM, Tom Van Baak <tvb at leapsecond.com> wrote:

> Hi Hal,
>
> > What do you mean by a double wide cycle?
> > What do you mean by a missed cycle?
> > They seem like the same thing - if you miss one, the next one will be
> twice as wide.
>
> Yes, sorry, I mixed up my words there. A missed cycle would be a reading
> that looks closer to 32 ms than 16 ms. And a double cycle is one where, for
> example, the negative zero crossing confuses the ZCD and you get two
> readings that each look like 8 ms instead of one at 16 ms. Or if there's
> noise you might get 2 ms and 14 ms, or 0.1 ms and 16.5 ms, etc. I've seen
> period counters where you get cycle slips as a result.
>
> This effect is especially bad in 1970's era mains clocks where they would
> keep time by counting mains cycles. That's a case where signal conditioning
> is important.
>
> Similar problems occur with a TIC when you use a GPS 1PPS as start and DUT
> 1PPS as stop. You can get into awkward situations where each reading takes
> 2 seconds instead of 1 second.
>
> With a time-stamping counter every reading essentially includes the full
> history of phase, so missing or extra data doesn't change the net result.
> At worst you use a "picket fence" model to clean up the raw data.
>
> By the way, a cool thing you can do with a mains time-stamping counter is
> check the polarity of your AC outlets. You can go around the house with a
> battery operated timestamping counter and depending on which way you orient
> the plug or which 120-0-120 leg your outlet is on, you get 8 ms shifts in
> the time stamps.
>
> > I agree that working with time stamps seems simpler.  I wonder if that's
> > because I got started that way and/or wanted to watch phase drift?  I'll
> bet
> > durations work just as well if the data collection code remembers the
> round
> > off and includes it in the calculations for the next cycle.
>
> Correct, a data set of phase (or timestamps) and a data set of intervals
> (or duration, or period, or frequency) are mathematically equivalent and
> you can freely convert from one to the other, plus a constant.
>
> You have to watch out for floating-point data formats, where you can loose
> precision if you are not careful, due to rounding or range. This is
> especially true for data files of frequency; that 1/period calculation can
> result in accumulation of error.
>
> > To me, this is the important advantage of working with time stamps, but
> > that's because I was interested in tracking phase which turns into clock
> > error.
>
> Right. You and I both record phase because we're treating mains as a
> clock. But I think other people are more interested to see strip charts of
> frequency over time, or histograms of frequency deviation and the like. In
> that case, the occasional bad data or cycle slip is not a problem. Another
> way to put it -- being a time nut is always harder than being a frequency
> nut.
>
> /tvb
>
> ----- Original Message -----
> From: "Hal Murray" <hmurray at megapathdsl.net>
> To: "Tom Van Baak" <tvb at leapsecond.com>; "Discussion of precise time and
> frequency measurement" <time-nuts at febo.com>
> Cc: <hmurray at megapathdsl.net>
> Sent: Monday, April 11, 2016 7:04 PM
> Subject: Re: [time-nuts] Building a mains frequency monitor
>
>
> >> record the duration of each cycle directly
> >> 5) Double wide cycles are detectable but missed cycles are not.
> >
> > What do you mean by a double wide cycle?
> > What do you mean by a missed cycle?
> > They seem like the same thing - if you miss one, the next one will be
> twice
> > as wide.
> >
> >> Here are the advantages of the timestamping method:
> >> 5) Extra or missing cycles are easy to detect and repair with no loss of
> >> phase information.
> >
> > I'd expect the extra or missing cycles would be easy to spot if you were
> > looking at the duration.  The duration would either be twice normal or
> less
> > than half of normal.  In the latter case, you have to figure out which
> is the
> > extra pulse.
> >
> > I agree that working with time stamps seems simpler.  I wonder if that's
> > because I got started that way and/or wanted to watch phase drift?  I'll
> bet
> > durations work just as well if the data collection code remembers the
> round
> > off and includes it in the calculations for the next cycle.
> >
> > To me, this is the important advantage of working with time stamps, but
> > that's because I was interested in tracking phase which turns into clock
> > error.
> >
> > Cycle duration:
> >> 3) With period or frequency measurements, if you lose even a single
> reading,
> >> you lose track of phase (timekeeping).
> >
> > Timestamps:
> >> 3) You get perfect long-term phase tracking, even if there is noise or
> >> glitches or lost or corrupted data.
> >
> >
> >
> > --
> > These are my opinions.  I hate spam.
> >
> >
> >
> _______________________________________________
> time-nuts mailing list -- time-nuts at febo.com
> To unsubscribe, go to
> https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
>


More information about the time-nuts mailing list