Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
— | linux:zeitsynchronisation_mit_dcf-77_empfaenger [2023/03/08 08:04] (aktuell) – angelegt - Externe Bearbeitung 127.0.0.1 | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== Zeitsynchronisation Mit DCF-77 Empfänger ====== | ||
+ | Die Zeit kann über einen DCF-77 Empfänger von der Atomuhr aus Meinberg bei Frankfurt geholt werden. | ||
+ | |||
+ | Der Empfänger selbst kann entweder fertig gekauft oder mit Elektronikteilen von Conrad selbst gebaut werden. | ||
+ | Mein Gebauter Empfänger hat zwei LEDs. Die rote zeigt an dass die Stromversorgung, | ||
+ | Die Grüne LED blinkt im Sekundentakt wenn ein Signal der Atomuhr vorhanden ist. | ||
+ | |||
+ | ===== Conrad Stückliste ===== | ||
+ | PC-Funkuhrmodul | ||
+ | ^ Anzahl ^ Beschreibung ^ Artikel-Nr ^ Preis/Stck ^ Preis ges. ^ | ||
+ | |1 |DCF77-Modul von Conrad-Elektronik |641138 |10,21 |10,21 | | ||
+ | |1 |RS-232 Buchse, Sub-D 9-polig |742082-62 |0,52 |0,52 | | ||
+ | |1 |passende Haube dazu |716028-62 |1,25 |1,25 | | ||
+ | |1 |IC MAX232 |152295-62 |1,47 |1,47 | | ||
+ | |2 |Dioden 1N4148 |162280-62 |0,04 |0,08 | | ||
+ | |1 |Z-Diode 5,1 Volt |160276-62 |0,3 |0,3 | | ||
+ | |1 |LEDs Low Current (2mA) rot |146005-62 |0,19 |0,19 | | ||
+ | |1 |LEDs Low Current (2mA) grün |146030-62 |0,19 |0,19 | | ||
+ | |1 |Widerstand 1 kΩ |405256-62 |0,09 |0,09 | | ||
+ | |2 |Widerstände 4,7 kΩ |405337-62 |0,09 |0,18 | | ||
+ | |5 |Kondensatoren Tantal (Elkos gehen auch) 10 μF / 35V |472484-62 |0,18 |0,9 | | ||
+ | |1 |Elektrolytkondensator 100 μF / 35V |472514-62 |0,21 |0,21 | | ||
+ | |1 |Folienkondensator 100nF |459977-62 |0,45 |0,45 | | ||
+ | |1 |Lochrasterplatine |528404-62 |0,63 |0,63 | | ||
+ | |1 |Gehäuse |520521-62 |2,71 |2,71 | | ||
+ | | | **Gesamt Preise**| |**18,53** |**19,38** | | ||
+ | |||
+ | ===== Schaltung ===== | ||
+ | Dazugehörige Schaltung: | ||
+ | |||
+ | {{:: | ||
+ | |||
+ | ===== Software ===== | ||
+ | Unter Linux kann mit dem NTP Daemon die Zeit des Funkuhrmoduls empfangen und konvertiert werden. | ||
+ | |||
+ | ==== NTP ==== | ||
+ | Folgende Softwarepakete müssen installiert werden: | ||
+ | <code bash> | ||
+ | |||
+ | In der ''/ | ||
+ | |||
+ | <code bash># / | ||
+ | |||
+ | driftfile / | ||
+ | logfile / | ||
+ | |||
+ | # Enable this if you want statistics to be logged. | ||
+ | statsdir / | ||
+ | |||
+ | statistics loopstats peerstats clockstats | ||
+ | filegen loopstats file loopstats type day enable | ||
+ | filegen peerstats file peerstats type day enable | ||
+ | filegen clockstats file clockstats type day enable | ||
+ | |||
+ | |||
+ | # You do need to talk to an NTP server or two (or three). | ||
+ | #server ntp.ubuntu.com | ||
+ | server 127.127.8.0 mode 5 prefer | ||
+ | server 127.127.1.0 | ||
+ | fudge 127.127.1.0 stratum 10 | ||
+ | |||
+ | # Access control configuration; | ||
+ | # details. | ||
+ | # might also be helpful. | ||
+ | # | ||
+ | # Note that " | ||
+ | # that might be intended to block requests from certain clients could also end | ||
+ | # up blocking replies from your own upstream servers. | ||
+ | |||
+ | # By default, exchange time with everybody, but don't allow configuration. | ||
+ | restrict -4 default kod notrap nomodify nopeer noquery | ||
+ | restrict -6 default kod notrap nomodify nopeer noquery | ||
+ | |||
+ | # Local users may interrogate the ntp server more closely. | ||
+ | restrict 127.0.0.1 | ||
+ | restrict ::1 | ||
+ | # Clients from this (example!) subnet have unlimited access, but only if | ||
+ | # cryptographically authenticated. | ||
+ | #restrict 192.168.123.0 mask 255.255.255.0 notrust | ||
+ | |||
+ | |||
+ | # If you want to provide time to your local subnet, change the next line. | ||
+ | # (Again, the address is an example only.) | ||
+ | #broadcast 192.168.123.255 | ||
+ | |||
+ | # If you want to listen to time broadcasts on your local subnet, de-comment the | ||
+ | |||
+ | # next lines. | ||
+ | #disable auth | ||
+ | # | ||
+ | |||
+ | ==== Udev Rules ==== | ||
+ | Damit der Eintrag '' | ||
+ | <code bash>ln -s /dev/ttyS0 / | ||
+ | |||
+ | Dieser Link sollte auch nach einem Reboot noch da sein. Dies ist er aber nicht wenn wir nicht die UDEV-Rules bearbeiten: | ||
+ | Also die Datei (evtl. noch nicht vorhanden) ''/ | ||
+ | <code bash> | ||
+ | |||
+ | ==== Apparmor ==== | ||
+ | //Zitat Wikipedia// | ||
+ | AppArmor (Application Armor, auf deutsch etwa Programm-Schutz/ | ||
+ | |||
+ | Damit AppArmor nun den Zugriff auf '' | ||
+ | dass Profil des AppArmor für den NTP-Daemon angepasst werden. | ||
+ | Dafür fügt man am Ende (vor der geschweiften Klammer) in die Datei ''/ | ||
+ | < | ||
+ | / | ||
+ | |||
+ | ===== Test ===== | ||
+ | Nun kann der NTP-Daemon mit dem Befehl '' | ||
+ | |||
+ | Unter ''/ | ||
+ | Im Verzeichniss ''/ | ||
+ | |||
+ | ==== NTP-Stats ==== | ||
+ | Im Statistikverzeichniss befinden sich die '' | ||
+ | |||
+ | ==== NTP-Drift ==== | ||
+ | Im Libverzeichniss kann man mit der Driftdatei schauen wie die lokale Zeit vom Empfängermodul abdriftet. | ||
+ | |||
+ | ==== NTP-Log ==== | ||
+ | Im Logverzeichniss sieht man in der Logdatei was der NTP-Daemon gemacht hat. | ||
+ | |||
+ | Hier eine Ausgabe: | ||
+ | < | ||
+ | 11 May 09:24:55 ntpd[2297]: parse: convert_rawdcf: | ||
+ | |||
+ | 11 May 09:24:55 ntpd[2297]: PARSE receiver #0: interval for following error message class is at least 00:01:00 | ||
+ | 11 May 09:24:55 ntpd[2297]: PARSE receiver #0: FAILED TIMECODE: " | ||
+ | 11 May 09:25:58 ntpd[2297]: synchronized to GENERIC(0), stratum 0 | ||
+ | 11 May 09:27:03 ntpd[2297]: time reset +64.490872 s | ||
+ | 11 May 09:27:03 ntpd[2297]: kernel time sync status change 2001 | ||
+ | 11 May 09:27:04 ntpd[2297]: parse: convert_rawdcf: | ||
+ | |||
+ | 11 May 09:27:04 ntpd[2297]: PARSE receiver #0: interval for following error message class is at least 00:01:00 | ||
+ | 11 May 09:27:04 ntpd[2297]: PARSE receiver #0: FAILED TIMECODE: " | ||
+ | 11 May 09:28:00 ntpd[2297]: parse: convert_rawdcf: | ||
+ | |||
+ | 11 May 09:29:03 ntpd[2297]: synchronized to GENERIC(0), stratum 0</ | ||
+ | |||
+ | Man sieht dass in der 1. Zeile der Neustart des Daemon angezeigt wird. | ||
+ | Danach erhält der NTP die Signale des Empfängers. | ||
+ | Das '' | ||
+ | Zum Schluss sieht man das die Zeit synchronisiert wurde. | ||
+ | |||
+ | Man kann mit dem Befehl '' | ||
+ | |||
+ | ===== timesyncd ===== | ||
+ | Quelle: [[https:// | ||
+ | |||
+ | Timesyncd ist ein anderer Zeitdienst-Daemon unter Linux. | ||
+ | |||
+ | **Zeitserver** | ||
+ | Der Zeitserver wird in dieser Datei Konfiguriert ''/ | ||
+ | < | ||
+ | #NTP= ntp1.domain.tld ntp2.domain.tld ... | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | |||
+ | Gestartet wird Timesync mit dem Befehl '' | ||
+ | |||
+ | Diese Befehle zeigen die aktuellen Einstellungen und Laufzeitdaten: | ||
+ | timedatectl status ntpq -p | ||
+ | timedatectl timesync-status</ | ||
+ | |||
+ | '' | ||
+ | Wenn timesyncd lange braucht um sich zu synchronisieren, | ||
+ | <code bash> | ||
+ | timedatectl set-net true</ | ||
+ | |||
+ | **Zeitzone** | ||
+ | Die Zeitzone wird mit folgendem Befehl konfiguriert. | ||
+ | <code bash> | ||
+ | So listet man verfügbare Zeitzonen auf | ||
+ | <code bash> | ||
+ | ===== NTP Commands ===== | ||
+ | <code bash> | ||
+ | ntpq -c rv</ | ||
+ | |||
+ | ===== LEAP ===== | ||
+ | Quelle: [[https:// | ||
+ | Folgende Leap-Codes gibt es. | ||
+ | ^ Code ^ Message ^ Description ^ | ||
+ | | 0 | leap_none | normal synchronized state | | ||
+ | | 1 | leap_add_sec | insert second after 23:59:59 of the current day | | ||
+ | | 2 | leap_del_sec | delete second 23:59:59 of the current day | | ||
+ | | 3 | leap_alarm | never synchronized | |