FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We are updating our platform to a new
system.
Read more: Important
information on the platform change.
09-20-2022 05:24 PM - edited 09-20-2022 05:25 PM
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
Solved! Go to Solution.
09-21-2022 01:43 PM
Did you already check this post?
09-21-2022 03:00 PM
Yes, but if I'm not wrong then the solved issue belongs to
READ ListParameter and then Write to S-0-0052 which isn't a list.
I tried with an ARRAY[0..1] OF UINT to Write to P-0-0397
[0] := input of VISU , the value what should be set to P-0-0397 element 0
[1] := 0 , not used
Still timeout error.
09-21-2022 05:31 PM
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
09-22-2022 02:46 PM - edited 09-22-2022 03:00 PM
Thanks a lot @CodeShepherd 👍
I don't know what's different between your writing style like
fbIL_ECATSoeWrite.Execute := bExecute;
fbIL_ECATSoeWrite.MasterName := ADR('ethercatmaster');
fbIL_ECATSoeWrite.SlaveAddress := 1004;
......
and using the function block from libary
fbIL_ECATSoeWrite(
Execute:= TRUE,
MasterName:= ADR('ethercatmaster'),
SlaveAddress:= 1004,
......
but using your style works fine, using function block style don't. Maybe I am doing something wrong but it's strange.
For using with IndraDrive MPB17 it can look like that (writing P-0-0397 filter of signal time constant):
Structure:
TYPE TableStruct :
STRUCT
ActLength : UINT;
MaxLength : UINT;
ArrayOfElements : ARRAY[0..1] OF UDINT;
END_STRUCT
END_TYPE
Declaration:
WriteList : TableStruct := (
ArrayOfElements := [40,30],
ActLength := 4,
MaxLength := 4);
Code: If HMI-input is changed by a user it will trigger writing on P-0-0397 element 0 (time constant for filter 1 / signal 1 (in my case signal 1 is S-0-0084 torque value)):
IF GVL_AXIS.iGlaettung[1] <> iGlaettungOld[1] THEN
WriteList.ArrayOfElements[0] := (GVL_AXIS.iGlaettung[1]*10);
fbIL_ECATSoeWrite.Execute := TRUE;
fbIL_ECATSoeWrite.MasterName := ADR('ethercatmaster');
fbIL_ECATSoeWrite.SlaveAddress := 1004;
fbIL_ECATSoeWrite.Idn := IL_ECATSOEIdnCoding(SOE_P_PARAM,0,397);
fbIL_ECATSoeWrite.ValueAdr := ADR(WriteList);
fbIL_ECATSoeWrite.SizeOfValue := WriteList.ActLength + SIZEOF(WriteList.MaxLength) + SIZEOF(WriteList.ActLength);
fbIL_ECATSoeWrite();
IF fbIL_ECATSoeWrite.Done THEN
bExecute := FALSE;
fbIL_ECATSoeWrite.Execute := FALSE;
fbIL_ECATSoeWrite();
iGlaettungOld[1] := GVL_AXIS.iGlaettung[1];
END_IF
IF TRUE = fbIL_ECATSoeWrite.Error THEN
bExecute := FALSE;
fbIL_ECATSoeWrite.Execute := FALSE;
fbIL_ECATSoeWrite();
iGlaettungOld[1] := GVL_AXIS.iGlaettung[1];
END_IF
END_IF
By the way, is this a special kind of coding?
IF TRUE = fbIL_ECATSoeWrite.Error THEN...
I don't know that style, I use always: IF fbIL_ECATSoeWrite.Error Then... or IF NOT fbIL_ECATSoeWrite.Error Then....
09-23-2022 07:22 AM
There is no functional difference between directly adding variables to the input of the function block in the brackets of the or outside, like in my examples. It simply does the same.
Also the if loop does the same. It just looks different.