Encoder Control#
直交エンコーダーは、インクリメンタルエンコーダー、ロータリーエンコーダー、またはシャフトエンコーダーとも呼ばれます。通常、動きや位置の変化を測定する必要がある自動化アプリケーションで使用されます。
Encoder Control機能は、Basler racer 2カメラでのみ使用できます。
機能を使用する#
仕組み#
Encoder Controlは、ロータリー型またはリニア型の直交エンコーダーに接続されます。直交エンコーダーは、2つの出力信号AおよびBを生成します。これらはフェーズまたはソースAおよびBとも呼ばれます。これら2つの信号には90°の位相差があり、エンコーダーの正方向および逆方向の動きを追跡するために使用されます。フェーズAおよびBは、カメラのEncoder Controlの入力信号です。
次の画像は、Encoder Controlの一般的な実装を示しています。
エンコーダの移動方向#
エンコーダーは、正方向または逆方向に移動できます。動きの方向を検出するために、Encoder ControlはAおよびB信号の立ち上がりエッジと立ち下がりエッジの順序を読み取ります。
- 正方向の動き: A信号がB信号より90°早く立ち上がります。位相の順序は1-2-3-4です。
- 逆方向の動き: B信号がA信号より早く立ち上がります。位相の順序は4-3-2-1です。
次の画像は、AおよびB信号のデジタル信号レベルに対応する4つの位相を示しています。
Position Counter#
Encoder Controlは、AおよびB信号によって駆動されるPosition Counterを使用します。カウンター値は、正方向の動きで増加し、逆方向の動きで減少します。
Position Counterは連続して実行されます。その値は、最後のリセット以降に受信した入力信号の数を表します。したがって、カウンター値は、正方向または逆方向の動きに対するターゲットオブジェクトの現在の位置を常に反映します。
エンコーダモード#
Encoder Modeは、入力されたエンコーダー信号がEncoder Controlによってどのように計算されるかを制御します。
4位相モード#
完全に完了した4つの信号位相が1つの直交サイクルを形成します。完全な直交サイクルごと、つまりA信号のエッジが立ち上がるときに、直交エンコーダーカウンターが1増加または減少します。
Four Phaseモードは非常に堅牢であり、2つの位相間の少量の信号ジッターをフィルタリングして除外することができます。
高解像度モード#
High Resolutionモードでは、サイクルあたりのカウント数が4倍になります。エンコーダーカウンターは、各信号位相で、つまりAおよびB信号のエッジが立ち上がりおよび立ち下がるときに、1増加または減少します。
情報
High Resolutionモードではジッターフィルタリングは実行できません。したがって、High Resolutionモードを encoder output mode に設定されます Motion と組み合わせて使用することは推奨されません。2つの位相間のジッターにより、連続的な出力トリガーパルスが発生する可能性があるためです。
エンコーダ出力モード#
Encoder Output Modeを使用すると、Encoder Controlが有効な出力信号を生成するための条件を設定できます。次のEncoder Output Modeを使用できます。
Motion: 動きの方向に関係なく、出力トリガー信号が生成されます。DirectionUp: すべての位置の増加において、出力トリガー信号が生成されます。 forward direction。逆方向の動きは無視されます。DirectionDown: すべての位置の増加において、出力トリガー信号が生成されます。 backward direction。順方向の動きは無視されます。PositionUp: 出力トリガー信号は、すべての new positions in forward direction。エンコーダーが逆転した場合、逆転が開始された位置を再び通過するまで、出力トリガー信号は生成されません。PositionDown: 出力トリガー信号は、すべての new positions in backward direction。エンコーダーが逆転した場合、逆転が開始された位置を再び通過するまで、出力トリガー信号は生成されません。Off: 出力トリガー信号は生成されません。
追加パラメーター#
EncoderDivider: Encoder Controlの出力トリガー信号を生成するために必要な、エンコーダーからの入力信号の数を決定します。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を使用して、パラメーターを簡単に設定することもできます。