Disclaimer
The goal is to read/write SoE parameters using standard PLC Function Blocks. All the examples in the following are suited for single axis drives, for double axis drives some slight modifications should be done. In using EtherCAT all REAL parameters are managed as scaled DINT parameters. These function blocks are working also with list parameters.
Requirements
Needed devices, apps:
- ctrlX CORE
- Indradrive or ctrlX DRIVE correctly connected
- PLC and EtherCAT apps.
If you don't know how to setup the EtherCAT bus just follow SoE drive setup
STEP1: PLC Engineering software
The first operation you need to do is to import the right library: the CXA_ETHERCATMASTER. Inside there are the SoE function blocks together with the examples, this guide is based on the use of them. Every of the following function blocks needs:
- The address to a string variable containing the EtherCATmaster master name, usually "ethercatmaster"
- The drive EtherCAT address: usually 1001,1002,...
- The DriveNo: drive number if the drive is multi axis (0,1..)
- The Parameter Idn obtained using IL_ECATSoeIdnCoding Function
IL_ECATSoeCommand
Here an example of how you can use the IL_ECATSoeCommand FB to clear and set the encoder absolute position is shown. The two parameters are both S parameters then the function IL_ECATSoeCommand takes SOE_S_PARAM as first entry. One executed the function remains active until it goes to "Command Executed" or "Error".
IL_ECATSoeRead
Here an example of how you can use the IL_ECATSoeRed FB to read a P parameter is shown. Differently from the previous FB this needs as input also the address and the size of the destination variable.
IL_ECATSoeWrite
Same as the previous function block but in the other direction. This example can be used to write the homing quota value.
Read Strings
Codesys uses null-terminated strings, the string will then miss the null at the end. It is possible to use the IL_BufferToString function to get a properly terminated string.
You can find the example attached. Have Fun 😎
Notes
The EtherCat SoE specification is based on the SERCOS II. The structured parameter including the indexes (instance.element e.g. S-0-602.1.1) were first introduced in SERCOS III. Even IDN size changed from 2 Byte to 4 Byte and so access to this parameter is not possible via SoE.