OPNsense Forum

English Forums => General Discussion => Topic started by: MagikMark on January 06, 2025, 01:32:40 AM

Title: NTP Server: GPS
Post by: MagikMark on January 06, 2025, 01:32:40 AM
Hi!

I'm using this GPS:

BU-353N5 GPS Receiver (https://www.globalsat.com.tw/en/product-282242/USB-GNSS-Receiver-BU-353N5.html)

Are there any configuration that I could use to optimize it's performance?  Right now I'm just using "Generic".  I'm getting a lot of "False Ticker".  Dunno if it's configuration related
Title: Re: NTP Server: GPS
Post by: bimbar on January 06, 2025, 12:14:12 PM
Generally you need a serial gps adapter with PPS signal. GPS NTP performance without PPS is poor. Unfortunately I am not aware of USB GPS adapters that do PPS - probably because PPS is usually a dedicated line and maybe USB performance is not good enough for PPS anyway.
Title: Re: NTP Server: GPS
Post by: 150d on January 06, 2025, 01:02:18 PM
This may be a futile battle: Your receiver seems to be optimized for (car) navigation. It may not even be capable to serve as a precise time source.

What you could try:

- Disable all PPS processing on the client. Even if the receiver should "emulate" this signal over USB, it won't be reliable.

- Limit message types on the receiver to only the NMEA types required for timing. This will "free up" bandwidth and maybe enable the receiver to report more often, giving a more plausible signal to the client.

- Increase comm speed from 4800 to something higher on the receiver. Same as before, this may enable the receiver to give more regular reports.

- Make sure the receiver has a good signal. If it looses the signal every now and then, the client will tend to view it as unreliable.

... but again, consider whether it's worth your time: You won't get precise timing out of this device anyway, you might be better off using internet time servers in the first place.
Title: Re: NTP Server: GPS
Post by: bimbar on January 06, 2025, 02:21:47 PM
IMO GPS without PPS is not worth it. Better to use internet time.
Title: Re: NTP Server: GPS
Post by: Patrick M. Hausen on January 06, 2025, 03:10:22 PM
I like these devices a lot:

https://centerclick.com/ntp/
Title: Re: NTP Server: GPS
Post by: pfry on January 06, 2025, 05:12:37 PM
Quote from: bimbar on January 06, 2025, 12:14:12 PM[...] Unfortunately I am not aware of USB GPS adapters that do PPS - probably because PPS is usually a dedicated line and maybe USB performance is not good enough for PPS anyway.

There are a few, e.g. https://www.adafruit.com/product/4279 (https://www.adafruit.com/product/4279). Not exactly plug'n'play, but cheap.
I've read that modern I2C-connected serial ports aren't great for PPS, either. Pretty sad, considering the speed of modern equipment.
A simple PCI-e x1 card would be nice, but those are rare/expensive.
Title: Re: NTP Server: GPS
Post by: Greg_E on January 06, 2025, 07:27:54 PM
Look on ebay for :

TF-NTP-Lite
and
FC-NTP-Mini

That said, I need to look into PTP through a RasPi5 a little deeper, I can use PTP for a couple things that really need to be in time.

And on those USB receivers, shouldn't they be just as accurate as the PPS signal? You should be receiving the raw data from each satellite and calculating the time from that data, or does the receiver do the calculations (which should be pretty accurate on the output)?
Title: Re: NTP Server: GPS
Post by: lilsense on January 06, 2025, 07:51:43 PM
for High performance, I do recommend sparkfun gps boards.
Title: Re: NTP Server: GPS
Post by: Patrick M. Hausen on January 06, 2025, 08:28:35 PM
Quote from: lilsense on January 06, 2025, 07:51:43 PMfor High performance, I do recommend sparkfun gps boards.
They look like they are in the same or even higher price range than the Centerclick devices which come with NTP, SNMP, SSH and a web UI. Any advantages of the Sparkfun ones?
Title: Re: NTP Server: GPS
Post by: lilsense on January 06, 2025, 09:47:38 PM
I am not sure about the Quectel Chipset but from the look of it briefly, the Sparkfun u-blox chipset has a 92 channel vs Quectel chipset 33 channel. But generally u-blox chipsets are considered high end.
Title: Re: NTP Server: GPS
Post by: pfry on January 07, 2025, 01:18:57 AM
Quote from: Greg_E on January 06, 2025, 07:27:54 PM[...]
And on those USB receivers, shouldn't they be just as accurate as the PPS signal? You should be receiving the raw data from each satellite and calculating the time from that data, or does the receiver do the calculations (which should be pretty accurate on the output)?

Over the same type of link, yes. But ideally your PPS would directly trigger an interrupt which would then be serviced immediately. No reason you couldn't do the same with NMEA (or other) data, but apparently commodity serial hardware these days has a lot of buffers and other processing delays, and the drivers are not designed to minimize latency either.

Say, where are those chip-scale atomic clocks we were promised...?
Title: Re: NTP Server: GPS
Post by: MagikMark on January 07, 2025, 06:08:46 AM
Thank you guys for your thoughts.

@Patrick M. Hausen

Do you have a guide on how you attached this to OPNsense then configure it?
Title: Re: NTP Server: GPS
Post by: Patrick M. Hausen on January 07, 2025, 07:52:55 AM
There's nothing to attach. Plug this device into your network, configure a static DHCP lease - you now have a local stratum 1 server.

In OPNsense: Services > Network Time > General

Enter the IP address of your new NTP server, done.
Title: Re: NTP Server: GPS
Post by: bimbar on January 07, 2025, 10:24:24 AM
I'll consolidate my answers into one post :) .

@Patrick: That's very cool, I have been looking for something cheaper than Meinberg.

@Greg_E: PTP is a whole different thing, I don't think we need that, we're just at NTP here.
Also, GPS has 2 time signals:
- coarse time is delivered via NMEA, but it pretty much only tells you the second. I have seen GPS time sources only using NMEA, even in the NTP Pool, but it's very bad practice
- precise time is delivered as a 1PPS signal, meaning one pulse per second, which triggers a pulse exactly on the second
A GPS time source as we know it uses a combination of both.

@pfry: you can not trigger on NMEA, because PPS is its own line on the serial interface and only that line carries that signal.

@lilsense: as long as your GPS interface maintains sync, it doesn't really matter which one you use. I recommend multi-band ones since they tend to hold sync better, especially indoors.

Those centerclick devices seem the way to go, they're pretty cheap for what they claim to do. If I had known that, I don't think I would have built my own esp32 based GPS stratum 1 NTP clock.
Title: Re: NTP Server: GPS
Post by: MagikMark on January 07, 2025, 11:34:47 AM
@Patrick M. Hausen

How about the antenna?  Are you using indoor or outdoor?  Does the indoor antenna sufficient if it's placed beside the window?  How fast does it take o syncronize with the satellite?
Title: Re: NTP Server: GPS
Post by: Patrick M. Hausen on January 07, 2025, 11:49:11 AM
I clamped a small sheet of metal to the book shelf that is standing right next to the window in my office and attached the magnetic indoor antenna to that. So it's sitting perpendicular to the window about centred in window height and a foot or so removed from the wall. "looking out" to the west and up.

                        window                                                                   
──────────────────┌─────────────────┐─────────────────────────────────────────────────────────────
                  └─────────────────┘  ┌─────────────────────────────────────────────────────────┐
                                       │                                                         │
                                      ┌┤                        bookshelf                        │
                              antenna └┴─────────────────────────────────────────────────────────┘


See attachment for the GPS status as shown by the device's UI. No precise idea about the sync time - couple of minutes.
Title: Re: NTP Server: GPS
Post by: pfry on January 07, 2025, 08:22:48 PM
Quote from: bimbar on January 07, 2025, 10:24:24 AM[...]
@pfry: you can not trigger on NMEA, because PPS is its own line on the serial interface and only that line carries that signal.
[...]

Implementation dependent. Current RS-232 and USB implementations may have issues, but the old discrete UARTs could be configured to interrupt immediately on any signal. In addition, GPS receiver implementation will likely not support precise timing of NMEA data, but some old ('90s) units did have this option. I recall one in particular with its PPS optionally connected to DCD and normally disabled, as its normal RS-422 didn't have control lines. I'll have to plug in my old Ultralink WWV clock and see how bad it is now, as it uses a similar method (time delivered on the second, with PPS disconnected). It used to be quite accurate back in the day.
Title: Re: NTP Server: GPS
Post by: bimbar on January 08, 2025, 11:50:41 AM
Quote from: pfry on January 07, 2025, 08:22:48 PM
Quote from: bimbar on January 07, 2025, 10:24:24 AM[...]
@pfry: you can not trigger on NMEA, because PPS is its own line on the serial interface and only that line carries that signal.
[...]

Implementation dependent. Current RS-232 and USB implementations may have issues, but the old discrete UARTs could be configured to interrupt immediately on any signal. In addition, GPS receiver implementation will likely not support precise timing of NMEA data, but some old ('90s) units did have this option. I recall one in particular with its PPS optionally connected to DCD and normally disabled, as its normal RS-422 didn't have control lines. I'll have to plug in my old Ultralink WWV clock and see how bad it is now, as it uses a similar method (time delivered on the second, with PPS disconnected). It used to be quite accurate back in the day.

That is also what I have seen, that PPS is connected to DCD, but I do not know of any way to do precise NMEA timing without PPS.
Title: Re: NTP Server: GPS
Post by: Greg_E on January 08, 2025, 03:39:11 PM
I use double sided foam tape and stick the antennae to a south facing window. With the above devices, this is currently what I get on a snowy cloudy day. If the option was easier, I would put up an external antenna, I'm on the ground floor of a three story concrete and steel building, the north is completely occluded, east is partially occluded, west is decent, and south completely clear.

These do have PPS output on the back, so I'm guessing fairly accurate. Matches the time from my phone at any rate which is good enough for me right now.