コンテンツにスキップ
ステージングサーバー
開発サーバー

Encoder Control#

Encoder Control カメラ機能を使用すると、直交エンコーダーの制御と監視を行うことができます。

直交エンコーダーは、インクリメンタル、ロータリー、またはシャフトエンコーダーとも呼ばれます。通常、動きや位置の変化を測定する必要がある自動化アプリケーションで使用されます。

Encoder Control機能は、Basler racer 2カメラでのみ使用できます。

機能を使用する#

仕組み#

Encoder Controlは、ロータリーまたはリニアのいずれかで、2つの出力信号AおよびBを生成する直交エンコーダーに接続されます。これらは、フェーズまたはソースAおよびBとも呼ばれます。これら2つの信号には90°の位相差があり、エンコーダーの前進および後退の移動方向を追跡するために使用されます。フェーズAおよびBは、カメラのエンコーダー制御の入力信号です。

次の画像は、エンコーダー制御の一般的な実装を示しています。

一般的なEncoder Controlの実装

エンコーダーの移動方向#

エンコーダーは、前進または後退のいずれの方向にも移動できます。移動方向を検出するために、Encoder ControlはA信号とB信号の立ち上がりエッジと立ち下がりエッジの順序を読み取ります。

  • 前進方向: A信号はB信号より90°早く立ち上がります。位相の順序は1-2-3-4です。
  • 後退方向: B信号はA信号より早く立ち上がります。位相の順序は4-3-2-1です。

次の画像は、A信号とB信号のデジタル信号レベルに対応する4つの位相を示しています。

A信号とB信号の関係

Position Counter#

Encoder Controlは、A信号とB信号によって駆動されるPosition Counterを使用します。カウンター値は、前進方向で増加し、後退方向で減少します。

Position Counterは連続的に動作します。その値は、最後のリセット以降に受信した入力信号の数を表します。したがって、カウンター値は、前進または後退の移動方向に対するターゲットオブジェクトの現在の位置を常に反映します。

Encoder Mode#

Encoder Modeは、入力されたエンコーダー信号がEncoder Controlによってどのように計算されるかを制御します。

Four Phase Mode#

完全に完了した4つの信号位相によって、1つの直交サイクルが形成されます。完全な直交サイクルごとに、つまりA信号のエッジが立ち上がるときに、直交エンコーダーカウンターが1増加または減少します。

Four Phaseモードは非常に堅牢であり、2つの位相間のわずかな信号ジッターをフィルタリングして除外することができます。

Four Phase Mode

High Resolution Mode#

High Resolutionモードでは、サイクルあたりのカウントが4倍になります。エンコーダーカウンターは、各信号位相で、つまりAおよびB信号のエッジが立ち上がりおよび立ち下がるときに、1増加または減少します。

High Resolution Mode

情報

High Resolutionモードではジッターのフィルタリングはできません。したがって、High Resolutionモードを encoder output mode に設定、 Motion と組み合わせて使用することは推奨されません。2つの位相間のジッターが原因で、連続的な出力トリガーパルスが発生する可能性があるためです。

Encoder Output Mode#

encoder output modeを使用すると、Encoder Controlが有効な出力信号を生成するための条件を設定できます。次のencoder output modeを使用できます:

  • Motion: 移動方向に関係なく、出力トリガー信号が生成されます。
  • DirectionUp: 出力トリガー信号は、次の位置のすべての増分で生成されます: forward 方向。後退方向の動作は無視されます。
  • DirectionDown: 出力トリガー信号は、次の位置のすべての増分で生成されます: 後退 方向。前進方向の動作は無視されます。
  • PositionUp: 出力トリガー信号は、すべての 新規 位置で生成されます( forward 方向)。エンコーダーが逆転した場合、逆転が開始された位置を再び通過するまで、出力トリガー信号は生成されません。
  • PositionDown: 出力トリガー信号は、すべての 新規 位置で生成されます( 後退 方向)。エンコーダーが逆転した場合、逆転が開始された位置を再び通過するまで、出力トリガー信号は生成されません。
  • Off: 出力トリガー信号は生成されません。

追加パラメーター#

  • EncoderDivider: エンコーダー出力トリガー信号を生成するために必要な、エンコーダーからの入力信号の数を指定します。
  • EncoderValue: 位置Counterの現在の値を取得します。このPropertyは読み取り専用です。
  • EncoderReset: 位置Counterの現在のCounter値を0にリセットします。これにより、Encoder Control全体もリセットおよび再起動されます。信号パルスは再起動直後からカウントされます。

Encoder Controlの設定#

Encoder Controlを設定するには:

  1. パラメーターを EncoderSelector パラメータを Encoder1.
  2. パラメーターを EncoderSourceA パラメータを利用可能なソース信号のいずれかに設定します(例: Line2.
  3. パラメーターを EncoderSourceB パラメータを利用可能なソース信号のいずれかに設定します(例: Line3.
  4. パラメーターを EncoderMode パラメーターを次のいずれかの値に設定します。
  5. パラメーターを EncoderDivider Propertyを希望の入力信号数に設定します。
  6. パラメーターを EncoderOutputMode Propertyを、有効にする output mode の種類(例: Motion.

エンコーダー信号によってカメラがトリガーされるように設定するには:

  1. パラメーターを TriggerSelector パラメータを LineStart.
  2. パラメーターを TriggerMode パラメータを On.
  3. パラメーターを 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を使用して、パラメーターを簡単に設定することもできます。