コンテンツにスキップ

Precision Time Protocol#

Precision Time Protocol(PTP)カメラ機能を使用すると、同じネットワーク内の複数のGigEカメラを同期できます。

IEEE 1588規格でプロトコルが定義されています。Baslerカメラは、IEEE 1588-2008(PTP Version 2とも呼ばれる)をサポートしています。

情報

PTP同期の精度は、ネットワークのハードウェアとセットアップによって大きく異なります。最高の精度を得るには、高品質のネットワークハードウェアを選択し、PTP有効ネットワークスイッチを使用し、GPS受信機を備えた外部PTPクロックデバイスをネットワークに追加してください。

機能を使用する#

PTPを使用する理由#

Precision Time Protocol(PTP)機能を使用すると、カメラで次の機能を使用できます(使用可能な場合)。

仕組み#

PTPを使用すると、複数のデバイス(カメラなど)が、ネットワーク内にある最も正確なクロック(マスタークロック、またはベストマスタークロックと呼ばれる)と自動的に同期されます。

このプロトコルを使用すると、ネットワーク内のシステムで次のことが可能になります。

  • マスタークロックと同期させます。つまり、ローカルクロックをマスタークロックの時間にできるだけ精密に合わせて設定します。
  • マスタークロックと同調させます。つまり、ローカルクロックの周波数をマスタークロックの周波数に調整します。両方のデバイスで、1秒の継続時間を可能な限り同一にする必要があります。

マスタークロックは、いくつかの基準によって決定されます。優先順位が最も高い基準は、デバイスのPriority 1設定です。

Timestampの同期#

The basic concept of the Precision Time Protocol (IEEE 1588) is based on the exchange of PTP messages. These messages allow the slave clocks to synchronize their timestamp value with the timestamp value of the master clock. For Basler cameras, this means that their TimestampLatchValue parameter values will be as identical as possible. The precision highly depends on your network hardware and setup.

ネットワーク内のデバイスが協定世界時(TAIやUTCなど)に同期されていない場合、ネットワークは任意のタイムスケールモード(ARB)で動作します。このモードでは、絶対時間にバインドされないため、エポックは任意です。タイムスケールは相対的であり、このネットワーク内でのみ有効です。

情報

  • IEEE 1588では、時間情報を保存および転送するための80ビットタイムスタンプが定義されています。GigEVisionは64ビットのタイムスタンプを使用するため、PTPタイムスタンプはGigE Visionの64ビットのタイムスタンプにマッピングされます。
  • 他のPTP有効デバイスがないネットワークで動作するPTP有効デバイスは、ローカルクロックを統制しません。ローカルクロックの精度は、PTP無効デバイスと同じです。
  • Precision Time Protocolの詳細については、Synchronous and in Real Time: Multi-Camera Applications in the GigE Networkホワイトペーパーを参照してください。

PTP Clock Synchronizationの有効化#

カメラの電源をオンにすると、PTPは常に無効になります。PTPを使用する場合は、有効にする必要があります。

PTPを有効にするには、次の手順に従います。

  1. 外部デバイスをマスタークロック(GPSレシーバーなど)として使用する場合は、外部デバイスをマスタークロックとして設定します。
    Baslerは、ANNOUNCE間隔を2秒、SYNC間隔を0.5秒にすることをお勧めします。
  2. PTP経由で同期するすべてのカメラが正しく設定されていることを確認してください。
  3. On all cameras that you want to synchronize via PTP, set the GevIEEE1588 parameter to true.
  4. すべてのPTPネットワークデバイスが十分に同期されるまで待機します。ネットワークの設定によっては、数秒または数分かかる場合があります。
    PTPクロック同期のステータスを確認することで、デバイスが同期されるタイミングを確認できます。

これで、PTPが有効化されたカメラ機能を使用できるようになりました。

情報

ace Classic/Lカメラでは、PTPクロック同期を有効にすると、カメラの内部ティック周波数が125MHz(= 8nsティック持続時間)から1GHz(=1nsティック持続時間)に変更されます。Inter-packet DelayおよびFrame Transmission Delayパラメーター値は自動的に調整されます。
他のカメラでは、ティック周波数は常に1GHzです。

PTP Clock Synchronizationの設定#

お使いのカメラのモデルに応じて、次の設定を使用できます。

Priority 1#

PTPが有効なネットワークでは、マスタークロックがいくつかの基準によって決定されます。最も重要な基準は、デバイスのPriority 1設定です。Priority 1設定値が最も低いネットワークデバイスがマスタークロックです。

