[time-nuts] Building a mains frequency monitor

David davidwhess at gmail.com
Mon Apr 11 15:30:55 UTC 2016


On Wed, 6 Apr 2016 18:21:43 -0700, you wrote:

>...
>
>Q1: Assuming the schmitt trigger in the picPET triggers at a consistent
>point in the waveform, the frequency at any given cycle is easy to 
>calculate: 1.0 / (timestamp2 - timestamp1)    ...but, is there a better
>way? That method just feels... naive, for some reason.

Given the low power line frequency and high noise content, this method
provides plenty of resolution.

>Q2: What are the sources of noise in this design? Assuming the picPET is as
>accurate as my 10MHz reference is, I can think of a few potential places
>that phase noise could creep into the measurements:
>  - Whatever is in the power brick beyond the transformer (I don't think a step down transformer alone would add phase noise, right?)
>  - The dropping resistor will slowly change the amplitude of the waveform (and thus the point in the cycle that the schmitt trigger fires) due to thermal and aging effects, if we're measuring anything that's not the exact zero crossing
>  - The point at which the schmitt trigger in the picPET fires will change over time for the same reasons. Also potentially due to picPET input voltage, depending on how the comparitor is built
>  - Am I missing any?

High frequency noise on the 60 Hz waveform itself will dominate
sources within the circuit.  Phase controlled light dimmers are
especially noisy but intermittent sources of noise from heavy loads
starting and stopping like motors and microwave ovens are also an
issue.

>Q3: The open-ended question: How do I improve on this? I suspect the main place for improvement will be in the trigger, but I'm not sure where to go with that.  Most designs I've seen involve a schmitt trigger, generally with reference voltages set by things like voltage dividers. This seems dubious at best, to me, since that means the reference voltage will be affected by the same effects I'm calling out above. Is there a *specific* design (rather than "make a zero crossing detector!" or something similarly vague) that someone can point me to, that would minimize this kind of trigger noise?

Take a look at page 12 of Linear Technology application note 31 for an
example of a simple Schmitt trigger based injection locked 60 Hz
oscillator intended for exactly this application:

http://www.linear.com/docs/4124

Schmitt triggers are great for preventing false triggering but are
less useful where low jitter is desired since they amplify high
frequency noise.  The old alternative I have sometimes seen involves
an analog phase locked loop but it would be pretty easy to implement a
modern DSP version in a simple microcontroller.

>Q3.1: Is there a better way to get mains voltage down to something I can work more directly with? I saw at least one design that just used a couple of megaohm resistors inline -- does that introduce appreciably less phase noise than random AC/AC power brick?

A transformer is one of the better ways because it provides galvanic
isolation; it is safe, low noise, and easy to get right.  Modern DSOs
use an optocoupler for their line trigger.  High value (and voltage)
resistors to neutral and ground will work but the high impedance will
pick up more ambient noise.  Capacitive coupling would work better
than resistors and Y type safety capacitors could be used for better
safety.



More information about the Time-nuts_lists.febo.com mailing list