Closed AlexLandherr closed 8 months ago
looks like there is no log file. maybe it is not there because of the configuration or it is not there because it is the first time run.
please try to uncomment the 99-calibration settings line and comment out the regular configurations line in the file on your system: /etc/chrony/chrony.conf
include /etc/chrony/stratum1/99-calibrate-offset.gps0
#include /etc/chrony/stratum1/*.conf
and restart chrony/gpsd without deleting the :
sudo systemctl stop --now gpsd.{service,socket} && \
sudo systemctl stop chrony && \
sudo systemctl start chrony && \
sudo systemctl start gpsd
after that a log file should be generated,
i forgot to mention this - it is not clear that note 2 is only working if the calibration settings are enabled in /etc/chrony/chrony.conf
.
Thanks; will try tomorrow.
Can I see the plot over SSH or do I need a desktop environment for that? I'm connecting via PuTTY from a Windows 10 laptop.
Can I see the plot over SSH or do I need a desktop environment for that? I'm connecting via PuTTY from a Windows 10 laptop.
no you can't. except PuTTY has x11-forwarding functionallity. but i don't know.
but @Lefuneste83 told me, that there is a pure text version pf gnuplot output possible. see https://github.com/beta-tester/RPi-GPS-PPS-StratumOne/issues/16
EDIT: maybe this will work for you to enable X11 forwarting to see the graphical output: https://x410.dev/cookbook/built-in-ssh-x11-forwarding-in-powershell-or-windows-command-prompt/ and https://superuser.com/questions/1733962/x11-port-forwarding-using-windows-ssh-client
EDIT2: see also the additional comments iat the top of /etc/chrony/stratum1/99-calibrate-offset.gps0
So I could try the instructions under "note2" but replace the final one with this?:
gpspipe -ru | grep --line-buffered GGA | cut -b 20-26
So I could try the instructions under "note2" but replace the final one with this?: gpspipe -ru | grep --line-buffered GGA | cut -b 20-26
this can be run at any time. even without enabling the 99-calibration settings. but you only get momentary values. not accumulated over time.
something like:
$ gpspipe -ru | grep --line-buffered GGA | cut -b 20-26
.236417
.239822
.238604
.238527
.242537
.240127
i tried the pure text version of @Lefuneste83 in #16, and it works over SSH
$ sudo gnuplot -e "set terminal dumb" ~/git/RPi-GPS-PPS-StratumOne/gnuplot/99-calibrate-offset-gps0.gnuplot
########################################
* FILE:
Records: 412423
Out of range: 0
Invalid: 0
Header records: 0
Blank: 0
Data Blocks: 1
* COLUMN:
Mean: -0.2711
Std Dev: 0.0520
Sample StdDev: 0.0520
Skewness: -0.2506
Kurtosis: 1.8580
Avg Dev: 0.0462
Sum: -111818.8650
Sum Sq.: 31431.9986
Mean Err.: 0.0001
Std Dev Err.: 0.0001
Skewness Err.: 0.0038
Kurtosis Err.: 0.0076
Minimum: -0.4791 [305581]
Maximum: -0.1451 [366969]
Quartile: -0.3161
Median: -0.2633
Quartile: -0.2253
########################################
GPS0:
mean: 2.711266e-01 => offset 2.711266e-01
lo_quartile: 3.161442e-01
median: 2.633393e-01 => offset 2.633393e-01
up_quartile: 2.252839e-01
########################################
Calibration Offset GPS0
600 +--GPS0:----------------------------------------------------------+
| mean: 2.711266e-01 (271.1 ms)* + + + + + |
| median: 2.633393e-01 (263.3 ms) |
500 |-+ ** +-|
| *** |
| *** |
400 |-+ ***** +-|
| ***** |
300 |-+ ***** ***** +-|
| ******* ****** |
| ******* ******* |
200 |-+ ******** ********* +-|
| **********|********* |
| *****|****|*****|**** |
100 |-+ *****|****|*****|***** +-|
| ******|****|*****|****** |
| + + + + *******|****v^****|********+ + |
0 +-----------------------------------------------------------------+
-0.050 0.000 0.050 0.100 0.150 0.200 0.250 0.300 0.350 0.400 0.450 0.500
Offset (for configuration file)
^C
Ok, I'll be back sometime again tomorrow (Central European Time, CET) if I need to ask more follow-ups.
oops, i made a mistake under note 2:
sudo rm -r /var/log/chrony/*.log
must be
sudo rm -f /var/log/chrony/*.log
.
option -f
instead of -r
and if your user is not member of group _chrony
, *.log
will not be expanded, so nothing will be deleted, even you execute rm
command as sudo
er.
and maybe sudo usermod -a -G _chrony $USER
must be executed, then log-out and log-in again to be member of the group _chrony
it is so long time ago that i made this project - i forgot already so many tiny things or they changed over time.
Hi again, I've now executed this:
sudo systemctl stop --now gpsd.{service,socket} && \
sudo systemctl stop chrony && \
sudo systemctl start chrony && \
sudo systemctl start gpsd
and modified chrony.conf correctly. What is the next step?
your chrony is up and running with the 99-calibration settings for more than 30 minutes?
then execute:
sudo gnuplot -e "set terminal dumb" ~/RPi-GPS-PPS-StratumOne/gnuplot/99-calibrate-offset-gps0.gnuplot
you will see a graph on the console (may take some time, depending on the size of the log file) it will update every 60s - you have to press [Ctrl]-[C] to cancel the update loop
depending on how wide your graph is, and if you have only on single big spike, or two, choose the value of mean, median or the value of the highest peak as offset. (the offset in the 10-refclocks-pps0.conf are in [s] not [ms])
if you have found your good offset, comment-out the 99-calibration line and uncomment the regular configuration in /etc/chrony.chrony.conf file.
put the offset you found to the 10-refclocks-pps0.conf
file and restart chrony + gpsd or reboot your system.
done.
it is not a problem if chronyc -m tracking sources
still shows few ms more or less as long it is within +/- 200ms range.
EDIT: i notices i changed the regular configurations to generate log files. switching to the 99-calibration configuration was not necessary.
EDIT2: it is not needed to calibrate / set the offset as long you just use the PSM0
as refclock - this is hadles/provided by gpsd and don't required the manual calibration.
i updated the README file a bit under note 3.
your chrony is up and running with the 99-calibration settings for more than 30 minutes? then execute:
sudo gnuplot -e "set terminal dumb" ~/RPi-GPS-PPS-StratumOne/gnuplot/99-calibrate-offset-gps0.gnuplot
you will see a graph on the console (may take some time, depending on the size of the log file) it will update every 60s - you have to press [Ctrl]-[C] to cancel the update loop
depending on how wide your graph is, and if you have only on single big spike, or two, choose the value of mean, median or the value of the highest peak as offset. (the offset in the 10-refclocks-pps0.conf are in [s] not [ms])
if you have found your good offset, comment-out the 99-calibration line and uncomment the regular configuration in /etc/chrony.chrony.conf file.
put the offset you found to the
10-refclocks-pps0.conf
file and restart chrony + gpsd or reboot your system.done.
it is not a problem if
chronyc -m tracking sources
still shows few ms more or less as long it is within +/- 200ms range.EDIT: i notices i changed the regular configurations to generate log files. switching to the 99-calibration configuration was not necessary.
EDIT2: it is not needed to calibrate / set the offset as long you just use the
PSM0
as refclock - this is hadles/provided by gpsd and don't required the manual calibration. i updated the README file a bit under note 3.
What's the full path to 10-refclocks-pps0.conf
?
What's the full path to 10-refclocks-pps0.conf?
it is in /etc/chrony/stratum1/
To restart gpsd and chrony can I just execute this?:
sudo systemctl restart chrony && sudo systemctl restart gpsd
to restart gpsd + chrony, do this:
sudo systemctl stop --now gpsd.{service,socket} && \
sudo systemctl stop chrony && \
sudo systemctl start chrony && \
sudo systemctl start gpsd
(gpsd service and socket must stop first, then chrony must restart and at last gpsd must start again)
this sequence is important (at least on my older version of RasPi OS 11), otherwise some gpsd / chrony shared memory objects will not restart correctly.
alternatively you can reboot your RPi.
if everything is running as normal again for about 30 minutes, you can show me the output of:
chronyc -m tracking sources
I'll try your instructions tomorrow and let you know how it went. Thanks for everything so far.
if everything is running as normal again for about 30 minutes, you can show me the output of:
chronyc -m tracking sources
pi@raspberrypi:~ $ chronyc -m tracking sources
Reference ID : 50534D30 (PSM0)
Stratum : 1
Ref time (UTC) : Sun Jan 07 11:02:57 2024
System time : 0.000000067 seconds fast of NTP time
Last offset : +0.000000496 seconds
RMS offset : 0.000004223 seconds
Frequency : 3.263 ppm fast
Residual freq : +0.003 ppm
Skew : 0.065 ppm
Root delay : 0.000000001 seconds
Root dispersion : 0.000266408 seconds
Update interval : 8.0 seconds
Leap status : Normal
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
#? PPS0 0 3 377 8 +231ns[ +679ns] +/- 143us
#? GPS0 0 3 377 9 +20ms[ +20ms] +/- 100ms
#* PSM0 0 3 377 8 +231ns[ +679ns] +/- 257us
#? PST0 0 3 377 8 +231ns[ +231ns] +/- 224us
^? 192.36.143.134 1 4 377 4 -492us[ -492us] +/- 8913us
^? ntp4.flashdance.cx 2 4 377 3 -15ms[ -15ms] +/- 24ms
^? time.cloudflare.com 3 4 377 37 -2213us[-2213us] +/- 11ms
^? ntp.xpd.se 2 4 377 2 -3317us[-3317us] +/- 32ms
pi@raspberrypi:~ $
that looks good to me.
that looks good to me.
Ok, thanks for the all the tips and help!
A note on the offset for RPi5B: I suspect that the lag/delay of the serial NMEA data could partially be explained by the new GPIO chip on the RPi5B.
The offset is several times larger than what I get on my two other RPi Zero 2 W:s (~158 milliseconds).
I suspect that the lag/delay of the serial NMEA data could partially be explained by the new GPIO chip on the RPi5B.
interesting. but i don't worry about the delay/lag of the serial NMEA data, i more worry about the PPS signal that also runs through the new GPIO chip of the RPi5. i think relatively/locally you may not notice a big difference, because PPS and serial passes the same GPIO chip. but absolutely to another PPS/device/reference clock the extra GPIO chip may cause some extra delay. but how to measure this?
in case you want to use stratum one time servers nea by you (sweden) instead of the (generic) pool.ntp.org time servers in the file /etc/chrony/stratum1/20-ntp-servers.conf
here some stratum one time servers in sweden i scraped from the StratumOneTimeServers web page:
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000244', 'hostname': 'gbg1.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:02:55', 'orig_time': '2024-01-07T13:02:56.305655', 'recv_time': '2024-01-07T13:02:56.325231', 'dest_time': '2024-01-07T13:02:56.355024', 'tx_time': '2024-01-07T13:02:56.325232', 'offset': '-0.0051083565', 'delay': '0.0493679047'}
server gbg1.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000245', 'hostname': 'gbg2.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:02:56', 'orig_time': '2024-01-07T13:02:57.775304', 'recv_time': '2024-01-07T13:02:57.794733', 'dest_time': '2024-01-07T13:02:57.824585', 'tx_time': '2024-01-07T13:02:57.794733', 'offset': '-0.0052118301', 'delay': '0.0492811203'}
server gbg2.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000246', 'hostname': 'mmo1.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:02:58', 'orig_time': '2024-01-07T13:02:59.737473', 'recv_time': '2024-01-07T13:02:59.758196', 'dest_time': '2024-01-07T13:02:59.773819', 'tx_time': '2024-01-07T13:02:59.758196', 'offset': '0.0025498867', 'delay': '0.0363450050'}
server mmo1.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000247', 'hostname': 'mmo2.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:00', 'orig_time': '2024-01-07T13:03:01.307655', 'recv_time': '2024-01-07T13:03:01.328516', 'dest_time': '2024-01-07T13:03:01.344751', 'tx_time': '2024-01-07T13:03:01.328516', 'offset': '0.0023124218', 'delay': '0.0370955467'}
server mmo2.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000250', 'hostname': 'sth1.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:03', 'orig_time': '2024-01-07T13:03:04.763172', 'recv_time': '2024-01-07T13:03:04.784772', 'dest_time': '2024-01-07T13:03:04.805240', 'tx_time': '2024-01-07T13:03:04.784772', 'offset': '0.0005662441', 'delay': '0.0420670509'}
server sth1.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000251', 'hostname': 'sth2.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:05', 'orig_time': '2024-01-07T13:03:06.817170', 'recv_time': '2024-01-07T13:03:06.838804', 'dest_time': '2024-01-07T13:03:06.858034', 'tx_time': '2024-01-07T13:03:06.838805', 'offset': '0.0012023449', 'delay': '0.0408635139'}
server sth2.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000252', 'hostname': 'time1.stupi.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:15', 'orig_time': '2024-01-07T13:03:16.625458', 'recv_time': '2024-01-07T13:03:16.647421', 'dest_time': '2024-01-07T13:03:16.677319', 'tx_time': '2024-01-07T13:03:16.647421', 'offset': '-0.0039670467', 'delay': '0.0518603325'}
server time1.stupi.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000253', 'hostname': 'time2.stupi.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:21', 'orig_time': '2024-01-07T13:03:22.647157', 'recv_time': '2024-01-07T13:03:22.669040', 'dest_time': '2024-01-07T13:03:22.698907', 'tx_time': '2024-01-07T13:03:22.669041', 'offset': '-0.0039916039', 'delay': '0.0517501831'}
server time2.stupi.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000891', 'hostname': 'ntp3.sptime.se', 'ref_id': 'MBGh', 'version': 2, 'stratum': 1, 'precision': -26, 'root_dispersion': '0.0000152588', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:28', 'orig_time': '2024-01-07T13:03:28.119416', 'recv_time': '2024-01-07T13:03:28.141235', 'dest_time': '2024-01-07T13:03:28.160522', 'tx_time': '2024-01-07T13:03:28.141239', 'offset': '0.0012681484', 'delay': '0.0411009789'}
server ntp3.sptime.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer000892', 'hostname': 'ntp1.sptime.se', 'ref_id': 'PHC0', 'version': 2, 'stratum': 1, 'precision': -24, 'root_dispersion': '0.0000152588', 'root_delay': '0.0000152588', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:29.399229', 'orig_time': '2024-01-07T13:03:30.207085', 'recv_time': '2024-01-07T13:03:30.228261', 'dest_time': '2024-01-07T13:03:30.251248', 'tx_time': '2024-01-07T13:03:30.228310', 'offset': '-0.0008814335', 'delay': '0.0441145897'}
server ntp1.sptime.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer001417', 'hostname': 'svl1.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:30', 'orig_time': '2024-01-07T13:03:31.738180', 'recv_time': '2024-01-07T13:03:31.764950', 'dest_time': '2024-01-07T13:03:31.790894', 'tx_time': '2024-01-07T13:03:31.764950', 'offset': '0.0004131794', 'delay': '0.0527138710'}
server svl1.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer001418', 'hostname': 'svl2.ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:32', 'orig_time': '2024-01-07T13:03:33.699564', 'recv_time': '2024-01-07T13:03:33.726350', 'dest_time': '2024-01-07T13:03:33.748461', 'tx_time': '2024-01-07T13:03:33.726351', 'offset': '0.0023381710', 'delay': '0.0488963127'}
server svl2.ntp.se iburst
# {'country': 'SE', 'details': 'https://support.ntp.org/Servers/PublicTimeServer001419', 'hostname': 'ntp.se', 'ref_id': 'PPS', 'version': 2, 'stratum': 1, 'precision': -25, 'root_dispersion': '0.0000305176', 'root_delay': '0.0000000000', 'mode': 4, 'poll': 0, 'leap': 0, 'ref_time': '2024-01-07T13:03:34', 'orig_time': '2024-01-07T13:03:35.163160', 'recv_time': '2024-01-07T13:03:35.184608', 'dest_time': '2024-01-07T13:03:35.203920', 'tx_time': '2024-01-07T13:03:35.184609', 'offset': '0.0010683537', 'delay': '0.0407595634'}
server ntp.se iburst
you can copy'n'past them to your 20-ntp-servers.conf
file and comment out all pool ...
servers.
Recently I set up this project on a RPi5B 4GB with a NEO-M8T GNSS HAT and today I tried to refine the setup by finding a better value for the GPS0 offset.
I ran the long chain of commands under "note2:" and got this:
What can I do about it?