6.27 NC_COMMAND_COE_SDO_READ signal


This function communicates with the motor driver that supports COE communication through the SDO (Service Data Object) communication mode specified in COE (CANopen over EtherCAT) and reads the specified object data in the object dictionary of the drive.


Signal

Function

plc.ncCommand.flag

Set NC_COMMAND_COE_SDO_READ to start NC COMMAND

plc.ncCommand.attr

Set the axis of the drive for this communication

plc.ncCommand.data.x

Communication status. When the NC returns the finish signal, the communication is successfully written here. 1 is successful and 0 is failed

plc.ncCommand.data.y

Index of the object to read, detailed definition of the object, please refer to the driver's manual

plc.ncCommand.data.z

The SubIndex of the object to be read, the detailed definition of the object, please refer to the driver's manual

plc.ncCommand.data.a

The length of the object read back, in byte

plc.ncCommand.data.b

The content of the object to be written, the type of the content, please refer to the driver's manual

plc.ncCommand.data.c

The content of the object to be written, the type of the content, please refer to the driver's manual


Please note when using this NC NOMMAND:

1. You can only specify one axis at a time, for example:

plc.ncCommand.attr = NC_TASK_OF_X; (Correct usage)

plc.ncCommand.attr = NC_TASK_OF_X | NC_TASK_OF_Y; (Misuse)

2.

data.b and data.c are only the memory used to store the contents of the object. The original data type of data.b and data.c (long) is not necessarily the same as the type of the object. It will be interpreted as an error content, PLC writers must read the data type of the contents of the object from the drive instructions, and then convert the memory of this block into the correct type readout.


Example:

Index 6077h is Torque actual value, and the type is INTEGER16, which is a short short number. Therefore, when reading data.b and data.c, use sTmpData = *(short*)&plc.ncCommand.data.b, meaning: Use a short indicator to extract a short value from the data.b storage location.


PLC program example:

void plcRun(Status &sts, PlcBlock &plc)

{

    …

    if(plc.mCode.flag){

           switch(plc.mCode.data){

           …

           case 154: // M154 -> X drv pos value (RD, idx:0x6064)

           if( plc.ncCommand.flag == NC_COMMAND_COE_SDO_READ && plc.ncCommand.finish ) {

                  SdoOK = plc.ncCommand.data.x;

                  if(SdoOK) XCoe6064 = *(int*)&plc.ncCommand.data.b;

                  plc.ncCommand.flag = 0;

                  plc.mCode.finish = 1;

           }else{

                  plc.ncCommand.attr = NC_TASK_OF_X;

                  plc.ncCommand.data.x = 0;

                  plc.ncCommand.data.y = 0x6064;  // index

                  plc.ncCommand.data.z = 0;       // subindex

                  plc.ncCommand.flag = NC_COMMAND_COE_SDO_READ;

           }

           break;

           …

           }

    }

    …

}