Welcome to EtherCAT user space application by Veysi ADIN & Chunwoo Kim.This repository contains EtherCAT based control software using CoE and CiA402 standard to control motors and receive sensor data, by wrapping IgH EtherCAT library functions. This implementation can be used with any robotic systems supporting EtherCAT protocol with small modifications. It contains EtherCAT real-time thread with priority of 98. And USB communication with Xbox Controller. You can use different type of user input device as well with small modifications.
Please check prerequisites, guides, links and documentations before installation, or using this control software. To be able to build this control software you will need to install IgH EtherCAT library, and if you need real-time performance you will need to install RT_PREEMPT patch or Xenomai kernel. You can follow links below for the installation of required library and RT_PREEMPT installation.
- IgH EtherCAT Implementation
- RT_PREEMPT Patched Linux
- If you want to use Xenomai-Installation
Once you install the prerequisites you're ready to build the control software.
mkdir project-ws
cd project-ws
git clone https://github.com/veysiadn/ecat_userspace ethercat-control
cd ethercat-control
cmake .
make
If there is no error during the compilation process you are ready to run the executable.
sudo ./ecat_node
If it is running your implementation is succesful, and now you are ready to customize the software based on your application. By default number of connected slaves are defined as one, therefore if you don't have any slave to connect to your Ethernet port software will raise an error about the situation, but don't worry you can customize the software based on your needs.
You should start your customization from ecat_globals.hpp file. In that file you can specify :
- Number of connected slaves and servo drives,
- Control operation mode : Velocity Mode, Position Mode, Torque Mode, Cyclic Synchronous Velocity,Position and Torque modes are supported.
- Control Frequency
- Enable/Disable Distributed Clock
- Motors encoder resolution : note that if you are using different type of motors you might need to create different definitions for each motor.
- Motor Gear Ratio : note that if you are using different type of motors you might need to create different definitions for each motor.
- Custom Slave : If you have different slave than the CiA402 supported servo drive you will need to define custom slave and PDO mapping for that custom slave.
- Keep in mind that this software addresses connected slaves based on physical position with respect to the master. For example the 0th slave will be the first slave that is connected to your Ethernet port.
- If you have a custom slave, it must be in the end of slave chain.
Once you did your initial configuration in the ecat_globals.hpp file. You can modify user input method in main.cpp file.
- Currently this software uses XboxController buttons and joystick data to send control commands to the connected motors, if you want to use different input you can remove Xbox related control parameters and add your own.
- If you want to use Xbox Controller for testing, keep in mind that each axis in the controller generates analog data in the range of -32768 ~ 32768.
- Change configuration parameters for your motor in SetConfigurationParameters() function in ecat_lifecycle.cpp file, based on your operation mode. You can check example page for detailed instructions on custom modifications, in Examples tab.
- Change control parameters based on your selected operation mode in ecat_lifecycle.cpp file in the Update functions. For example if you want to use velocity mode in your control loop, you can change function content of UpdateVelocityModeParameters();
Once you did those changes you will need recompile the software using make and you can test the executable.
- This software heavily tested on Maxon EPOS drivers, therefore if you want to use different servo driver you will need to check PDO mapping of your slave, or you can do custom PDO mapping by using MapCustomPdo function defined in ecat_node.cpp file.