文章
ECX-EC example
refer to EtherCAT MainDevice Application Developers Manual and ECX-EC Hardware Manual
Demo
Demostrate how to create 2 esd EtherCAT Master projects, one is to handle sending a uint8 data from the ECX-EC Pri(EC-A) side to its Sec(EC-B) side, and the other is to handle receiving and processing the uint8 data in Sec(EC-B) side.

Use esd developed UDDC tool to create 2 ESI files
Create 2 variables as shown below, and click "Export Device Descriptions" to create "ESD ECX-EC UDDC Pri.xml" and "ESD ECX-EC UDDC Sec.xml".
Configure ECX-EC by EtherCAT Workbench
First, Configure ECX-EC Pri.(EC-A) side.
- Copy "ESD ECX-EC UDDC Pri.xml" to "C:\Program Files (x86)\esd\EtherCAT\EtherCAT Workbench\SlaveLibrary".
- In "SubDevice 1(ECX-EC Pri) -> SubDevice -> Mailbox -> CoE", create 2 Init Commands "0x2000:01 PS 01" and "0x2000:07 PS 01"
- Modify the Process Data/Image, as shown below.
- Click "Export ENI" to create "ecx-ec-example_pri.xml".
Next, Configure ECX-EC Sec.(EC-B) side.
- Copy "ESD ECX-EC UDDC Sec.xml" to "C:\Program Files (x86)\esd\EtherCAT\EtherCAT Workbench\SlaveLibrary".
- In "SubDevice 1(ECX-EC Sec) -> SubDevice -> Mailbox -> CoE", create an Init Command "0x2000:01 PS 01".
- Modify the Process Data/Image, as shown below.
- Click "Export ENI" to create "ecx-ec-example_sec.xml".

Example code
First, at EtherCAT Master PC (A) side. Build executable file based on the source code, and copy the corresponding ENI to the same folder as the executable file.
result = ecmGetDataReference(hndMaster, ECM_OUTPUT_DATA, 39, 1, (void **)&pucDo);
result = ecmGetDataReference(hndMaster, ECM_OUTPUT_DATA, 40, 1, (void **)&pucToggle);
result = ecmGetDataReference(hndMaster, ECM_INPUT_DATA, 54, 1, (void **)&pucDi);
result = ecmGetDataReference(hndMaster, ECM_INPUT_DATA, 39, 1, (void **)&pucBeToggled);
static int CycleHandler(ECM_HANDLE hnd, int error){
if (*pucBeToggled == 1){
*pucToggle = 0;
}
if (*pucDi != *pucDo){
*pucDo = *pucDi;
*pucToggle = 1;
printf("0x%X \n", *pucDi);
}
return 0;
}
Next, at EtherCAT Master PC (B) side. Build executable file based on the source code, and copy the corresponding ENI to the same folder as the executable file.
result = ecmGetDataReference(hndMaster, ECM_INPUT_DATA, 39, 1, (void **)&pucDi);
result = ecmGetDataReference(hndMaster, ECM_OUTPUT_DATA, 39, 1, (void **)&pucToggle);
result = ecmGetDataReference(hndMaster, ECM_INPUT_DATA, 40, 1, (void **)&pucBeToggled);
static int CycleHandler(ECM_HANDLE hnd, int error){
if (*pucBeToggled == 1){
*pucToggle = 1;
printf("0x%X \n", *pucDi);
} else {
*pucToggle = 0;
}
return 0;
}
Run both executable files, wait for them both get into OP state. In OP mode, use wire to connect some digital input channel of ECX-DIO8, and at EtherCAT Master PC (B) side, there is the value printed indicating which digital input channel is connected.