By using PTP , time sync between processors in the robot system - githeim/windheim_archive GitHub Wiki
Time synchronization using PTP
Introducing how to use PTP(Precision Time Protocol) in distributed systems like robot system. Here we will introduce a method to synchronize the time between two systems within the robot system. (μ¬κΈ°μ λ‘λ΄ μμ€ν λ΄μ μλ λ μμ€ν κ°μ μκ°μ λκΈ°ν νλ λ°©λ²μ μκ°ν κ²μ΄λ€.)
the difference between ptpd <--> ptp4l
This Article deal with ptpd
Install ptpd
$ sudo apt install ptpd
Check your Network interface
$ ethtool -T eno1
...
Time stamping parameters for eno1:
Capabilities:
hardware-transmit (SOF_TIMESTAMPING_TX_HARDWARE)
software-transmit (SOF_TIMESTAMPING_TX_SOFTWARE)
hardware-receive (SOF_TIMESTAMPING_RX_HARDWARE)
software-receive (SOF_TIMESTAMPING_RX_SOFTWARE)
software-system-clock (SOF_TIMESTAMPING_SOFTWARE)
hardware-raw-clock (SOF_TIMESTAMPING_RAW_HARDWARE)
...
The following properties should be found
SOF_TIMESTAMPING_RAW_HARDWARE
SOF_TIMESTAMPING_TX_HARDWARE
SOF_TIMESTAMPING_RX_HARDWARE
Set up through command line
Set up the master
$ sudo ptpd -V -i enp89s0 -M -L
Set up the slave
$ sudo ptpd -V -i eno1 -s -L
Set up through the configuration file
Default File config
The following is the default config file after installing ptpd.
# /etc/default/ptpd
# Set to "yes" to actually start ptpd automatically
START_DAEMON=no
# Add command line options for ptpd
PTPD_OPTS=""
Set up the master system
/etc/default/ptpd
# /etc/default/ptpd
# Set to "yes" to actually start ptpd automatically
START_DAEMON=yes
# Add command line options for ptpd
PTPD_OPTS="-c /etc/ptpd.conf"
/etc/ptpd.conf
; /etc/ptpd.conf
; This is configuration for master
ptpengine:interface=enp89s0
ptpengine:preset=masteronly
ptpengine:log_announce_interval=-1
ptpengine:log_announce_interval_max=0
ptpengine:log_sync_interval=-1
ptpengine:log_sync_interval_max=0
ptpengine:clock_update_timeout=1
Set up the slave system
/etc/default/ptpd
# /etc/default/ptpd
# Set to "yes" to actually start ptpd automatically
START_DAEMON=yes
# Add command line options for ptpd
PTPD_OPTS="-c /etc/ptpd.conf"
/etc/ptpd.conf
; /etc/ptpd.conf
; This is configuration for slave
ptpengine:interface=eno1
ptpengine:preset=slaveonly
ptpengine:log_announce_interval=-1
ptpengine:log_announce_interval_max=0
ptpengine:log_sync_interval=-1
ptpengine:log_sync_interval_max=0
ptpengine:clock_update_timeout=1
Restart ptp system daemon
restart the master & slave
$ sudo systemctl restart ptpd.service
$ sudo systemctl status ptpd.service
β ptpd.service - LSB: start and stop ptpd
Loaded: loaded (/etc/init.d/ptpd; generated)
Active: active (running) since Tue 2024-02-20 09:34:14 KST; 4s ago
Docs: man:systemd-sysv-generator(8)
Process: 6632 ExecStart=/etc/init.d/ptpd start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 9274)
Memory: 1.1M
CGroup: /system.slice/ptpd.service
ββ6639 /usr/sbin/ptpd -c /etc/ptpd.conf
Feb 20 09:34:14 FORMER-0024 ptpd2[6638]: Starting ptpd2 daemon with parameters: /usr/sbin/ptpd -c /etc/ptpd.conf
Feb 20 09:34:14 FORMER-0024 ptpd2[6638]: Loading configuration file: /etc/ptpd.conf
Feb 20 09:34:14 FORMER-0024 ptpd2[6638]: Checking configuration
Feb 20 09:34:14 FORMER-0024 ptpd2[6638]: Configuration OK
Feb 20 09:34:14 FORMER-0024 ptpd2[6638]: Successfully acquired lock on /var/run/ptpd2.lock
Feb 20 09:34:14 FORMER-0024 ptpd2[6639]: Info: Now running as a daemon
Feb 20 09:34:14 FORMER-0024 ptpd2[6639]: Successfully acquired lock on /var/run/ptpd2.lock
Feb 20 09:34:14 FORMER-0024 systemd[1]: Started LSB: start and stop ptpd.
Feb 20 09:34:14 FORMER-0024 ptpd2[6639]: PTPDv2 started successfully on eno1 using "slaveonly" preset (PID 6639)
Feb 20 09:34:14 FORMER-0024 ptpd2[6639]: TimingService.PTP0: PTP service init
References
Example of the ptpd config file