[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.

- 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.

- 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.

- 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.

- 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.

- 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.

衍生類別:
Class Name | Vendor ID | Product Code |
EthercatDevice_QECR11MP3S | 0x00000bc3 | 0x0086d0d6 |
EthercatDevice_QECR00MP3S | 0x00000bc3 | 0x0086d0d9 |
語法
int configEncoderMode(int encoder, uint8_t mode);
參數
[in] int encoder
The specified encoder number:
定義 | 值 | 描述 |
ECAT_ENCODER_1 | 0x01 | Encoder 1 on the EtherCAT slave device. |
ECAT_ENCODER_2 | 0x02 | Encoder 2 on the EtherCAT slave device. |
ECAT_ENCODER_3 | 0x03 | Encoder 3 on the EtherCAT slave device. |
ECAT_ENCODER_X | 0x11 | Encoder X, which mapping is determined by the configMachineAxisMapping() . |
ECAT_ENCODER_Y | 0x12 | Encoder Y, which mapping is determined by the configMachineAxisMapping() . |
ECAT_ENCODER_Z | 0x13 | Encoder 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_DIR | 0 | Please see Pulse/DIR mode. |
ECAT_ENCODER_MODE_CWCCW | 1 | Please see CW/CCW mode. |
ECAT_ENCODER_MODE_AB_PHASE | 2 | Please see Pulse A/B mode. |
ECAT_ENCODER_MODE_STEP_DIR_x2 | 5 | Please see Pulse/DIR x2 mode. |
ECAT_ENCODER_MODE_CWCCW_x2 | 6 | Please see CW/CCW x2 mode. |
ECAT_ENCODER_MODE_AB_PHASE_x2 | 7 | Please 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.