Pt1588 is an open-source implementation of the IEEE 1588-2008 standard that defines a Precision Time Protocol (PTP) to synchronize time in a distributed system over a network to the sub-microsecond range. Pt1588 was developed for use with PTIDES, a programming model for distributed, embedded real-time systems that provides platform-independent specification of both functionality and timing. Consequently, the protocol itself is implemented as an actor with discrete-event semantics. The code executes only when provided with an input event, and executes to completion without blocking. In order to provide timer functionality, the actor produces an event to be provided to itself as input at a time in the future. However, Pt1588 can still be easily interfaced with more traditional approaches, as demonstrated with the Pt1588-Linux and Pt1588-SH7216 ports.
Porting to a new execution platform requires providing code for interface functions that interact with the network stack, real-time clock, and scheduler. In other words, Pt1588 needs to be able to send and receive messages across the network, read and adjust the real-time clock, and be scheduled to run at a future time. The Pt1588-Linux and Pt1588-SH7216 ports provide examples of how this can be achieved.
A clock servo algorithm adjusts the frequency of the slave clock. The goal is to match the frequency of the slave clock with that of the master clock and to maintain a zero offset between the two clocks. One proportional-integral (PI) controller is used to adjust the frequency to match that of the master clock, and another PI controller is used to temporarily adjust the frequency to maintain a zero offset. Of course, the parameters should be adjusted for a given application, or the clock servo algorithm replaced all together.
Pt1588-Linux is a port of Pt1588 for Linux. The port was done for demonstration purposes only, and has not been adequately tested. Timestamping is done in software, but more accurate timestamping is achievable with kernel modifications. Clock synchronization is on the order of 200µs.
Pt1588-SH7216 is a port of Pt1588 for the Renesas 7216 Demonstration Kit that uses the open-source uIP TCP/IP Stack. The DP83640 Precision PHYTER from National Semiconductor is used to provide hardware support for IEEE 1588 in the form of an integrated 125MHz IEEE 1588 clock, packet detection and timestamping with 8ns precision, and synchronized event timestamping and triggering through GPIO ports. It is difficult to have accurate and precise timestamping in software due to interrupt service routines and other sources of variability, so hardware support is useful for accurate clock synchronization. With a point-to-point connection, clock synchronization within 25ns was achieved.Michael Zimmer (mzimmereecs.berkeley.edu)