IgH EtherCAT master with EasyCAT slave example
Files:
Combine IgH EtherCAT master source code to one file with
Unpack IgH EtherCAT master source code with
Try to use ./configure —disable-8139too instead of ./configure if error occurs, read /ethercat/INSTALL for details,
The IgH EtherCAT master source code has been tested to compile with kernel version 5.4.80-gentoo-x86_64.
After IgH EtherCAT master installed, check ethercat service settings /etc/sysconfig/ethercat,
example
ifconfig
enp3s0u1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.124.186 netmask 255.255.0.0 broadcast 169.254.255.255
ether 70
6b
2d:b4 txqueuelen 1000 (Ethernet)
RX packets 358799 bytes 28470392 (27.1 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 358978 bytes 33531024 (31.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
where the interface name is enp3s0u1, mac is 706b
2d:b4
lsusb # (use lspci -nn in case of lan is on PCI)
Bus 004 Device 002: ID 0bda:8153 Realtek Semiconductor Corp. RTL8153 Gigabit Ethernet Adapter
where LAN with chipset RTL8153 (0bda:8153), the IgH EtherCAT master source code does not include Ethernet driver module specially for RTL8153 (0bda:8153) to use it for EtherCAT operation, ethercat master “generic” lan driver is going to be used.
for this example, in /etc/sysconfig/ethercat file:
MASTER0_DEVICE=”706b
2d:b4”
DEVICE_MODULES=”generic”
LINK_DEVICES=”enp3s0u1”
Start ethercat service with
It might be helpful to check ethercat service messages with
Check connected EasyCAT slave with
Expected output of “./ethercat slave -m0”:
0 0:0 PREOP + Generic 32+32 bytes rev 1
Expected output of “./ethercat pdos -m0”:
SM0: PhysAddr 0x1000, DefaultSize 0, ControlRegister 0x64, Enable 1 RxPDO 0x1600 "Outputs"
PDO entry 0x0005:01, 8 bit, "Byte0"
::::::::::::::::::::::::::::::
PDO entry 0x0005:20, 8 bit, "Byte31"
SM1: PhysAddr 0x1200, DefaultSize 0, ControlRegister 0x20, Enable 1 TxPDO 0x1a00 "Inputs"
PDO entry 0x0006:01, 8 bit, "Byte0"
::::::::::::::::::::::::::::::
PDO entry 0x0006:20, 8 bit, "Byte31"
Copy main.c file to /ethercat/examples/dc_user (/ethercat is IgH EtherCAT master source code)
Go to “/ethercat/examples/dc_user”, compile “main.c” there with “make”, the output file will be “ec_dc_user_example”
Start EasyCAT slave example in “/ethercat/examples/dc_user” with
Example code (main.c) creates files to use bash script or console to send/display received data to/from EasyCAT slave
/run/ethercat/EasyCAT/pdoin0
::::::::::::::::::::::::::::
/run/ethercat/EasyCAT/pdoin31
/run/ethercat/EasyCAT/pdoout0
:::::::::::::::::::::::::::::
/run/ethercat/EasyCAT/pdoout31
Example to display received byte from input 1
Example to send byte 255 to output 10