On ace 2 cameras, you can change the Priority 1 setting to force a camera to be the master clock, or to prevent a camera from being the master clock. To do so, set the BslPtpPriority1 parameter to a value between 0 (highest priority) and 255 (lowest priority).

他のカメラでは、Priority 1設定は128にプリセットされており、変更できません。

情報

マスタークロック基準の詳細については、IEEE 1588-2008仕様の7.6.2.2項を参照してください。

PTP Delay Mechanism#

遅延測定メカニズムは、ネットワーク内でPTP遅延測定メッセージを送受信する方法を定義します。PTP規格では、エンドツーエンド(E2E、「遅延要求応答」とも呼ばれる)とピアツーピア(P2P)の2つのメカニズムが定義されています。詳細については、この記事を参照してください。

On ace 2 cameras, you can change the delay measurement mechanism. To do so, set the BslPtpProfile parameter to DelayRequestResponseDefaultProfile (default) or PeerToPeerDefaultProfile.

他のカメラでは、遅延測定メカニズムはエンドツーエンドにプリセットされており、変更できません。

情報

  • ほとんどの場合、エンドツーエンドの遅延測定を使用します。ピアツーピアの遅延測定がネットワーク全体で設定されている場合にのみ、ピアツーピアを使用します。つまり、すべてのスイッチとルーターがPTP有効で、すべてのPTPデバイスがピアツーピア通信用に設定されている場合です。
  • ピアツーピア遅延測定を使用する場合は、次の制約事項が適用されます。

Network Mode#

ネットワークモード設定では、ネットワーク内でPTPメッセージを転送する方法が定義されます。

On ace 2 cameras, you can change the network mode. To do so, set the BslPtpNetworkMode parameter to one of the following values:

  • Multicast: PTP messages are sent to all devices in the local network that are configured for PTP multicasting. This is the default mode and sufficient for most use cases.
  • Hybrid: PTP messages are sent using multicast and unicast messages. This saves network load because fewer messages have to be processed. For more information, see this article.
  • ユニキャスト:PTPメッセージは、ローカルネットワーク内の1つ以上の指定されたデバイスに送信されます。他のデバイスは、PTPメッセージを受信できません。
    ユニキャストを設定するには、次の手順に従います。
    1. Make sure that the BslPtpNetworkMode is set to Unicast.
    2. Set the BslPtpUcPortAddrIndex parameter to 0.
    3. Set the BslPtpUcPortAddr parameter to the IP address of the first receiving device.
    4. Increase the BslPtpUcPortAddrIndex parameter by 1.
    5. Set the BslPtpUcPortAddr parameter to the IP address of the next receiving device.
    6. 関連するすべてのPTPデバイスについて、手順3と4を繰り返します。

他のカメラでは、ネットワークモードはマルチキャストにプリセットされています。ただし、これらのカメラはユニキャストメッセージを受信し、それに対応して応答することもできます。

情報

ユニキャストモードを使用する場合、関連するすべてのデバイスがユニキャストネゴシエーションをサポートしている必要があります。一部のPTP実装ではユニキャストネゴシエーションが使用されないため、Baslerカメラとの互換性はありません。

PTP Management#

PTP Management Protocolを使用すると、pylon APIを使用せずに、管理メッセージを介して任意のPTPデバイスの設定を読み取ることができます。許可されている場合は、設定を書き込むこともできます。

ace 2カメラでは、PTP管理の有効/無効を切り替えられます。これを行うには、次の手順に従います。

  1. PTPクロック同期を有効にします
  2. パラメーターを BslPtpManagementEnable パラメーターを次のいずれかの値に設定します。
    • true: You can read settings (GET), write settings (SET), and execute commands (COMMAND) using management messages with the message IDs listed below.
    • false (default): The PTP Management Protocol is disabled, and settings can neither be read nor written.

他のカメラでは、PTP管理は常に有効であり、読み取り専用アクセスにプリセットされています。

