2. EtherCAT Master Setup

Once the ENI file has been created in the previous step, the EtherCAT devices can be connected to the target IPC and supplied with power.

Connect Hardware to IPC

Fig. 11 Connect the EtherCAT Devices to an IPC

2.1. Docker Compose File

The following folder structure is used in this example. The ENI file was stored in the subfolder data. Create a new docker-compose.yml file inside the dio_example directory.

📂dio_example/
  🖹docker-compose.yml
  📂data/
    🖹eni.xml

docker-compose.yml

Two services (containers) are defined in the docker-compose.yml file. The codemeter service is for licensing the software. The ethercat-master service contains the voraus EtherCAT master executable, as the name suggests. This docker container requires four capabilities, the reasons for which are described in the respective comments.

 1services:
 2  ethercat-master:
 3    image: ${IMAGE}
 4    network_mode: host
 5    cap_add:
 6      - CAP_NET_ADMIN # needed for setting the interface into promiscuous mode
 7      - CAP_NET_RAW # needed for raw socket communication
 8      - CAP_IPC_LOCK # needed for memory locking
 9      - CAP_SYS_NICE # needed for using SCHED_FIFO with a priority
10    devices:
11      - /dev/cpu_dma_latency:/dev/cpu_dma_latency # needed for sleep state prevention
12    volumes:
13      - ./data/:/root/data/ # contains eni file and logs
14    environment:
15      - CODEMETER_HOST=codemeter
16      - ECAT_ENI=/root/data/eni.xml
17      - ECAT_CYCLETIME=2000
18      - ECAT_INTERFACE=${INTERFACE}
19      - ECAT_LOG_DIR=/data/log
20      - ECAT_OPCUA_PORT=${OPCUA_PORT}
21 
22  codemeter:
23    hostname: codemeter
24    image: artifactory.vorausrobotik.com/docker/voraus-codemeter:latest
25    environment:
26      LICENSE_SERVER: host.docker.internal
27    extra_hosts:
28      - host.docker.internal:host-gateway

2.2. Executing the Master

The master can be started and stopped with the following commands inside the dio_example folder. Further information on docker compose can be found here.

# Starting the voraus EtherCAT master.
docker compose up -d
# Stopping the voraus EtherCAT master.
docker compose down