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.
Needed devices, apps:
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
ctrlXCORE ethercat library
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".
Ethercat command for ctrlXDRIVE
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.
Read ethercat parameter ctrlXCORE
Same as the previous function block but in the other direction. This example can be used to write the homing quota value.
Write ethercat parameter ctrlXCORE
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.
Read Codesys string
You can find the example attached. Have Fun 😎
... View more