サポートされている管理メッセージ#
管理メッセージID サポートされているアクション
NULL_MANAGEMENT GET, SET
CLOCK_DESCRIPTION GET
USER_DESCRIPTION GET, SET
INITIALIZE COMMANDa
DEFAULT_DATA_SET GET
CURRENT_DATA_SET GET
PARENT_DATA_SET GET
TIME_PROPERTIES_DATA_SET GET
PORT_DATA_SET GET
PRIORITY1 GET, SET
PRIORITY2 GET, SET
DOMAIN GET
SLAVE_ONLY GET
LOG_ANNOUNCE_INTERVAL GET, SET
ANNOUNCE_RECEIPT_TIMEOUT GET, SET
LOG_SYNC_INTERVAL GET, SET
VERSION_NUMBER GET
ENABLE_PORT COMMAND
DISABLE_PORT COMMAND
TIME GET, SETb
CLOCK_ACCURACY GET, SET
UTC_PROPERTIES GET, SET
TRACEABLE_PROPERTIES GET, SET
TIMESCALE_PROPERTIES GET, SET
UNICAST_NEGOTIATION_ENABLE GET
ACCEPTABLE_MASTER_TABLE GET, SET
ACCEPTABLE_MASTER_TABLE_ENABLED GET, SET
ACCEPTABLE_MASTER_MAX_TABLE_SIZE GET
DELAY_MECHANISM GET, SET
LOG_MIN_PDELAY_REQ_INTERVAL GET, SET

  1. INITIALIZEコマンドは、クロック速度をリセットします。

  2. 対応するデバイスがグランドマスタークロックとして機能する場合にのみ設定できます。

これらの属性のデフォルト値および範囲については、IEEE 1588-2008 仕様の付録Jを参照してください。

One-StepまたはTwo-Step Clock#

この設定では、egressタイムスタンプが必要なPTPイベントメッセージに対して生成されるメッセージ数を定義します。

  • ワンステップ操作では、1つのメッセージが送信されます。メッセージには、メッセージデータとegressタイムスタンプが含まれます。
  • 2ステップ操作では、2つのメッセージが送信されます。最初のメッセージには、メッセージデータが含まれます。2番目のメッセージには、egressタイムスタンプが含まれます。

詳細については、この記事を参照してください。

On ace 2 cameras, two-step operation is disabled by default. If another PTP device in the network explicitly requires two-step event messages, you can enable them by setting the BslPtpTwoStep parameter to true.

他のカメラでは、2ステップ操作は常に有効になっています。

PTP Clock Synchronizationのステータスを確認する#

PTPクロック同期のステータスを確認するには、pylon APIを使用して独自のチェック方法を開発する必要があります。

PTPステータスチェックの一般的な実装には、次の手順が含まれます。

  1. Execute the GevIEEE1588DataSetLatch command.
    The command allows you to take a "snapshot" of the camera's current PTP state. The "snapshot" implementation ensures that all parameter values in the latched data set refer to exactly the same point in time.
  2. Wait until the GevIEEE1588Status parameter value is no longer Initializing.
  3. カメラのモデルに応じて、デバイスから次のパラメーター値を読み取ります。

    • On ace 2 cameras, read the PtpServoStatus parameter from all slave cameras. If the parameter value is Locked, the respective device should be sufficiently synchronized. If you need a more refined status check, follow the "other cameras" procedure below instead.
    • On other cameras, read the GevIEEE1588OffsetFromMaster parameter value from all slave cameras until the highest offset from master is below a certain threshold (according to your requirements, e.g., 1 millisecond).
      Due to the fact that the clock is continuously adjusted by a control mechanism, the offset is not decreasing monotonically. Basler recommends that you check the maximum GevIEEE1588OffsetFromMaster parameter value within a given time window:

      PTP Offset From Master Amplitude

  4. デバイスが十分に同期されるまで、手順1と2を繰り返します。

Latched Data Setの中身#

After executing the GevIEEE1588DataSetLatch command, you can read the following parameter values from the device:

  • GevIEEE1588ClockId: Indicates the unique ID of the current PTP device (the "clock ID").
  • GevIEEE1588OffsetFromMaster: Indicates the estimated temporal offset between the master clock and the clock of the current PTP device in ticks (1 tick = 1 nanosecond).
  • GevIEEE1588ParentClockId: Indicates the clock ID of the PTP device that currently serves as the master clock (the "parent clock ID").
  • GevIEEE1588Status: Indicates the state of the current PTP device, e.g., whether it is a master or a slave clock. The returned values match the PTP port state enumeration (Initializing, Faulty, Disabled, Listening, Pre_Master, Master, Passive, Uncalibrated, and Slave). For more information, refer to the pylon API documentation and the IEEE 1588-2008 specification.
  • GevIEEE1588StatusLatched: If this parameter is available, Basler recommends using it instead of the GevIEEE1588Status parameter. This is because the GevIEEE1588Status parameter is not tied to the GevIEEE1588DataSetLatch command. Therefore, if you read multiple PTP-related values from a device, the device state will not relate to the same point in time as the other values.
追加パラメーター#

