跳转到内容

Periodic Signal#

相机的 Periodic Signal 功能使您可以生成在不同设备间同步的周期性触发信号。

例如,借助该功能,您能同时在多台相机上以相同的帧速率采集图像。

此功能类似于 Synchronous Free Run 功能,但除了图像采集外,它还可以用于其他用途。

该功能的使用#

运作原理#

Basler cameras supporting the Periodic Signal feature provide an additional camera signal source, PeriodicSignal1. Via this source, the camera transmits a signal with the following characteristics:

  • 信号是重复的。
  • 信号可以通过 Precision Time Protocol 在各设备间同步。
  • 可以配置信号的周期。
  • 可以配置第一个周期之前的延迟。

即: PeriodicSignal1 signal source can be used for many different purposes, e.g., to synchronize counters or image acquisition across devices.

使用 Periodic Signal 同步图像采集#

要在多台相机上同步图像采集,请执行以下操作:

  1. 打开要使用 Periodic Signal 进行同步的其中一台相机。
  2. Make sure that the BslPeriodicSignalSource parameter on the camera is set to PtpClock.
    This indicates that the camera is synchronized via the Precision Time Protocol feature.
  3. 设置 BslPeriodicSignalPeriod parameter to the reciprocal of the desired frame rate, converted to microseconds. For example, if you want to synchronize the cameras at 50 frames per second, set the parameter to 20000 (1 / 50 = 0.02 seconds = 20000 microseconds). You must specify the same parameter value on all cameras.
  4. 配置 periodic signal 延迟:
    • If you want all cameras to acquire images at the same time, set the BslPeriodicSignalDelay parameter to 0 on all cameras.
    • If you want all cameras to acquire images sequentially, i.e, in regular intervals, set the BslPeriodicSignalDelay parameter to 0 on the first camera and to multiples of the desired interval on the other cameras.
      For example, assume you want to acquire images with an interval of 10000 µs between cameras. To do so, set the delay to 0 on the first camera, to 10000 on the second camera, to 20000 on the third camera, and so on.
  5. 将相机配置为由 periodic signal 触发:
    1. 设置 TriggerSelector parameter to FrameStart.
    2. 设置 TriggerMode parameter to .
    3. 设置 TriggerSource parameter to PeriodicSignal1.
  6. 对所有相机重复步骤 1 至 5。

使用 Periodic Signal 同步触发外部设备#

您可以使用 Periodic Signal 功能同步触发外部设备。这样您可以将非 PTP 设备设为支持 PTP 功能。

相机的内部 periodic signal 不能用作 I/O 信号。但是,您可以使用 periodic signal 触发相机的 Timer 功能,然后将 timer 信号用作 I/O 信号。

为此:

  1. 打开要用于触发外部设备的相机。
  2. Make sure that the BslPeriodicSignalSource parameter on the camera is set to PtpClock.
    This indicates that the camera is synchronized via the Precision Time Protocol feature.
  3. 设置 BslPeriodicSignalPeriod parameter to the reciprocal of the desired trigger rate, converted to microseconds. For example, if you want to generate 20 trigger signals per second, set the parameter to 50000 (1/20 = 0.05 seconds = 50000 microseconds).
  4. If you want to trigger the external device with a time delay, set the BslPeriodicSignalDelay parameter to the desired delay.
  5. 配置相机的 Timer 功能以由 periodic signal 触发:
    1. 设置 TimerSelector parameter to Timer1.
    2. 设置 TimerDuration parameter to the desired timer duration in microseconds.
      The camera will send an I/O signal with a width equal to this value. Therefore, set a parameter value high enough for the external device to be able to receive the signal. In most cases, the default value of 10 µs should be sufficient.
    3. 设置 TimerTriggerSource parameter to PeriodicSignal1.
  6. 配置相机以输出 timer 信号:
    1. 设置 LineSelector parameter to the desired I/O line, e.g., Line2. The line must be configured as output.
    2. 设置 LineSource parameter to Timer1Active.
  7. 将外部设备连接到在步骤 6 中选择的输出线路。
    设备现已在此线路上接收同步的触发信号。
  8. If you want to trigger another external device, repeat steps 1 to 6, using Timer2 and Timer2Active in steps 5 and 6.

