[time-nuts] Recording mains frequency/phase [WAS: NoGPSsatellites]

Ben Hall kd5byb at gmail.com
Tue Mar 3 20:07:28 EST 2015

Hi Tom and list!

Thank you for the responses.  This has been very educational.

On 3/2/2015 2:55 AM, Tom Van Baak wrote:
> 1) The PC program that reads the serial port can toss lines it
> doesn't want.

I'll publicly expose my silliness here - I never thought about the
program end of things.  I was simply thinking something like an old
terminal program with logging turned on.

Last night in a sleepless moment I got to thinking:  this seems like a
great use of a Raspberry Pi.  It can parse the serial, save the data to
a file, start a new file each day, each week, etc...  Plus, I can set it
up to be a network file location so I can analyze the files elsewhere
easily.  I'm going to pursue this.  I've got two already - one is a
GPS-based NTP server...the other is an ADS-B receiver / reporter.

> 3) The other solution that I often use is a version of the picPET
> (pP19) that deliberately takes 990 ms to output the timestamp (events
> are counted in h/w).

This would be perfect.  While discarding the unwanted data should not be 
hard...not having to do it at all is easier.  ;)

> Yes, see code above. Same logic in any language, but probably one
> line of code in awk or perl or python.

I'll probably end up learning some python in doing the serial logger 
above.  It seems to be a language of choice for the Pi.

> If you do it up-front, like a pre-scaler, you have to worry about
> signal quality to avoid off-by-one glitches. You'll get lots of
> suggestions here on the mailing list and on the web about how to best
> detect zero-crossings. The circuits get pretty complex. It may
> surprise you that I don't do any of that.

I wasn't aware of this, so its very good to know.  :)

> The beauty of timestamping (instead of traditional counting) is that
> signal conditioning is much less important. I put raw 5 VAC into the
> PIC pin via a 10k resistor. That's it. Any "conditioning" can be done
> in software.

It is a lot simpler too.  Simple is always good in my book.  (mostly 
because I'm too stupid to do much that is complex!)

thanks much and 73,
ben, kd5byb

More information about the time-nuts mailing list