我想找...

搜尋

分享

目錄

EthercatDevice_DmpStepper.configEncoderMode()

[EthercatDevice_DmpStepper_Generic]

描述

Configure the encoder mode of the specified encoder on the EtherCAT slave device. This parameter is written to the EEPROM of the EtherCAT slave device and loaded during startup, so users do not need to configure this parameter each time before running the program.

This EtherCAT slave device supports a total of six encoder modes, as follows:

  • Pulse/DIR (1-Pulse mode)
    This mode is also known as 1-Pulse mode and has two input pins for accepting signals from the encoder: the Pulse input and the DIR input. The Pulse input is used to count the number of pulses from the encoder, and the DIR input is used to indicate the current counting direction of the encoder counter. In this mode, the counter only counts on the rising edge of the Pulse input.
configEncoderMode-1
  • CW/CCW (2-Pulse mode)
    This mode is also known as 2-Pulse mode. It has two input pins for accepting signals from the encoder: the CW input and the CCW input. The pulses from the CW input represent the number of pulses counted in the forward direction by the encoder counter, while the pulses from the CCW input represent the number of pulses counted in the reverse direction by the encoder counter. In this mode, the counter only counts on the rising edge of the CW 以及 CCW inputs.
configEncoderMode-2
  • Pulse A/B (QEI mode)
    This mode is also known as QEI (Quadrature Encoder Interface) mode. It has two input pins for accepting signals from the encoder: the Pulse A input and the Pulse B input. The Pulse A 以及 Pulse B inputs have a unique relationship. If Pulse A leads Pulse B, the counting direction is deemed forward. If Pulse A lags Pulse B, the counting direction is deemed reverse. In this mode, the counter only counts on the rising and falling edges of the Pulse A input.
configEncoderMode-3
  • Pulse/DIR x2
    This mode is similar to Pulse/DIR mode, with the only difference being that the counter in this mode counts on both the rising and falling edges of the Pulse input.
configEncoderMode-4
  • CW/CCW x2
    This mode is similar to CW/CCW mode, with the only difference being that the counter in this mode counts on both the rising and falling edges of the CW 以及 CCW inputs.
configEncoderMode-5
  • Pulse A/B x2
    This mode is similar to Pulse A/B mode, with the only difference being that the counter in this mode counts on both the rising and falling edges of the Pulse A 以及 Pulse B inputs.
configEncoderMode-6

衍生類別:

Class NameVendor IDProduct Code
EthercatDevice_QECR11MP3S0x00000bc30x0086d0d6
EthercatDevice_QECR00MP3S0x00000bc30x0086d0d9

語法

int configEncoderMode(int encoder, uint8_t mode);

參數

  • [in] int encoder
    The specified encoder number:
定義描述
ECAT_ENCODER_10x01Encoder 1 on the EtherCAT slave device.
ECAT_ENCODER_20x02Encoder 2 on the EtherCAT slave device.
ECAT_ENCODER_30x03Encoder 3 on the EtherCAT slave device.
ECAT_ENCODER_X0x11Encoder X, which mapping is determined by the configMachineAxisMapping().
ECAT_ENCODER_Y0x12Encoder Y, which mapping is determined by the configMachineAxisMapping().
ECAT_ENCODER_Z0x13Encoder Z, which mapping is determined by the configMachineAxisMapping().
  • [in] uint8_t mode
    The encoder mode to be configured. Users can select from six encoder modes, as detailed in the table below. For input values not listed in the table, the default configuration will be ECAT_ENCODER_MODE_AB_PHASE_x2.
定義描述
ECAT_ENCODER_MODE_STEP_DIR0Please see Pulse/DIR mode.
ECAT_ENCODER_MODE_CWCCW1Please see CW/CCW mode.
ECAT_ENCODER_MODE_AB_PHASE2Please see Pulse A/B mode.
ECAT_ENCODER_MODE_STEP_DIR_x25Please see Pulse/DIR x2 mode.
ECAT_ENCODER_MODE_CWCCW_x26Please see CW/CCW x2 mode.
ECAT_ENCODER_MODE_AB_PHASE_x27Please see Pulse A/B x2 mode.

回傳值

Return an error code. If the returned value is zero, it indicates a successful execution of this function.

備註

This function must be called after a successful execution of EthercatMaster::begin(). This function is blocking and cannot be called within the callback functions.

範例

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_QECR11MP3S slave;

void setup() {
  master.begin();
  slave.attach(0, master);

  slave.configEncoderMode(ECAT_ENCODER_1, ECAT_ENCODER_MODE_AB_PHASE_x2);
  slave.configEncoderMode(ECAT_ENCODER_2, ECAT_ENCODER_MODE_AB_PHASE_x2);
  slave.configEncoderMode(ECAT_ENCODER_3, ECAT_ENCODER_MODE_AB_PHASE_x2);
  // ...
}

void loop() {
  // ...
}

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

返回頂端