berthubert / galmon

galileo open source monitoring
GNU General Public License v3.0
199 stars 53 forks source link

Feature Request - enable PPS #102

Closed sjcjonker closed 4 years ago

sjcjonker commented 4 years ago

Next to Issue #100 it would be good to then also add PPS support, this can be done with UBX_CFG_TP5, there are some settings to put in, checking both gpsd ubxtool and gpsctl the following seem to be OK, but might need tweaking:

"dmesg | grep pps" should show a pps source is detected, and after installing pps-tools, if PPS is woorking it should show output like: $ sudo ppstest /dev/pps0 # press Ctrl-C to cancel.. trying PPS source "/dev/pps0" found PPS source "/dev/pps0" ok, found 1 source(s), now start fetching data... source 0 - assert 1351501153.999956346, sequence: 47481 - clear 0.000000000, sequence: 0 source 0 - assert 1351501154.999954601, sequence: 47482 - clear 0.000000000, sequence: 0 source 0 - assert 1351501155.999951856, sequence: 47483 - clear 0.000000000, sequence: 0 ^C

Together with the SHM driver this will allow ubxtool to be used together with Chrony/NTPd as time source.

The above is PPS info is taken from: http://www.satsignal.eu/ntp/Raspberry-Pi-NTP.html

amontefusco commented 4 years ago

That page in satsignal web site is a little bit outdated.

In order to avoid to use SHM, gpsd, and above all to change uboxtool code, I connected to my Pine64, running galmon, the TTL serial of the ublox' receiver, see

www.montefusco.com/ntpgnss

note that SHM support is still present in ntpd code but nowadays ntpd is able to decode directly the NMEA strings; moreover, as you mentioned, even the PPS input can be linked to an interrupt enabled GPIO, and, after enabling PPS support, everything can be seen and used by ntpd.

See also the discussion here #74

amontefusco commented 4 years ago

This is the current status of my Pine64 running two Galileo receivers plus ntpd:

root@pine64:~# pstree
systemd-+-NetworkManager-+-dhclient
        |                `-2*[{NetworkManager}]
        |-2*[agetty]
        |-alsactl
        |-avahi-daemon---avahi-daemon
        |-cron
        |-dbus-daemon
        |-ntpd---{ntpd}
        |-polkitd---2*[{polkitd}]
        |-rsyslogd---3*[{rsyslogd}]
        |-sshd---sshd---bash---pstree
        |-systemd---(sd-pam)
        |-systemd-journal
        |-systemd-logind
        |-systemd-udevd
        |-2*[<em>ubxtool---{ubxtool}</em>]
        |-unattended-upgr---{unattended-upgr}
        `-wpa_supplicant

Note the two instances of ubxtool as there are two receivers active (NEO-M8 and the most recent ZED).

root@pine64:~# ntpq -cpeers
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
oGPS_NMEA(0)     .GAL.            0 l   10   16  377    0.000   -0.002   0.004

ntpd reports incorrectly GPS, but it is just a cosmetic.

sjcjonker commented 4 years ago

I do believe viable as well; I do have an simpleRTK2B where by via https://www.ardusimple.com/simplertk2b-hack-1-unleash-the-usb-power-of-simplertk2b/ I enabled (or should have) enabled/tricked the uart2 output. But neither NMEA or PPS (depending on ucenter config) on the come through after I started ubxtool.

As such I thought better to get it from ubxtool directly to enable the pps on port 3/usb.

bminish commented 4 years ago

Since galmon does not use the PPS line it's already possible to add PPS to NTP / Chrony.

however SHM support would allow the coarse time to be passed to NTP / Chrony and avoid the need for extra wiring to bring a second interface from the UBLOX module into use (not always easy/practical) or the use of external NTP sources to set the coarse time

To my mind does not make sense to add PPS support to galmon just so it can also be available via the SHM method if it's of no benefit internally to the galmon project. However it would be really useful if galmon could export 'coarse time' which it already has internally via the SHM method.

amontefusco commented 4 years ago

I do believe viable as well; I do have an simpleRTK2B where by via https://www.ardusimple.com/simplertk2b-hack-1-unleash-the-usb-power-of-simplertk2b/ I enabled (or should have) enabled/tricked the uart2 output. But neither NMEA or PPS (depending on ucenter config) on the come through after I started ubxtool.

As such I thought better to get it from ubxtool directly to enable the pps on port 3/usb.

