This is a motor control demo program based on IGH EtherCAT Master, demonstrating how to control a servo motor in CSV (Cyclic Synchronous Velocity) mode using EtherCAT communication.
- Ubuntu 20.04/22.04/24.04
- IGH EtherCAT Master (v1.5.3)
- Servo drive supporting CiA402 protocol
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git autoconf libtool pkg-config make build-essential net-tools
git clone https://gitlab.com/etherlab.org/ethercat.git
cd ethercat
git checkout stable-1.5
./bootstrap
./configure --prefix=/usr/local/etherlab --disable-8139too --disable-eoe --enable-generic
make all modules
sudo make modules_install install
sudo depmod
sudo ln -s /usr/local/etherlab/bin/ethercat /usr/bin/
sudo ln -s /usr/local/etherlab/etc/init.d/ethercat /etc/init.d/ethercat
sudo mkdir -p /etc/sysconfig
sudo cp /usr/local/etherlab/etc/sysconfig/ethercat /etc/sysconfig/ethercat
- Create udev rule:
echo 'KERNEL=="EtherCAT[0-9]*", MODE="0666"' | sudo tee /etc/udev/rules.d/99-EtherCAT.rules
- Configure EtherCAT network adapter:
sudo gedit /etc/sysconfig/ethercat
Modify MAC address and driver in the configuration file:
MASTER0_DEVICE="xx:xx:xx:xx:xx:xx" # Replace with your network card's MAC address
DEVICE_MODULES="generic"
sudo /etc/init.d/ethercat start
git clone https://github.com/ZeroErrControl/eRob_IGH_EtherCAT.git
cd eRob_IGH_EtherCAT
mkdir build
cd build
cmake ..
make
./igh_driver
- Automatic state machine transition for slave devices (from INIT to OPERATION ENABLED)
- In OPERATION ENABLED state, the motor will run at target velocity 10000 (units depend on drive configuration)
- Real-time display of actual motor velocity and status information
- Ensure EtherCAT master is properly started before running the program
- Verify network configuration and slave device detection
- Check slave status using:
ethercat slaves
- Ensure the motor is securely mounted before first run
- Start with lower velocity values for testing
- Make sure emergency stop measures are in place
If you encounter issues, check:
- EtherCAT master status
- Network connection
- Slave device status
- Program execution permissions (sudo required)
This project is open source and provided for reference only. Please use with caution. The author is not responsible for any damages or losses.