time-nuts@lists.febo.com

Discussion of precise time and frequency measurement

View all threads

Adding PTP or NTP to my GPSDO

PT
Pluess, Tobias
Sun, May 30, 2021 7:09 PM

Hi together

I am still working on my GPSDO and Jeremy with his "amazing $5 timestamper"

https://febo.com/pipermail/time-nuts_lists.febo.com/2021-February/102892.html

inspired me to do again some tests by using the internal PLL of my STM3F407
microcontroller. And guess what, it works perfectly! I don't know why the
PLL of the STM32F303 I used for my first experiments was so bad.

What my GPSDO does at the moment is:
on one connector, it outputs directly the 10 MHz from the OCXO (with a
buffer amplifier in between).
The 10 MHz also go to the microcontroller and the internal PLL is used to
boos this to 160 MHz; from these 160 MHz, the 1PPS output is achieved
(using a hardware timer with prescaler). Compared to a couple different
commercial oscillators, the stability is quite good and it appears that the
PLL does not introduce as much phase shift as I feared.
I will post more data on my long-term tests later, if interested - my GPSDO
is running now sine almost a year being tested, and is connected to a
laptop that records the data it outputs (e.g. DAC value and phase error
etc.).

Having now the PLL working nicely offers a whole bunch of new
possibilities. I rewrote my software to use FreeRTOS, which makes the
software a lot easier to understand (will upload on Github).
And I even do have some additional computing power available to do more
awesome stuff.

For instance I thought about adding PTP to my GPSDO. I will design a more
advanced PCB anyways, so I could add ethernet. Now I have read that the PTP
implementation of STM32 is not so well documented. Has anybody made some
experience with it and can give some comments?

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?

And then, one further option would be to output hte $GNRMC data and the
1PPS signal on the serial port, which could then be read by a PC. I don't
have experience with this and wonder how well that works. Has anyone ever
tried it? what caveats are there?

I think for either solution, I will need to implement some sort of calendar
and clock inside my software. And here comes the tricky part; I don't know
how I should deal with leap seconds and so forth. What would be the correct
approach? just read out the time information once a second from the GPS
module? how should I proceed then during holdover?

Thanks,
Tobias
HB9FSX

Hi together I am still working on my GPSDO and Jeremy with his "amazing $5 timestamper" https://febo.com/pipermail/time-nuts_lists.febo.com/2021-February/102892.html inspired me to do again some tests by using the internal PLL of my STM3F407 microcontroller. And guess what, it works perfectly! I don't know why the PLL of the STM32F303 I used for my first experiments was so bad. What my GPSDO does at the moment is: on one connector, it outputs directly the 10 MHz from the OCXO (with a buffer amplifier in between). The 10 MHz also go to the microcontroller and the internal PLL is used to boos this to 160 MHz; from these 160 MHz, the 1PPS output is achieved (using a hardware timer with prescaler). Compared to a couple different commercial oscillators, the stability is quite good and it appears that the PLL does not introduce as much phase shift as I feared. I will post more data on my long-term tests later, if interested - my GPSDO is running now sine almost a year being tested, and is connected to a laptop that records the data it outputs (e.g. DAC value and phase error etc.). Having now the PLL working nicely offers a whole bunch of new possibilities. I rewrote my software to use FreeRTOS, which makes the software a lot easier to understand (will upload on Github). And I even do have some additional computing power available to do more awesome stuff. For instance I thought about adding PTP to my GPSDO. I will design a more advanced PCB anyways, so I could add ethernet. Now I have read that the PTP implementation of STM32 is not so well documented. Has anybody made some experience with it and can give some comments? 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? And then, one further option would be to output hte $GNRMC data and the 1PPS signal on the serial port, which could then be read by a PC. I don't have experience with this and wonder how well that works. Has anyone ever tried it? what caveats are there? I think for either solution, I will need to implement some sort of calendar and clock inside my software. And here comes the tricky part; I don't know how I should deal with leap seconds and so forth. What would be the correct approach? just read out the time information once a second from the GPS module? how should I proceed then during holdover? Thanks, Tobias HB9FSX
AR
Andrew Rodland
Mon, Jul 12, 2021 3:25 AM

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

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