1 Example project
We have There is no EoE Example available. Take the source from ECS simpleConfig Example .and Socket Interface Example
2 Configuration packet
For EoE it is necessary to change the EtherCAT Set Configuration Packet.
add ECAT_SET_CONFIG_EOE falgflag:
ptConfigReq->tData.tBasicCfg.ulComponentInitialization |= ECAT_SET_CONFIG_DEVICEINFO | ECAT_SET_CONFIG_EOE;
3 ESI
Add in the ESI the EoE following EoE parameters to the ESI, in the Mailbox area:
<Mailbox DataLinkLayer="1">
...
<CoE SdoInfo="1" PdoUpload="1" CompleteAccess="1"/>
</Mailbox>
4 TwinCAT
Installe Install the new ESI in TwinCAT.
Now the EoE can be seen in TwinCAT in the advanced settings.
The MAC and IP settings will be written to the slave as with the following startup parameter.
There is no other way to set the IP to the EtherCAT Slave.
5
...
Application
To use the EoE in the application the socket API is necessary. Go to the Socket Interface Example for more application sourcecode:
netX 90 - Ethernet Interface - Examples
copy the Socket folder to the ECS project
and change the wscript
and activate the ethernet interface channel 1
Bring the ECS Slave to Pre-Operational state. TwinCAT writes EoE startup parameter (MAC and IP) in the statechange form Init to Pre-Operational to the ECS Slave. After that EoE is ready.
The example demonstrates the TCP/UDP server and client ability of the socket interface. For the opposite part, any TCP/UDP server respectively client can be used, for example Socket Test shown below.
https://sourceforge.net/projects/sockettest/
use the same IP like in TwinCAT
The configuration of the socket interface is done by hSockCtrl[] table in AppSockIf_DemoApplicationFunctions.c. Several instances may be created, thus an amount of combination of TCP/UDP servers and clients can be implemented, the limitation of the instances is given by BACKLOG define, the bigger the BACKLOG, the fewer instances are possible.