Writing value in element 0 of P-0-0397

Hello,

I'd like to write a value into the parameter P-0-0397. This parameter contains of 2 elements. How to write on element '0' with FB IL_CATSoeWrite? Currently, the result is a timeout error....

To write this parameter of an IndraDrive

 

Best reply by CodeShepherd

See my example for the ctrlX DRIVE. Beware that the values in my case is 4 Byte and the digits after decimal point are 3. In IndraDrive it is 2 Byte and 1 digit. I created an own structure corresponding to the drive parameter that then is written via IL_ECATSoeWrite:

Struct:

TYPE MyTableStruct :
STRUCT
	ActLength : UINT;
	MaxLength : UINT;
	ArrayOfElements : ARRAY[0..3] OF UDINT;
END_STRUCT
END_TYPE

Declaration:

PROGRAM Read_Write_StringParameter
VAR
	fbECATSoeWrite: IL_ECATSoeWrite;
	WriteList: MyTableStruct := (
                ActLength:= 16(*number of bytes*), 
                MaxLength := 16(*number of bytes*), 
                ArrayOfElements := [1000,2000,3000,4000](*number multiplied with digits after decimal point*));
	bExecute: BOOL;
	strMasterName: STRING := 'ethercatmaster';
	fbECATSoeRead2: IL_ECATSoeRead;
	bExecuteRead: BOOL;
	rDiagnosis: IL_ST_SOE_STRING;
END_VAR

Implementation:

fbECATSoeWrite.Execute      := bExecute;
fbECATSoeWrite.MasterName   := ADR(strMasterName);
fbECATSoeWrite.SlaveAddress := 1001;
fbECATSoeWrite.Idn          := IL_ECATSOEIdnCoding(SOE_P_PARAM,0,397);
fbECATSoeWrite.ValueAdr     := ADR(WriteList);
fbECATSoeWrite.SizeOfValue  := WriteList.ActLength(*number of bytes that should be written*) + SIZEOF(WriteList.MaxLength) + SIZEOF(WriteList.ActLength);
fbECATSoeWrite();
IF TRUE = fbECATSoeWrite.Done THEN
  ; // FB finished .
END_IF
IF TRUE = fbECATSoeWrite.Error THEN
	fbECATSoeWrite.ErrorID;
	fbECATSoeWrite.ErrorIdent.Table;
	fbECATSoeWrite.ErrorIdent.Additional1;
	fbECATSoeWrite.ErrorIdent.Additional2;
  ; // Error handling
END_IF

 

View original
5 replies