6.28 NC_COMMAND_COE_SDO_WRITE signal


This function communicates with the motor driver supporting COE communication through the SDO (Service Data Object) communication mode specified in COE (CANopen over EtherCAT), and writes the data to the specified object in the object dictionary of the driver.


Signal

Function

plc.ncCommand.flag

Set NC_COMMAND_COE_SDO_WRITE 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

For the definition of the object to be written, please refer to the driver's manual for a detailed definition of the object

plc.ncCommand.data.z

SubIndex of the object to be written, detailed definition of the object please refer to the driver manual

plc.ncCommand.data.a

The length of the object to be written, the unit is byte, the detailed definition of the object please refer to the driver manual, or you can first SDO_READ once the object to get the length

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 used to store the contents of the object. data.b and data.c are not necessarily the same as the type of the object. If used directly, the data type may be written. Into the error content, PLC writers must read the data type of the object content from the driver's manual, and then write the correct type of the block memory at the beginning.


Example:

Index 6060h is a Modes of operation, type INTEGER8. It represents an integer char of number characters. Therefore, when writing data.b and data.c, use *(char*)&plc.ncCommand.data.b = cTmpData. Writes a char value to the storage address of data.b as a char pointer.


PLC program example:

void plcRun(Status &sts, PlcBlock &plc)

{

    …

    if(plc.mCode.flag){

           switch(plc.mCode.data){

           …

           case 153: // M153 -> X drv homing method (WR, idx:0x6098, data: 35)

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

                  SdoOK = plc.ncCommand.data.x;

                  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 = 0x6098;      // index

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

                  plc.ncCommand.data.a = 1;           // parSize

                  *(char*)&plc.ncCommand.data.b = 35;  // parData

                  plc.ncCommand.flag = NC_COMMAND_COE_SDO_WRITE;

           }

           break;

           …

           }

    }

    …

}