信息

您还可以在相机之间同步图像采集,使用相同的 periodic signal 同步触发外部设备。为此,请执行上面详细介绍的两个过程。

附加参数#

  • BslPeriodicSignalSelector: Sets the periodic signal channel to be configured. Because all Basler cameras currently offer one channel, this parameter is preset to PeriodicSignal1 and can't be changed.

示例代码#

/* Using Periodic Signal to Synchronize Image Acquisition */
// Set the signal period to 20000 µs
camera.BslPeriodicSignalPeriod.SetValue(20000.0);
// Set the signal delay to 0
camera.BslPeriodicSignalDelay.SetValue(0);
// Configure the camera to be triggered by the periodic signal
camera.TriggerSelector.SetValue(TriggerSelector_FrameStart);
camera.TriggerMode.SetValue(TriggerMode_On);
camera.TriggerSource.SetValue(TriggerSource_PeriodicSignal1);

/* Using Periodic Signal to Synchronously Trigger External Devices */
// Set the signal period to 50000 µs
camera.BslPeriodicSignalPeriod.SetValue(50000.0);
// Set the signal delay to 0
camera.BslPeriodicSignalDelay.SetValue(0);
// Configure the camera's Timer feature to be triggered by periodic signals
camera.TimerSelector.SetValue(TimerSelector_Timer1);
camera.TimerDuration.SetValue(10.0);
camera.TimerTriggerSource.SetValue(TimerTriggerSource_PeriodicSignal1);
// Configure the camera to output the timer signal on Line 2
camera.LineSelector.SetValue(LineSelector_Line2);
camera.LineMode.SetValue(LineMode_Output);
camera.LineSource.SetValue(LineSource_Timer1Active);
INodeMap& nodemap = camera.GetNodeMap();
/*Using Periodic Signal to Synchronize Image Acquisition*/

CFloatParameter(nodemap, "BslPeriodicSignalPeriod").SetValue(20000.0);
// Set the signal delay to 0
CIntegerParameter(nodemap, "BslPeriodicSignalDelay").SetValue(0);
// Configure the camera to be triggered by the periodic signal
CEnumParameter(nodemap, "TriggerSelector").SetValue("FrameStart");
CEnumParameter(nodemap, "TriggerMode").SetValue("On");
CEnumParameter(nodemap, "TriggerSource").SetValue("PeriodicSignal1");

/*Using Periodic Signal to Synchronously Trigger External Devices*/

CFloatParameter(nodemap, "BslPeriodicSignalPeriod").SetValue(50000.0);
// Set the signal delay to 0
CIntegerParameter(nodemap, "BslPeriodicSignalDelay").SetValue(0);
// Configure the camera's Timer feature to be triggered by periodic signals
CEnumParameter(nodemap, "TimerSelector").SetValue("Timer1");
CFloatParameter(nodemap, "TimerDuration").SetValue(10.0);
CEnumParameter(nodemap, "TimerTriggerSource").SetValue("PeriodicSignal1");
// Configure the camera to output the timer signal on Line 2
CEnumParameter(nodemap, "LineSelector").SetValue("Line2");
CEnumParameter(nodemap, "LineMode").SetValue("Output");
CEnumParameter(nodemap, "LineSource").SetValue("Timer1Active");
/*Using Periodic Signal to Synchronize Image Acquisition*/

camera.Parameters[PLCamera.BslPeriodicSignalPeriod].SetValue(20000.0);
// Set the signal delay to 0
camera.Parameters[PLCamera.BslPeriodicSignalDelay].SetValue(0);
// Configure the camera to be triggered by the periodic signal
camera.Parameters[PLCamera.TriggerSelector].SetValue(PLCamera.TriggerSelector.FrameStart);
camera.Parameters[PLCamera.TriggerMode].SetValue(PLCamera.TriggerMode.On);
camera.Parameters[PLCamera.TriggerSource].SetValue(PLCamera.TriggerSource.PeriodicSignal1);

