콘텐츠로 바로 가기
스테이징 서버
개발 서버

Encoder Control#

Encoder Control camera feature를 사용하면 구적 엔코더를 제어하고 모니터링할 수 있습니다.

구적 엔코더는 증분식, 로터리 또는 샤프트 엔코더로도 알려져 있습니다. 이들은 일반적으로 모션이나 위치 변화를 측정해야 하는 자동화 애플리케이션에서 사용됩니다.

Encoder Control 기능은 Basler racer 2 카메라에서만 사용할 수 있습니다.

Using the Feature#

작동 방식#

Encoder Control은 로터리 방식 또는 리니어 방식일 수 있으며 두 개의 출력 신호 A와 B를 생성하는 구적 엔코더에 연결됩니다. 이들은 위상 또는 소스 A 및 B라고도 합니다. 두 신호는 90°의 위상 차이를 가지며, 이를 통해 엔코더의 전진 및 후진 방향 모션을 추적합니다. A 및 B 위상은 카메라 엔코더 제어를 위한 입력 신호입니다.

다음 이미지는 엔코더 제어의 일반적인 구현을 보여줍니다.

일반적인 Encoder Control 구현

Encoder Direction of Motion#

엔코더는 전진 또는 후진 방향으로 이동할 수 있습니다. 모션 방향을 감지하기 위해 Encoder Control은 A 및 B 신호의 상승 에지와 하강 에지의 순서를 읽습니다.

  • 전진 방향 모션: A 신호가 B 신호보다 90° 앞서 상승합니다. 위상 순서는 1-2-3-4입니다.
  • 후진 방향 모션: B 신호가 A 신호보다 앞서 상승합니다. 위상 순서는 4-3-2-1입니다.

다음 이미지는 A 및 B 신호의 디지털 신호 수준에 해당하는 네 가지 위상을 보여줍니다.

A 및 B 신호 간의 관계

Position Counter#

Encoder Control은 A 및 B 신호에 의해 구동되는 Counter를 사용합니다. Counter 값은 전진 방향 모션에서 증가하고 후진 방향 모션에서 감소합니다.

Position Counter는 지속적으로 실행됩니다. 그 값은 마지막 재설정 이후 수신된 들어오는 신호의 수를 나타냅니다. 따라서 Counter 값은 항상 전진 또는 후진 방향 모션과 관련하여 대상 객체의 현재 위치를 반영합니다.

Encoder Mode#

Encoder mode는 들어오는 엔코더 신호가 Encoder Control에 의해 계산되는 방식을 제어합니다.

Four Phase Mode#

완전히 완료된 네 개의 신호 위상이 하나의 구적 주기를 형성합니다. 전체 구적 주기마다, 즉 A 신호 에지가 상승할 때 구적 엔코더 Counter가 1씩 증가하거나 감소합니다.

Four Phase 모드는 매우 견고하며 두 위상 간의 적은 양의 신호 지터를 필터링할 수 있습니다.

Four Phase Mode

High Resolution Mode#

High Resolution 모드에서는 주기당 카운트가 4배가 됩니다. 각 신호 위상에서, 즉 A 및 B 신호 에지가 상승 및 하강할 때 엔코더 Counter가 1씩 증가 또는 감소합니다.

High Resolution Mode

정보

High Resolution 모드에서는 지터 필터링이 불가능합니다. 따라서 High Resolution 모드는 다음과 함께 사용하는 것을 권장하지 않습니다. encoder output mode (으)로 설정됨 Motion 두 위상 간의 지터가 지속적인 출력 트리거 펄스를 발생시킬 수 있기 때문입니다.

Encoder Output Mode#

encoder output mode를 사용하면 Encoder Control이 유효한 출력 신호를 생성하기 위한 조건을 설정할 수 있습니다. 다음과 같은 encoder output mode를 사용할 수 있습니다.

  • Motion: 모션 방향과 관계없이 출력 트리거 신호가 생성됩니다.
  • DirectionUp: 모든 위치 증가분에서 출력 트리거 신호가 생성됩니다. forward 방향입니다. 역방향 움직임은 무시됩니다.
  • DirectionDown: 모든 위치 증가분에서 출력 트리거 신호가 생성됩니다. 역방향 방향입니다. 정방향 움직임은 무시됩니다.
  • PositionUp: 모든 위치에서 출력 Trigger 신호가 생성되며, new 다음 위치에서 forward 방향입니다. 엔코더가 역회전하면, 반전이 시작된 위치를 다시 통과할 때까지 출력 Trigger 신호가 생성되지 않습니다.
  • PositionDown: 모든 위치에서 출력 Trigger 신호가 생성되며, new 다음 위치에서 역방향 방향입니다. 엔코더가 역회전하면, 반전이 시작된 위치를 다시 통과할 때까지 출력 Trigger 신호가 생성되지 않습니다.
  • Off: 출력 Trigger 신호가 생성되지 않습니다.

추가 Parameter#

  • EncoderDivider: Encoder Control 출력 Trigger 신호를 생성하는 데 필요한 엔코더 입력 신호 수를 결정합니다.
  • EncoderValue: Position Counter의 현재 값을 가져옵니다. 이 Parameter는 읽기 전용입니다.
  • EncoderReset: Position Counter의 현재 Counter 값을 0으로 재설정합니다. 이 작업은 또한 전체 Encoder Control을 재설정하고 다시 시작합니다. 신호 펄스는 재시작 직후에 카운트됩니다.

