Precision Time Protocol (blaze)#
The IEEE 1588 standard defines the protocol. Basler cameras support IEEE 1588-2008, also known as PTP Version 2.
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:
- 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.
- On all cameras that you want to synchronize via PTP, set the
- 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 pylon SDK.
Example of How to Check the PTP status#
A typical implementation of a PTP status check includes the following steps:
- Enable PTP.
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
PtpStatusparameter value for all cameras is either
Slaveand no more than one camera returns
- Execute the
PtpDataSetLatchcommand 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.
- Read the
PtpStatusparameter for each camera.
- Wait until the clocks are sufficiently synchronized.
See the following section for instruction how to verify this.
- Execute the
How to Check Whether the Clocks are Sufficiently Synchronized#
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.
- Define a threshold for the offset values depending on your application requirements, e.g., 50 µs.
- Define the length of the time window during which you want the offset values to be below the threshold.
- Read out the current system time and use it as the start of the time window during which you want to check the
- Perform the following steps in a loop:
- On each camera, execute
PtpDataSetLatchand read out the
Make a note of the values for later use.
- 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.
- On each camera, execute
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.
Recommendations for Using PTP to Synchronize blaze Cameras and 2D Cameras#
If you want to use PTP to synchronize 2D cameras with a blaze camera, follow these recommendations when configuring your network. Network settings are the most common cause for synchronization failures.
- Keep the camera network setup as simple as possible, e.g., avoid switch/router cascading.
- If you're using a managed switch with IGMP snooping, IGMP multicast should be enabled for all ports in the switch configuration. Otherwise, IGMP packages that are used for synchronization will be blocked.
- If you want to improve the clock precision, use PTP switches/routers that provide a PTP grandmaster clock.