[time-nuts] Re: Adding PTP or NTP to my GPSDO

2021-07-11 Thread Andrew Rodland
On Sunday, May 30, 2021 3:09:16 PM EDT Pluess, Tobias wrote:
> Besides that, I also thought about adding a NTP. That would not require a
> MAC with PTP capability. Any thoughts on that? has anyone ever written
> their own NTP server on a microcontroller?

I have, twice — once for the Arduino Uno (ATmega328) with W5100 Ethernet (not 
great; the W5100's own processor adds quite a lot of jitter, but it was still 
good to better than 100us), and once for an Arduino Due clone (ATSAM3X8E) 
using the internal Ethernet MAC. Both of them are up on GitHub: 
https://github.com/arodland?tab=repositories&q=ntp

Probably most of it is not much use to you, but the NTP protocol 
implementation at lines 27 - 216 of
https://github.com/arodland/Due-GPS-NTP-Server/blob/master/ethernet.cpp
might be educational.

One trick to keep in mind when doing NTP on a micro is: you don't need to 
bother with an ARP implementation, just swap the src and dst MAC addresses 
along with the src and dst IP addresses when you send your reply.

Cheers,

Andrew KC2G

___
time-nuts mailing list -- time-nuts@lists.febo.com -- To unsubscribe send an 
email to time-nuts-le...@lists.febo.com
To unsubscribe, go to and follow the instructions there.

[time-nuts] Re: GPSDO Software & Performance

2021-07-11 Thread Poul-Henning Kamp

Pluess, Tobias writes:

> However in the other plot "gpsdo-outliers" we can see that there are huge
> outliers in the phase error. At these times, we had huge thunderstorms here
> in Switzerland at my place and I believe that the GPS signal quality was so
> bad at these times that the GPS time pulse did not work reliably. (what
> other reasons could there be for these 1PPS timing outliers?)

Thunderstorms, in particular in regions with high ground resistance
(= mountains) causes electrostatic fields which can cause trouble.

One of the lesser known kinds of this trouble is induced voltages
in high impedance CMOS inputs.

Therefore: make sure that all unused CMOS pins are either tied
to something with a suitably low resistance.

On microcontrollers one can configure unused pins as outputs and drive
them low.

> Obviously, the "magic" of a GPSDO control algorithm is in the filtering of
> these outliers! so far, my control code (src/cntl.c on Github) does not
> seem to filter these outliers good enough

In general median filters are probably the most robust way to deal with
outliers, but if you do them the naiive way, they cause a usually
unacceptable time-delay.

When the outliers are less than half of samples, and always wrong,
running the median filter in "gate mode" works well.

Since the output from the median filter only defines a "gate" which
input signals must pass, it causes no time-delay in the control
loop.

Something like:

NMEDIAN = 300
GATE = 1e-3

median_filter = [None]

def new_measurement(x):
median = sorted(median_filter)[len(median_filter)//2]
if median is None or median - GATE < x < median + GATE:
ok_measurement(x)
if len(median_filter) >= NMEDIAN:
median_filter.pop(0)
median_filter.append(x)

This will reliably discard any sample which are more than 1e-3 from
the median of the previous 300 samples.

If the outliers are sometimes true, ie, where step-changes are
to be expected and sensibly handled, median filters are not
so swell and Kalman filters may be indicated.


-- 
Poul-Henning Kamp   | UNIX since Zilog Zeus 3.20
p...@freebsd.org | TCP/IP since RFC 956
FreeBSD committer   | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
___
time-nuts mailing list -- time-nuts@lists.febo.com -- To unsubscribe send an 
email to time-nuts-le...@lists.febo.com
To unsubscribe, go to and follow the instructions there.


[time-nuts] Re: Symmetricom NTS-150 Network Time Server Report

2021-07-11 Thread Björn
Hi Ben,


> On 10 Jul 2021, at 21:20, Ben Hall  wrote:
> 
> Afternoon all,
> 
[...]
> 
> So basically, I've got a nice rack-mount enclosure to enclose my next 
> rack-mount project...as I don't think it will ever work as an NTP server 
> again.  :)
> 
> Thanks much and 73,
> ben, kd5byb

Since it is tracking - it should be showing the right time of day. If the 
server had 1PPS/10MHz outputs those would also be fullt correct. The ”only” 
issue is that the date is off by 1024weeks.  You could try to set up a 
raspberry with ntpd using the NTS as a server but offset it with 1024wk. That 
should bring back a useful ntp-service.

/Björn 
___
time-nuts mailing list -- time-nuts@lists.febo.com -- To unsubscribe send an 
email to time-nuts-le...@lists.febo.com
To unsubscribe, go to and follow the instructions there.