跳转到内容

Precision Time Protocol (blaze)#

Precision Time Protocol (PTP) 功能可让您同步同一网络中的多台 GigE 相机。

IEEE 1588标准定义了该协议。Basler 相机支持 IEEE 1588-2008,也称为 PTP 版本 2。

信息

PTP 同步的精度在很大程度上取决于您的网络硬件和设置。为了获得最高精度,请选择高质量的网络硬件、使用支持 PTP 的网络交换机,并向您的网络添加一个带有 GPS 接收器的外部 PTP 时钟设备。

该功能的使用#

为什么使用 PTP#

Precision Time Protocol (PTP) 功能可以让 blaze 相机使用 Synchronous Free Run (blaze) 功能。

通过 PTP,多台相机的时钟会自动与网络中找到的最准确时钟(称为主时钟或最佳主时钟)同步。

根据您的系统设置,主时钟可以是相机或外部设备:

  • 如果您的系统只包括相机,则各台相机将相互协商以确定最准确的相机时钟,然后将其用作主时钟。
  • 如果您的系统包括外部设备(例如 GPS 接收器或配置为主设备的其他计算机),则外部设备将充当主时钟。

当相机的时钟同步时,它们的 Timestamp 可以相互比较。

如果网络中的主时钟基于国际时间标准 TAI 来传递绝对时间(例如,通过 GPS 接收器),则可以从相机的同步时钟生成的 Timestamp 来确定本地时间。

如果主时钟未传递 TAI 时间,则这些时钟会同步运行,但它们的时间是随机的时标,这就是所谓的任意时标模式 (ARB)。在此模式下,纪元是任意的,因为它不受绝对时间的限制。而时标是相对的,即仅在该网络中有效。最佳的主时钟算法将选择具有最高稳定性和精度的时钟作为该网络的主时钟。充当主时钟的相机无法传递 TAI 时间,只能传递 ARB 时间。

启用 PTP 时钟同步#

开启相机电源时,始终禁用 PTP。如果要使用 PTP,必须自行启用。

要启用 PTP:

  1. 如果要将外部设备用作主时钟(例如 GPS 接收器),请将外部设备配置为主时钟。
  2. On all cameras that you want to synchronize via PTP, set the PtpEnable parameter to true.
  3. 等待全部 PTP 网络设备充分同步。根据您的网络设置,这可能需要几秒钟或几分钟。
    您可以通过检查设备的 PTP 时钟同步状态来确定何时实现设备同步。

检查 PTP 时钟同步的状态#

您必须开发自己的方法来使用 pylon SDK 检查 PTP 时钟同步的状态。

关于如何检查 PTP 状态的示例#

一个典型的 PTP 状态检查实例包含以下步骤:

  1. 启用 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. 等到时钟充分同步。
      请参阅以下部分,以获取有关如何进行验证的说明。
如何检查时钟是否充分同步#

信息

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. 根据您的应用要求定义偏离量的阈值,例如 50 µs。
  2. 定义您希望偏离量低于阈值的时窗长度。
  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. 循环执行以下步骤:
    1. On each camera, execute PtpDataSetLatch and read out the PtpOffsetFromMaster parameter value.
      Make a note of the values for later use.
    2. 查找最高偏离量。
      • 如果一个或多个绝对偏离量在指定的时窗内高于阈值,则将时窗的起始点重置为当前时间,然后返回步骤 1。
      • 如果所有绝对偏离量在整个时窗长度内均低于阈值,请停止循环。
        现在所有时钟都已充分同步。

下图显示了主时钟的偏离量如何随时间变化。时窗由红色矩形表示。偏离主时钟的绝对值越小,精度越高。

PTP 相对于主振幅的偏移

使用 PTP 同步 blaze 相机与 2D 相机的建议#

如果您要使用 PTP 将 2D 相机与 blaze 相机同步,请在配置网络时遵循以下建议。网络设置是导致同步失败的最常见原因。

  • 保持相机网络设置尽可能简单,例如,避免级联交换机/路由器。
  • 如果将管理型交换机与 IGMP 侦听装置配合使用,则应在交换机配置中为所有端口启用 IGMP 多播。否则,用于同步的 IGMP 包将被阻止。
  • 如要提高时钟精度,请使用提供 PTP 主时钟的 PTP 交换机/路由器。