Precision Time Protocol

Measurement and control systems increasingly use distributed system technologies. To distribute measurement or control tasks over interconnected computing devices, such systems maintain a system-wide sense of time. Simulink® Real-Time™ uses the Precision Time Protocol (PTP) to synchronize the PTP clock of each computer to a reference time. The PTP clock of a Simulink Real-Time target computer is the clock on the PTP network card.

PTP (IEEE® 1588) is a protocol that synchronizes PTP clocks throughout a computer network. The current version of PTP (IEEE 1588-2008) describes a hierarchical master-slave architecture for clock distribution.

By design, this protocol is more accurate for local systems than the Network Time Protocol (NTP) and more robust than the Global Positioning System (GPS). On a local area network, the protocol achieves PTP clock accuracy in the submicrosecond range, making it suitable for distributed measurement. When you use this protocol to synchronize Simulink Real-Time applications across multiple target computers, it can synchronize execution to under 10 µs.

Suppose that you are designing a control system for a wind power plant. To determine the plant parameters, you attach sensors that acquire the data shown in the diagram.

To record the data and timestamps, you connect the sensors to a set of data acquisition target computers. You interconnect the data acquisition computers through an Ethernet network and a switch that supports the PTP protocol (a PTP transparent clock or boundary clock). To access the data and timestamps, you connect the target computers to a development computer through another Ethernet network and switch. On the development computer, you run MATLAB® to do the data analysis, including:

  • Sorting by time the data recorded on the different computers to analyze the event sequence over time.

  • Filtering sensor data that have invalid (unsynchronized) timestamps.

  • Integrating values of measured data collected at the same time from sensors connected to different computers.

To synchronize the target computer PTP clocks, you create a Simulink Real-Time model for each target computer. Each model uses the following PTP blocks:

  • IEEE 1588 Ethernet — Run PTP protocol with Raw Ethernet as transport protocol. This block communicates with the corresponding blocks on the other target computers and determines the time offset that synchronizes them.

  • IEEE 1588 Read Parameter — Output a Precision Time Protocol parameter value. Of the possible output values, you select PTP time (nanosecond).

    For debugging, you can configure a separate IEEE 1588 Read Parameter block to read other values, such as Protocol state.

  • IEEE 1588 Sync Execution — Synchronize model execution to Precision Time Protocol clock. You can now make measurements at the same time step.

  • IEEE 1588 Sync Status — Output the synchronization status of the Precision Time Protocol. When the value is true, the data timestamps are synchronized to the required precision.

As a best practice, for each model, you enclose the sensor block and the IEEE 1588 Read Parameter and IEEE 1588 Sync Status blocks in an Atomic Subsystem block. By using the Atomic Subsystem block, you bring the PTP timestamp as close as possible to the time of the data measurement.

Finally, you build and download the real-time applications to each target computer, run the applications, and collect and analyze the results at each valid timestamp. You use the results to design a control system for the wind power generator.

See Also

| | | |

Related Topics

External Websites