サイト内検索

検索

Shares

Table of Content

EthercatDevice_DmpStepper.encoderDirectionRead()

[EthercatDevice_DmpStepper_Generic]

説明

EtherCATスレーブデバイス上の指定されたエンコーダの現在の方向を取得します。

派生クラス:

クラス名製造者ID製品コード
EthercatDevice_QECR11MP3S0x00000bc30x0086d0d6
EthercatDevice_QECR00MP3S0x00000bc30x0086d0d9

構文

int encoderDirectionRead(int encoder);

媒介変数

  • [in] int encoder
    指定されたエンコーダ番号:
定義Value説明
ECAT_ENCODER_10x01EtherCATスレーブデバイス上のエンコーダ1
ECAT_ENCODER_20x02EtherCATスレーブデバイス上のエンコーダ2
ECAT_ENCODER_30x03EtherCATスレーブデバイス上のエンコーダ3
ECAT_ENCODER_X0x11エンコーダXで、マッピングは configMachineAxisMapping()によって決定されます。
ECAT_ENCODER_Y0x12エンコーダYで、マッピングはconfigMachineAxisMapping()によって決定されます。
ECAT_ENCODER_Z0x13エンコーダZで、マッピングはconfigMachineAxisMapping()によって決定されます。

戻り値

Return the current direction of the specified encoder. A return value of 0 indicates forward rotation, while a return value of 1 indicates reverse rotation. If the returned value is less than zero, it indicates an error codeを示します。.

備考

この関数は、 EthercatMaster::start() が正常に実行された後で、 EthercatMaster::stop()が正常に実行された後に呼び出す必要があります。 この関数はブロッキングされており、コールバック関数内で呼び出すことはできません。

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_QECR11MP3S slave;

void setup() {
  Serial.begin(115200);
  master.begin();
  slave.attach(0, master);
  master.start();
}

void loop() {
  Serial.print("Encoder 1 Direction: ");
  Serial.println(slave.encoderDirectionRead(ECAT_ENCODER_1));
  Serial.print("Encoder 2 Direction: ");
  Serial.println(slave.encoderDirectionRead(ECAT_ENCODER_2));
  Serial.print("Encoder 3 Direction: ");
  Serial.println(slave.encoderDirectionRead(ECAT_ENCODER_3));
  Serial.print("Encoder X Direction: ");
  Serial.println(slave.encoderDirectionRead(ECAT_ENCODER_X));
  Serial.print("Encoder Y Direction: ");
  Serial.println(slave.encoderDirectionRead(ECAT_ENCODER_Y));
  Serial.print("Encoder Z Direction: ");
  Serial.println(slave.encoderDirectionRead(ECAT_ENCODER_Z));
  delay(1000);
  // ...
}

Please see EthercatDevice_DmpStepper_Generic Class for more QEC Stepper Drivers instructions and API usage.

上部へスクロール