On ace 2 cameras, after executing the PtpDataSetLatch command, you can read the following additional parameter values from the device:

  • BslPtpDelayMechanism: Indicates the delay mechanism used by the PTP network. A value of E2E indicates that the Delay Request-Response mechanism is used. A value of P2P indicates that the peer-to-peer mechanism is used.
  • PtpClockAccuracy: Indicates the expected accuracy of the PTP device clock when it is or becomes the grandmaster. On Basler cameras, the expected accuracy is preset to Unknown. This is because Basler cameras don't synchronize to a coordinated world time, e.g., UTC.
  • PtpGrandmasterClockID: Indicates the clock ID of the PTP device that currently serves as the grandmaster clock.
  • PtpServoStatus: Indicates the state of the clock servo, i.e., the state of the PTP clock synchronization. If the state is Locked, the clock of the current device is successfully synchronized with the master clock. In all other cases, the state is Unknown.

サンプルコード#

ace 2カメラ#
// ** Configure PTP **
// Set Priority 1 to 128
camera.BslPtpPriority1.SetValue(128);
// Enable end-to-end delay measurement
camera.BslPtpProfile.SetValue(BslPtpProfile_DelayRequestResponseDefaultProfile);
// Set the network mode to unicast
camera.BslPtpNetworkMode.SetValue(BslPtpNetworkMode_Unicast);
// Set the IP address of the first unicast device to 192.168.10.12
// (0xC0 = 192, 0xA8 = 168, 0x0A = 10, 0x0C = 12)
camera.BslPtpUcPortAddrIndex.SetValue(0);
camera.BslPtpUcPortAddr.SetValue((0xC0A80A0C);
// Enable PTP Management Protocol
camera.BslPtpManagementEnable.SetValue(true);
// Disable two-step operation
camera.BslPtpTwoStep.SetValue(false);
// ** Enable PTP on the current device **
camera.PtpEnable.SetValue(true);
// To check the status of the PTP clock synchronization,
// implement your own check method here.
// For guidelines, see "Checking the Status of
// the PTP Clock Synchronization" in this topic.
INodeMap& nodemap = camera.GetNodeMap();
// ** Configure PTP **
// Set Priority 1 to 128
CIntegerParameter(nodemap, "BslPtpPriority1").SetValue(128);
// Enable end-to-end delay measurement
CEnumParameter(nodemap, "BslPtpProfile").SetValue("DelayRequestResponseDefaultProfile");
// Set the network mode to unicast
CEnumParameter(nodemap, "BslPtpNetworkMode").SetValue("Unicast");
// Set the IP address of the first unicast device to 192.168.10.12
// (0xC0 = 192, 0xA8 = 168, 0x0A = 10, 0x0C = 12)
CIntegerParameter(nodemap, "BslPtpUcPortAddrIndex").SetValue(0);
CIntegerParameter(nodemap, "BslPtpUcPortAddr").SetValue(0xC0A80A0C);
// Enable PTP Management Protocol
CBooleanParameter(nodemap, "BslPtpManagementEnable").SetValue(true);
// Disable two-step operation
CBooleanParameter(nodemap, "BslPtpTwoStep").SetValue(false);
// ** Enable PTP on the current device **
CBooleanParameter(nodemap, "PtpEnable").SetValue(true);
// To check the status of the PTP clock synchronization,
// implement your own check method here.
// For guidelines, see "Checking the Status of
// the PTP Clock Synchronization" in this topic.
// ** Configure PTP **
// Set Priority 1 to 128
camera.Parameters[PLCamera.BslPtpPriority1].SetValue(128);
// Enable end-to-end delay measurement
camera.Parameters[PLCamera.BslPtpProfile].SetValue(PLCamera.BslPtpProfile.DelayRequestResponseDefaultProfile);
// Set the network mode to unicast
camera.Parameters[PLCamera.BslPtpNetworkMode].SetValue(PLCamera.BslPtpNetworkMode.Unicast);
// Set the IP address of the first unicast device to 192.168.10.12
// (0xC0 = 192, 0xA8 = 168, 0x0A = 10, 0x0C = 12)
camera.Parameters[PLCamera.BslPtpUcPortAddrIndex].SetValue(0);
camera.Parameters[PLCamera.BslPtpUcPortAddr].SetValue(0xC0A80A0C);
// Enable PTP Management Protocol
camera.Parameters[PLCamera.BslPtpManagementEnable].SetValue(true);
// Disable two-step operation
camera.Parameters[PLCamera.BslPtpTwoStep].SetValue(false);
// ** Enable PTP on the current device **
camera.Parameters[PLCamera.PtpEnable].SetValue(true);
// To check the status of the PTP clock synchronization,
// implement your own check method here.
// For guidelines, see "Checking the Status of
// the PTP Clock Synchronization" in this topic.
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
/* ** Configure PTP ** */
/* Set Priority 1 to 128 */
errRes = PylonDeviceSetIntegerFeature(hdev, "BslPtpPriority1", 128);
CHECK(errRes);
/* Enable end-to-end delay measurement */
errRes = PylonDeviceFeatureFromString(hdev, "BslPtpProfile", "DelayRequestResponseDefaultProfile");
CHECK(errRes);
/* Set the network mode to unicast */
errRes = PylonDeviceFeatureFromString(hdev, "BslPtpNetworkMode", "Unicast");
CHECK(errRes);
/* Set the IP address of the first unicast device to 192.168.10.12 */
/* (0xC0 = 192, 0xA8 = 168, 0x0A = 10, 0x0C = 12) */
errRes = PylonDeviceSetIntegerFeature(hdev, "BslPtpUcPortAddrIndex", 0);
CHECK(errRes);
errRes = PylonDeviceSetIntegerFeature(hdev, "BslPtpUcPortAddr", 0xC0A80A0C);
CHECK(errRes);
/* Enable PTP Management Protocol */
errRes = PylonDeviceSetBooleanFeature(hdev, "BslPtpManagementEnable", 1);
CHECK(errRes);
/* Disable two-step operation */
errRes = PylonDeviceSetBooleanFeature(hdev, "BslPtpTwoStep", 0);
CHECK(errRes);
/* ** Enable PTP on the current device ** */
errRes = PylonDeviceSetBooleanFeature(hdev, "PtpEnable", 1);
CHECK(errRes);
/* To check the status of the PTP clock synchronization, */
/* implement your own check method here. */
/* For guidelines, see "Checking the Status of */
/* the PTP Clock Synchronization" in this topic. */
# ** Configure PTP **
# Set Priority 1 to 128
camera.BslPtpPriority1.Value = 128
# Enable end-to-end delay measurement
camera.BslPtpProfile.Value = "DelayRequestResponseDefaultProfile"
# Set the network mode to unicast
camera.BslPtpNetworkMode.Value = "Unicast"
# Set the IP address of the first unicast device to 192.168.10.12
# (0xC0 = 192, 0xA8 = 168, 0x0A = 10, 0x0C = 12)
camera.BslPtpUcPortAddrIndex.Value = 0
camera.BslPtpUcPortAddr.Value = 0xC0A80A0C
# Enable PTP Management Protocol
camera.BslPtpManagementEnable.Value = True
# Disable two-step operation
camera.BslPtpTwoStep.Value = False
# ** Enable PTP on the current device **
camera.PtpEnable.Value = True
# To check the status of the PTP clock synchronization,
# implement your own check method here.
# For guidelines, see "Checking the Status of
# the PTP Clock Synchronization" in this topic.
その他のカメラ#
// Enable PTP on the current device
camera.GevIEEE1588.SetValue(true);
// To check the status of the PTP clock synchronization,
// implement your own check method here.
// For guidelines, see "Checking the Status of
// the PTP Clock Synchronization" in this topic.
INodeMap& nodemap = camera.GetNodeMap();
// Enable PTP on the current device
CBooleanParameter(nodemap, "GevIEEE1588").SetValue(true);
// To check the status of the PTP clock synchronization,
// implement your own check method here.
// For guidelines, see "Checking the Status of
// the PTP Clock Synchronization" in this topic.
// Enable PTP on the current device
camera.Parameters[PLCamera.GevIEEE1588].SetValue(true);
// To check the status of the PTP clock synchronization,
// implement your own check method here.
// For guidelines, see "Checking the Status of
// the PTP Clock Synchronization" in this topic.
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK;  /* Return value of pylon methods */
/* Enable PTP on the current device */
errRes = PylonDeviceSetBooleanFeature(hdev, "GevIEEE1588", 1);
CHECK(errRes);
/* To check the status of the PTP clock synchronization, */
/* implement your own check method here. */
/* For guidelines, see "Checking the Status of */
/* the PTP Clock Synchronization" in this topic. */
# Enable PTP on the current device
camera.GevIEEE1588.Value = True
# To check the status of the PTP clock synchronization,
# implement your own check method here.
# For guidelines, see "Checking the Status of
# the PTP Clock Synchronization" in this topic.

pylon Viewerを使用して、パラメーターを簡単に設定することもできます。