Encoder Control#
구직교 인코더는 인크리멘탈, 로터리 또는 샤프트 인코더로도 알려져 있습니다. 이들은 일반적으로 모션이나 위치 변화를 측정해야 하는 자동화 애플리케이션에서 사용됩니다.
Encoder Control 기능은 Basler racer 2 카메라에서만 사용할 수 있습니다.
기능 사용법#
작동 원리#
Encoder Control은 두 개의 출력 신호 A와 B를 생성하는 회전형 또는 선형 구직교 인코더에 연결됩니다. 이들은 위상 또는 소스 A 및 B라고도 불립니다. 두 신호는 인코더의 전진 및 후진 모션 방향을 추적하는 데 사용되는 90°의 위상 차이를 가집니다. 위상 A와 B는 카메라의 encoder control을 위한 입력 신호입니다.
다음 이미지는 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 신호의 디지털 신호 레벨에 해당하는 네 가지 위상을 보여줍니다.
Position Counter#
Encoder control은 A 및 B 신호로 구동되는 position counter를 사용합니다. 카운터 값은 전진 모션 방향에서 증가하고 후진 모션 방향에서 감소합니다.
Position counter는 연속적으로 실행됩니다. 이 값은 마지막 재설정 이후 수신된 들어오는 신호의 수를 나타냅니다. 따라서 카운터 값은 전진 또는 후진 모션 방향과 관련하여 타겟 객체의 현재 위치를 항상 반영합니다.
Encoder Mode#
Encoder mode는 들어오는 인코더 신호가 encoder control에 의해 계산되는 방식을 제어합니다.
Four Phase Mode#
완전히 완료된 네 가지 신호 위상이 하나의 직교 주기를 형성합니다. 모든 전체 직교 주기마다, 즉 A 신호 에지가 상승할 때 quadrature encoder counter가 1씩 증가하거나 감소합니다.
Four Phase 모드는 매우 견고하며 두 위상 간의 소량의 신호 지터를 필터링할 수 있습니다.
High Resolution Mode#
High Resolution 모드에서는 주기당 카운트가 4배가 됩니다. 인코더 카운터는 각 신호 위상에서, 즉 A 및 B 신호 에지가 상승 및 하강할 때 1씩 증가 또는 감소합니다.
정보
High Resolution 모드에서는 지터 필터링이 불가능합니다. 따라서 High Resolution 모드를 다음 기능과 함께 사용하는 것은 권장되지 않습니다. encoder output mode 로 설정된 Motion 두 위상 간의 지터로 인해 연속적인 출력 트리거 펄스가 발생할 수 있기 때문입니다.
Encoder Output Mode#
Encoder output mode를 사용하면 encoder control이 유효한 출력 신호를 생성하기 위한 조건을 설정할 수 있습니다. 다음과 같은 encoder output mode를 사용할 수 있습니다.
Motion: 모션 방향과 관계없이 출력 트리거 신호가 생성됩니다.DirectionUp: 모든 위치 증가에서 출력 트리거 신호가 생성됩니다. 순방향 방향입니다. 후진 모션 방향은 무시됩니다.DirectionDown: 모든 위치 증가에서 출력 트리거 신호가 생성됩니다. 역방향 방향. 전진 방향의 움직임은 무시됩니다.PositionUp: 모든 위치에서 출력 트리거 신호가 생성됩니다. 신규 위치에서 순방향 방향. 인코더가 역회전하는 경우, 방향 전환이 시작된 위치를 다시 통과할 때까지 출력 트리거 신호가 생성되지 않습니다.PositionDown: 모든 위치에서 출력 트리거 신호가 생성됩니다. 신규 위치에서 역방향 방향. 인코더가 역회전하는 경우, 방향 전환이 시작된 위치를 다시 통과할 때까지 출력 트리거 신호가 생성되지 않습니다.Off: 출력 트리거 신호가 생성되지 않습니다.
추가 Parameters#
EncoderDivider: 인코더 출력 트리거 신호를 생성하는 데 필요한 인코더의 입력 신호 수를 결정합니다.EncoderValue: position counter의 현재 값을 가져옵니다. 이 파라미터는 읽기 전용입니다.EncoderReset: position counter의 현재 카운터 값을 0으로 재설정합니다. 이는 또한 전체 Encoder Control을 재설정하고 다시 시작합니다. 재시작 직후 신호 펄스가 카운트됩니다.
Encoder Control 구성하기#
Encoder Control을 구성하려면:
- 다음 값 중 하나로
EncoderSelector매개변수:Encoder1. - 다음 값 중 하나로
EncoderSourceA파라미터를 사용 가능한 소스 신호 중 하나로 설정합니다(예:Line2. - 다음 값 중 하나로
EncoderSourceB파라미터를 사용 가능한 소스 신호 중 하나로 설정합니다(예:Line3. - 다음 값 중 하나로
EncoderMode매개변수를 다음 값 중 하나로 설정합니다: - 다음 값 중 하나로
EncoderDivider파라미터를 원하는 입력 신호 수로 설정합니다. - 다음 값 중 하나로
EncoderOutputMode파라미터를 다음 종류로 설정합니다: output mode 활성화하려는 항목(예:Motion.
인코더 신호에 의해 카메라가 트리거되도록 구성하려면:
- 다음 값 중 하나로
TriggerSelector매개변수:LineStart. - 다음 값 중 하나로
TriggerMode매개변수:On. - 다음 값 중 하나로
TriggerSource매개변수:Encoder1.
샘플 코드#
// 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를 사용하여 파라미터를 손쉽게 설정할 수 있습니다.