Prerequisites
- Linux with PREEMPT_RT kernel (recommended) or standard kernel for evaluation — macOS and Windows builds are also available
- A dedicated NIC for EtherCAT (Intel i210/i219 recommended)
- A C toolchain —
gccon Linux and macOS, or an x64 Native Tools Command Prompt for VS 2022+ on Windows - Slaves using the CiA 402 motion profile, and their ESI files
- Sudo access on Unix — the library needs direct access to the Ethernet adapter
1. Download and Extract
Grab the free 2-hour trial archive for your platform from the downloads page and extract it. It ships with the static library libethercat.a, the ethercat.h header, an example main.c, app_config.yml, an ESI/ folder, and the build-and-run helper scripts.
2. Identify Your Network Interface
ifconfig
# Look for your dedicated EtherCAT NIC, e.g. enp86s0 If you are unsure, launch the example anyway — it prints the list of valid interface names it can bind to.
3. Configure the Master
Edit app_config.yml and set your interface and cycle time, then copy your slave ESI files into the ESI/ folder:
ethernet:
interface_name: enp86s0
prioritize_usr_space_eth_drv: true
ethercat:
esi_file_path: ESI/
prioritize_esi_config: true
cycle_time: 4000 # [us], multiples of 250 us only
shift_time: 30 # [% of cycle time]
rx_frame_timeout: 12000 # [us], Unix only 4. Build and Run the Example
On Linux and macOS, rebuild and run in one step:
./rebuild_and_rerun_app.sh To run the already-built binary against a config file:
sudo ./ethercat_master_example app_config.yml On Windows, run rebuild_and_rerun_app.bat from an x64 Native Tools Command Prompt, or ethercat_master_example <path_to_config_file> from a normal command prompt. The config path defaults to app_config.yml.
5. What the Example Does
main.c servos on the first single-axis servo drive slave and moves it at constant speed, and serves as a worked reference for the library API. Slave indexes are slave positions within the network, indexed from zero.
Caution: the example moves a real motor. Make sure the axis is clear before running it.