Skip to content

Precision Time Protocol (blaze)#

The Precision Time Protocol (PTP) feature allows you to synchronize multiple GigE cameras in the same network.

The IEEE 1588 standard defines the protocol. Basler cameras support IEEE 1588-2008, also known as PTP Version 2.

Info

The precision of the PTP synchronization depends to a large extent on your network hardware and setup. For maximum precision, choose high-quality network hardware, use PTP-enabled network switches, and add an external PTP clock device with a GPS receiver to your network.

Using the Feature#

Why Use PTP#

The Precision Time Protocol (PTP) feature enables a blaze camera to use the Synchronous Free Run (blaze) feature.

Through PTP, the clocks of multiple cameras can be automatically synchronized with the most accurate clock found in a network, the so-called master clock or best master clock.

Depending on your system setup, the master clock can either be a camera or an external device:

  • If your system only includes cameras, the cameras negotiate amongst themselves to determine the most accurate camera clock, which will then serve as the master clock.
  • If your system includes an external device (e.g., a GPS receiver or an additional computer configured as master), the external device will act as the master clock.

When the cameras' clocks are synchronized, their timestamps can be compared against each other.

If the master clock in the network delivers absolute times based on the international time standard TAI, e.g., via a GPS receiver, the local time can be determined from the timestamps generated by the cameras' synchronized clocks.

If the master clock doesn't deliver TAI time, the clocks are running in synch but their times are on a random timescale, the so-called arbitrary timescale mode (ARB). In this mode, the epoch is arbitrary, as it is not bound to an absolute time. This timescale is relative, i.e., it is only valid in that network. The best master clock algorithm will select the clock with the highest stability and precision as the master clock of that network. Cameras acting as master clocks can't deliver TAI times, only ARB time.

Enabling PTP Clock Synchronization#

When powering on the camera, PTP is always disabled. If you want to use PTP, you must enable it.

To enable PTP:

  1. If you want to use an external device as the master clock (e.g., a GPS receiver), configure the external device as the master clock.
  2. On all cameras that you want to synchronize via PTP, set the PtpEnable parameter to true.
  3. Wait until all PTP network devices are sufficiently synchronized. Depending on your network setup, this may take a few seconds or minutes.
    To determine when the devices are synchronized, check the status of the PTP clock synchronization.

Checking the Status of the PTP Clock Synchronization#

You must develop your own method for checking the status of the PTP clock synchronization using the blaze SDK.

Example of How to Check the PTP status

A typical implementation of a PTP status check includes the following steps:

  1. Enable PTP.
  2. Wait for the Best Master Clock algorithm to finish. To determine whether the algorithm has finished, perform the following steps in a loop until the PtpStatus parameter value for all cameras is either Master or Slave and no more than one camera returns Master as PtpStatus:
    1. Execute the PtpDataSetLatch command on each camera.
      The command allows you to take a "snapshot" of the camera's current PTP state. The "snapshot" implementation ensures that all parameter values refer to exactly the same point in time.
    2. Read the PtpStatus parameter for each camera.
  3. Wait until the clocks are sufficiently synchronized.
    See the following section for instruction how to verify this.
How to Check Whether the Clocks are Sufficiently Synchronized

Info

For this, use the PtpOffsetFromMaster parameter, which indicates how much a device's clock deviates from the clock of the master. You should wait until all these offsets are below a certain threshold (specified by you according to your requirements), e.g., 50 µs.
Due to the fact that the clock is adjusted continuously by a control mechanism, the offset will oscillate for a while around the master value with the amplitudes of the oscillations becoming smaller with time passing. Basler recommends checking that the maximum PtpOffsetFromMaster parameter value is below the threshold for a certain period of time, e.g., for 10 seconds.

  1. Define a threshold for the offset values depending on your application requirements, e.g., 50 µs.
  2. Define the length of the time window during which you want the offset values to be below the threshold.
  3. Read out the current system time and use it as the start of the time window during which you want to check the PtpOffsetFromMaster parameter value.
  4. Perform the following steps in a loop:
    1. On each camera, execute PtpDataSetLatch and read out the PtpOffsetFromMaster parameter value.
      Make a note of the values for later use.
    2. Find the highest offset value.
      • If one or more of the absolute offset values are above the threshold within the time window specified, reset the start of the time window to the current time and go back to step 1.
      • If all absolute offset values are below the threshold for the whole length of the time window, stop the loop.
        All clocks are sufficiently synchronized now.

The following figure shows how the offset from master changes over time. The time window is represented by the red rectangle. The smaller the absolute value of the offset from the master, the higher the precision.

PTP Offset From Master Amplitude