What I did is to add just three wires from my ArduSimple to Pine64 (but I used the PI2 standard connector so it applies even to RPI), the TX1/RX1 to the Pine64 available UART, plus PPS to a viable GPIO. I soldered the wires, but the 2.54 strips can be used.

The UART on ZED can be enabled with the proper UBlox tools (alas on Windows) selecting the UART speed and the NMEA messages that it spits out.

In this way, you leave Galmon as is and achieve your Stratum 1 NTP server as well.

amontefusco commented 4 years ago

I enabled (or should have) enabled/tricked the uart2 output. But neither NMEA or PPS (depending on ucenter config) on the come through after I started ubxtool.

It should work, I did the same using ucenter. Did you wire the IOREF ? zed_wiring pine64_wiring

sjcjonker commented 4 years ago

amontefusco,

Thanks a lot; I'm a noob on the hardware front. As per guide on the ArduSimple page, I connected the TX and RX wires on the Xbee connector and I'm using the USB in the top of your picture. I (wrongly I guess now) that if I enabled the NMEA output the PPS would follow.

Ok so I should learn soldering, I can try. I understand the IORef wire reading the hookup guide as that sets the voltage. The TimePulse I should connect to a GPIO pin of the PI as per your sync disconnected linux system page and the page on a PI as Stratum 1

The TX/RX you have to a UART of the Base64, which would be a UART on the PI in my case. Then I would have NMEA via the uart and PPS via the GPIO?

I'm fighting some power issues on the PI, ordered an external power usb hub (it also runs an RTL-SDR for ADS-B), and then either dare to solder myself or find a friend to put some wires in place.

I'll revert back and if/when successful I'll write a page to add to this repo and maybe you can use it to include as well on yours.

Much appreciated for all the support so far.

amontefusco commented 4 years ago

In order to use, for the RPI UART, the same pins that as I did on Pine64, follow the original guide from Raspberry web site, as enabling the UART on RPI is a little bit trickier than Pine64:

https://www.raspberrypi.org/documentation/configuration/uart.md

To test everything is working at the RPI level, connect Tx to RX and start minicom or any other Linux terminal emulator (even screen is good enough): pressing a key, you should have echoed what you type.

amontefusco commented 4 years ago

Let me recap here a few info that I used in my setup.

As per "simpleRTK2B hookup guide"

TX1: ZED-F9P UART1 TX
RX1: ZED-F9P UART1 RX

The XBEE RX/TX pins are from ZED-F9P UART2, not UART1.

According to the UBlox integration Manual, 3.1.3 Default interface settings

UART1 output38400 Baud, 8 bits, no parity bit, 1 stop bit. NMEA GGA, GLL, GSA, GSV, RMC, VTG, TXT (and noUBX) messages are output by default.

so you should see something there in any case (Galmon software doesn't mess with that). Just to be sure, stop the Galmon processes and recycle power to the ArduSimple. If you have a proper TTL/USB serial dongle (@3.3V !!!), e.g. the one used for the raspberry console, attach it to the ArduSimple TX1/RX1 pins and check independently from RPI that you have there NMEA messages.

sjcjonker commented 4 years ago

@amontefusco just wanted to say with your help the UART and clockpulse works.

root@alzira:~# chronyc sources -v
210 Number of sources = 10

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| /   '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
#- NEMA                          0   4   377    15   +171ms[ +171ms] +/-  254ms
#* PPS                           0   4   377    16    +78ns[ +100ns] +/-  259ns
^- 1.app.communibase.nl          2   7   377   114    +72us[  +72us] +/-   32ms
^- 52.157.218.192                3   7   377   117  +1238us[+1238us] +/-   66ms
^- .                             3   7   377    50  +2356us[+2356us] +/-   75ms
^- time.cloudflare.com           3   7   377    49   +194us[ +194us] +/- 2976us
^- ntp.xtom.nl                   2   7   377    52    +37us[  +37us] +/-   15ms
^- gowest.hojmark.net            2   7   377   118  -1664us[-1664us] +/-   40ms
^- time.cloudflare.com           3   7   377    52   +240us[ +240us] +/- 3090us
^- docker01.rondie.nl            2   6   377    54   +393us[ +393us] +/-   40ms
root@alzira:~# ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1582231319.999998902, sequence: 3459 - clear  0.000000000, sequence: 0
source 0 - assert 1582231320.999998408, sequence: 3460 - clear  0.000000000, sequence: 0
^C

Will do a write up shortly and make a PR.

THX!

sjcjonker commented 4 years ago

Per above not required :-)