Community discussions

MikroTik App
 
Linwood
just joined
Topic Author
Posts: 17
Joined: Mon Dec 14, 2020 7:15 pm

GPS and NTP questions (V6.48.2, hAP ac^2)

Sat May 01, 2021 11:05 pm

I bought a GPS USB dongle and decided to give it a try.

I enabled GPS and it is showing the correct lat/long and date. I have GPS set to update the system time. I realize that's a low resolution time, my intent is to use this with a telescope at dark sites, if I can get to a second or so that's great, a tenth even better.

I enabled NTP Client and Server. My intent is when observing at home to use my own time source which is perhaps more accurate, so I set the NTP client to sync first with my home time server, and no secondary. The idea is it won't even succeed at a remote site, and NTP will do the time control.

Question #1: Is that correct? Will GPS Server's time updates give way to NTP client if it's showing synchronized, or will they just compete each resetting the clock? Is there a proper way to coordinate?

Question #2: Now lat/long -- if I want that from another system, how can I get it?

I can log in with ssh and do a /system gps monitor and could parse it out. I tried various combinations of /system gps get <stuff> without success, I was hoping to get latitude/longitude separately. Is there any other path, a web service or such? I guess in theory I could also do an http request to the webfig, including logging in, but that seems even more convoluted.

Is there a better way? Or maybe I'm better off trying to run the GPS on a windows box (which I also have) and NTP client to set the time (really at that point I don't much care if the router knows the time, except for logs). But Windows is a pretty unfriendly environment for either GPS or NTP, really, I was hoping this was more solid. Maybe not?
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: GPS and NTP questions (V6.48.2, hAP ac^2)

Sun May 02, 2021 12:36 pm

The problem with time messages from GPS devices is that they do not indicate the current time, but the time at which the GPS unit calculated the "fix", i.e. the solution for the position+time equations from the data received from the satellites.
The GPS device then sends this data as a serial message to the user (router) and by the time it arrives it refers to a time in the past.
This can easily create a 1 second error, often even more.

It is worst when the NMEA standard messages are used. Often a GPS device can switch to a manufacturer-specific protol where binary messages are used (smaller) and where there also are specific messages to convey "current time" rather than "time of fix".
There would have to be specific handling of those messages in the router and it could then sync its time to these messages and provide that time via NTP.
(and of course for best results there should be a hardware link that connects the pulse-per-second output of the GPS module to some interrupt of the processor)
It has been suggested before that MikroTik should compile an optional package for RouterOS containing the opensource program "gpsd".
It was created to solve exactly this problem, and also to distribute other GPS information like lat/lon to other devices over the network.

Unfortunately MikroTik has not done this yet. You could try sending a request to support or sales via e-mail.

When you want really accurate time I would suggest using a dedicated device for that, e.g. the LeoNTP. I have one of these and it provides NTP time within a couple of microseconds accurate and it also can output 1-second pulses with nanosecond-scale accuracy. It does display the position (lon/lat) on the front panel display but it does not offer network access to that, you would have to copy it manually.

Having to use Windows surely does not make it easier, Windows and accurate time are not friends.
 
Linwood
just joined
Topic Author
Posts: 17
Joined: Mon Dec 14, 2020 7:15 pm

Re: GPS and NTP questions (V6.48.2, hAP ac^2)

Sun May 02, 2021 5:08 pm

Thanks, I'm aware of the limitations of using a $12 dongle instead of a $300 time server, but I think I could still get something close, like 100ms accuracy. If I'm tracking stars a few seconds accuracy is fine. The fastest thing I may ever track would be something like the ISS, which can move at 1.15 degrees/sec. If I'm using even a long focal length telescope getting that near the center would at worst require about 1/4 second accuracy, and that's also bright and I could do from home where I have internet based NTP and can easily get 50ms or so.

In other words, I get the limitations, but it is fine for the purpose intended if I could get things to work. But exposing lat/long is a pain, and I cannot tell at all what's happening when I run NTP and GPS at the same time. I tried enabling logging (except !raw) and neither tool seems to log its adjustments, nor does either tool seem to permit you to run it for data without updating the clock. In other words, it is not at all obvious how they work together (or if they do at all, indeed at one point I got a completely unexpected reboot).

I've at least for the moment shifted to using windows, which has its own pain, but at least seems to be a bit better documented pain. I may get ambitious at some point and stick an rPi on my tripod as well, where I can run a 1pps gps as input to gps. But that takes more work than I was hoping to put into it, plus a lot of limited real estate on the tripod.
 
Linwood
just joined
Topic Author
Posts: 17
Joined: Mon Dec 14, 2020 7:15 pm

Re: GPS and NTP questions (V6.48.2, hAP ac^2)

Sun May 02, 2021 5:44 pm

Just for anyone interested, on Windows, with NMEATime2 as the GPS consumer, and compared against an NTP server to compare against and internet sync'd linux server, over an hour or so I'm showing 60ms +/- 12ms accuracy. Not great (not even good) for GPS time, but plenty good for a telescope at a remote site.
 
pe1chl
Forum Guru
Forum Guru
Posts: 10195
Joined: Mon Jun 08, 2015 12:09 pm

Re: GPS and NTP questions (V6.48.2, hAP ac^2)

Sun May 02, 2021 9:10 pm

But exposing lat/long is a pain, and I cannot tell at all what's happening when I run NTP and GPS at the same time.
That is where "gpsd" comes in. It receives the messages from the GPS receiver, parses them and stores them in local data structures, provides the time reference for NTP via SHM and/or kernel PPS, and allows you to query the lat/lon values and other GPS info (e.g. received satellites, precision, UTC offset etc) via a simple protocol over a TCP port.
Then you can run a client on the PC to query those values without having to fiddle with the messages sent by the GPS receiver.
And it also multiplexes the access in case you have multiple systems and/or applications that want the same info.

It really is something MikroTik should add to RouterOS, especially as they have devices that contain GPS but cannot do anything useful with it.

Who is online

Users browsing this forum: cmmike, Fogga, GoogleOther [Bot], mszru and 39 guests