PID: https://www.isa.org/intech-home/2017/may-june/features/optimizing-to-the-tune-of-a-pid-equation
EtherCAT info: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_io_intro/1257993099.html&id=
https://www.daimajiaoliu.com/daima/712028a9630f001
sync: https://training.ti.com/ethercat-protocol-feature-highlight-distributed-clocks#? http://www.noobyard.com/article/p-movtdnnn-qz.html
The master sends a broadcast command in a data frame at T0. When slave receives the frame, local clock time stamp is written into the parameter Receive time Port0, noted as T1(n), where n is the slave station number.
When the data frame is returned (Port1 receives), the local clock is written into the parameter Receive time Port1 as T2(n).
The master station calculates Toffset(n)=T0-T1(n) and remote writes it into the System Time offset register of the slave(n).
The master station calculate the delay of slave(n) relative to the reference clock as [T2( 1) – T1(1) – (T2(n) – T1(n))] / 2, and writes this parameter into the register System time transmission delay register of slave(n).
Here some assumption ignored, When slave receives the frame means when Port0/1 receives the first bit of the leading bit of the data. The reference clock is the local clock of the first DC slave station.