Encoder Control 구성#

Encoder Control을 구성하려면:

  1. 다음 파라미터를 EncoderSelector 파라미터(Parameter) Encoder1.
  2. 다음 파라미터를 EncoderSourceA Parameter를 사용 가능한 소스 신호 중 하나로 설정합니다(예: Line2.
  3. 다음 파라미터를 EncoderSourceB Parameter를 사용 가능한 소스 신호 중 하나로 설정합니다(예: Line3.
  4. 다음 파라미터를 EncoderMode Parameter를 다음 값 중 하나로 설정하십시오.
  5. 다음 파라미터를 EncoderDivider Parameter를 원하는 입력 신호 수로 설정합니다.
  6. 다음 파라미터를 EncoderOutputMode Parameter를 다음 유형으로 설정합니다. output mode 활성화하려는 항목(예: Motion.

엔코더 신호에 의해 카메라가 Trigger되도록 구성하려면:

  1. 다음 파라미터를 TriggerSelector 파라미터(Parameter) LineStart.
  2. 다음 파라미터를 TriggerMode 파라미터(Parameter) On.
  3. 다음 파라미터를 TriggerSource 파라미터(Parameter) Encoder1.

Sample Code#

// Select the desired encoder selector
camera.EncoderSelector.SetValue(EncoderSelector_Encoder1)
// Select line 2 as the source signal for the A input of the encoder control
camera.EncoderSourceA.SetValue(EncoderSourceA_Line2);
// Select line 3 as the source signal for the B input of the encoder control
camera.EncoderSourceB.SetValue(EncoderSourceB_Line3);
// Select the desired encoder mode
camera.EncoderMode.SetValue(EncoderMode_FourPhase);
// Determine the number of input signals needed to generate an encoder output trigger signal
camera.EncoderDivider.SetValue(1);
// Select the desired encoder output mode
camera.EncoderOutputMode.SetValue(EncoderOutputMode_Motion);
INodeMap& nodemap = camera.GetNodeMap();
// Select the desired encoder selector
CEnumParameter(nodemap, "EncoderSelector").SetValue("Encoder1");
// Select line 2 as the source signal for the A input of the encoder control
CEnumParameter(nodemap, "EncoderSourceA").SetValue("Line2");
// Select line 3 as the source signal for the B input of the encoder control
CEnumParameter(nodemap, "EncoderSourceB").SetValue("Line3");
// Select the desired encoder mode
CEnumParameter(nodemap, "EncoderMode").SetValue("FourPhase");
// Determine the number of input signals needed to generate an encoder output trigger signal
CIntegerParameter(nodemap, "EncoderDivider").SetValue(1);
// Select the desired encoder output mode
CEnumParameter(nodemap, "EncoderOutputMode").SetValue("Motion");
// Select the desired encoder selector
camera.Parameters[PLCamera.EncoderSelector].SetValue(PLCamera.EncoderSelector.Encoder1);
// Select line 2 as the source signal for the A input of the encoder control
camera.Parameters[PLCamera.EncoderSourceA].SetValue(PLCamera.EncoderSourceA.Line2);
// Select line 3 as the source signal for the B input of the encoder control
camera.Parameters[PLCamera.EncoderSourceB].SetValue(PLCamera.EncoderSourceB.Line3);
// Select the desired encoder mode
camera.Parameters[PLCamera.EncoderMode].SetValue(PLCamera.EncoderMode.FourPhase);
// Determine the number of input signals needed to generate an encoder output trigger signal
camera.Parameters[PLCamera.EncoderDivider].SetValue(1);
// Select the desired encoder output mode
camera.Parameters[PLCamera.EncoderOutputMode].SetValue(PLCamera.EncoderOutputMode.Motion);
/* 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 */
/* Select the desired encoder selector */
errRes = PylonDeviceFeatureFromString(hdev, "EncoderSelector", "Encoder1");
CHECK(errRes);
/* Select line 2 as the source signal for the A input of the encoder control */
errRes = PylonDeviceFeatureFromString(hdev, "EncoderSourceA", "Line2");
CHECK(errRes);
/* Select line 3 as the source signal for the B input of the encoder control */
errRes = PylonDeviceFeatureFromString(hdev, "EncoderSourceB", "Line3");
CHECK(errRes);
/* Select the desired encoder mode */
errRes = PylonDeviceFeatureFromString(hdev, "EncoderMode", "FourPhase");
CHECK(errRes);
/* Determine the number of input signals needed to generate an encoder output trigger signal */
errRes = PylonDeviceSetIntegerFeature(hdev, "EncoderDivider", 1);
CHECK(errRes);
/* Select the desired encoder output mode */
errRes = PylonDeviceFeatureFromString(hdev, "EncoderOutputMode", "Motion");
CHECK(errRes);
# Select the desired encoder selector
camera.EncoderSelector.Value = "Encoder1"
# Select line 2 as the source signal for the A input of the encoder control
camera.EncoderSourceA.Value = "Line2"
# Select line 3 as the source signal for the B input of the encoder control
camera.EncoderSourceB.Value = "Line3"
# Select the desired encoder mode
camera.EncoderMode.Value = "FourPhase"
# Determine the number of input signals needed to generate an encoder output trigger signal
camera.EncoderDivider.Value = 1
# Select the desired encoder output mode
camera.EncoderOutputMode.Value = "Motion"

또한 pylon Viewer를 사용하여 파라미터를 간편하게 설정할 수 있습니다.