/*Using Periodic Signal to Synchronously Trigger External Devices*/

camera.Parameters[PLCamera.BslPeriodicSignalPeriod].SetValue(50000.0);
// Set the signal delay to 0
camera.Parameters[PLCamera.BslPeriodicSignalDelay].SetValue(0);
// Configure the camera's Timer feature to be triggered by periodic signals
camera.Parameters[PLCamera.TimerSelector].SetValue(PLCamera.TimerSelector.Timer1);
camera.Parameters[PLCamera.TimerDuration].SetValue(10.0);
camera.Parameters[PLCamera.TimerTriggerSource].SetValue(PLCamera.TimerTriggerSource.PeriodicSignal1);
// Configure the camera to output the timer signal on Line 2
camera.Parameters[PLCamera.LineSelector].SetValue(PLCamera.LineSelector.Line2);
camera.Parameters[PLCamera.LineMode].SetValue(PLCamera.LineMode.Output);
camera.Parameters[PLCamera.LineSource].SetValue(PLCamera.LineSource.Timer1Active);
/* 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 */
/*Using Periodic Signal to Synchronize Image Acquisition*/

errRes = PylonDeviceSetFloatFeature(hdev, "BslPeriodicSignalPeriod", 20000.0);
CHECK(errRes);
/* Set the signal delay to 0 */
errRes = PylonDeviceSetIntegerFeature(hdev, "BslPeriodicSignalDelay", 0);
CHECK(errRes);
/* Configure the camera to be triggered by the periodic signal */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerSelector", "FrameStart");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "TriggerMode", "On");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "TriggerSource", "PeriodicSignal1");
CHECK(errRes);

/*Using Periodic Signal to Synchronously Trigger External Devices*/

errRes = PylonDeviceSetFloatFeature(hdev, "BslPeriodicSignalPeriod", 50000.0);
CHECK(errRes);
/* Set the signal delay to 0 */
errRes = PylonDeviceSetIntegerFeature(hdev, "BslPeriodicSignalDelay", 0);
CHECK(errRes);
/* Configure the camera's Timer feature to be triggered by periodic signals */
errRes = PylonDeviceFeatureFromString(hdev, "TimerSelector", "Timer1");
CHECK(errRes);
errRes = PylonDeviceSetFloatFeature(hdev, "TimerDuration", 10.0);
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "TimerTriggerSource", "PeriodicSignal1");
CHECK(errRes);
/* Configure the camera to output the timer signal on Line 2 */
errRes = PylonDeviceFeatureFromString(hdev, "LineSelector", "Line2");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "LineMode", "Output");
CHECK(errRes);
errRes = PylonDeviceFeatureFromString(hdev, "LineSource", "Timer1Active");
CHECK(errRes);
# Using Periodic Signal to Synchronize Image Acquisition
camera.BslPeriodicSignalPeriod.Value = 20000.0
# Set the signal delay to 0
camera.BslPeriodicSignalDelay.Value = 0
# Configure the camera to be triggered by the periodic signal
camera.TriggerSelector.Value = "FrameStart"
camera.TriggerMode.Value = "On"
camera.TriggerSource.Value = "PeriodicSignal1"

# Using Periodic Signal to Synchronously Trigger External Devices
camera.BslPeriodicSignalPeriod.Value = 50000.0
# Set the signal delay to 0
camera.BslPeriodicSignalDelay.Value = 0
# Configure the camera's Timer feature to be triggered by periodic signals
camera.TimerSelector.Value = "Timer1"
camera.TimerDuration.Value = 10.0
camera.TimerTriggerSource.Value = "PeriodicSignal1"
# Configure the camera to output the timer signal on Line 2
camera.LineSelector.Value = "Line2"
camera.LineMode.Value = "Output"
camera.LineSource.Value = "Timer1Active"

您也可以使用 pylon Viewer 轻松设置参数。