FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
09-15-2022 08:54 AM
Hello,
I'd like to write the local output of an IndraDrive. Reading local input P-0-0302 works fine, but when wirting output P-0-0304 there's always an ACCESS_ERROR.
---
VAR
fbAIL_ECATSoeWrite: IL_ECATSoeWrite;
iValueLocOutput: UDINT;
bLocBit7: BOOL;
END_VAR
Code:
IF NOT fbAIL_ECATSoeWrite.Done AND NOT fbAIL_ECATSoeWrite.Error THEN
fbAIL_ECATSoeWrite(Execute:= TRUE,MasterName:= ADR('ethercatmaster'),AddressType:= 1004,Idn:=IL_ECATSOEIdnCoding(SOE_P_PARAM,0,304),Element:= SOE_ELEMENT_OPDATA,SizeOfValue:= SIZEOF(iValueLocOutput),ValueAdr:=ADR(iValueLocOutput) ,);
ELSIF fbAIL_ECATSoeWrite.Done OR fbAIL_ECATSoeWrite.Error THEN
fbAIL_ECATSoeWrite(Execute:= FALSE,MasterName:= ADR('ethercatmaster'),AddressType:= 1004,Idn:=IL_ECATSOEIdnCoding(SOE_P_PARAM,0,304),SizeOfValue:= SIZEOF(iValueLocOutput),ValueAdr:= ADR(iValueLocOutput) ,);
END_IF
iValueLocOutput.0 := bLocBit7;
---
bLocBit7 is a BOOL which can be set with visu
Local output is bit 0 of P-0-0304. Writing this with ctrlX-Drive is working directly is working. So the issue is with Ethercat, I think.
Solved! Go to Solution.
09-15-2022 11:00 AM - edited 09-15-2022 02:22 PM
In the drive you have to make sure your values do get overwritten by other settings:
Your PLC example looks a little strange to me. Some inputs needs to be different and you should not call the function block inside of the IF function. See here an adaption of example that also is part of the library:
Declaration:
PROGRAM Write_param
VAR
fbECATSoeWrite: IL_ECATSoeWrite;
strMasterName: STRING := 'ethercatmaster';
uiWriteValue: UINT := 16#0001;
bExecute := BOOL;
END_VAR
Implementation:
fbECATSoeWrite.Execute := bExecute;
fbECATSoeWrite.MasterName := ADR(strMasterName);
fbECATSoeWrite.SlaveAddress := 1001;
fbECATSoeWrite.Idn := IL_ECATSoeIdnCoding(SOE_P_PARAM,0,304);
fbECATSoeWrite.ValueAdr := ADR(uiWriteValue);
fbECATSoeWrite.SizeOfValue := SIZEOF(uiWriteValue);
fbECATSoeWrite();
IF TRUE = fbECATSoeWrite.Done THEN
; // FB finished .
END_IF
IF TRUE = fbECATSoeWrite.Error THEN
; // Error handling
END_IF
Another way of setting the output would be using a bit of S-0-0144 the "Signal status word" via the cyclic communication:
09-16-2022 02:49 PM
Thanks for feedback.
It is just a pre-testing program to learn how to use ctrlX, EtherCat and so on....
Following the red lines, these are for writing on the local output X31:8 of the IndraDriveCS. With ECATSoeWrite there is always an Access_Error when wirting P-0-0304.
Reading inputs (blue line) of P-0-0303 is working well.
Input bits are shown on Visu, output bit should be controlled by Visu input.
FB reports:
09-16-2022 02:57 PM - edited 09-16-2022 02:59 PM
The error code tells us following as you can see in the online documentation.
"0C880007
Ecat: Invalid argument
Cause/Remedy 1: Cause: A function with one or multiple invalid argument(s) was called. Remedy: Check the arguments/parameters used and compare them to the documentation of the interface."
So did you try to implement the improvements I wrote my post before? At least the AddressType you give to the function block does not fit (and is not needed) but the SlaveAdress input missing.
09-16-2022 04:33 PM - edited 09-16-2022 04:34 PM
Oh, sorry, yes it has to be SlaveAdress.
I copied your code and modified it so that it fits, but still Access_Error:
Maybe I did something wrong again or there is somewhere else an issue.
The IndrDrive (SlaveAdress := 1004) is in OM
iValueLocOutput : UINT
09-19-2022 09:29 AM
Quite strange. I cannot reproduce this behaviour. Could you check if in your code there are other calls of the same function block where invalid input parameters are used?
09-19-2022 09:34 AM
Don't know why and what happened, but without any change, it is working today.
The only thing what was done, PLC was shut down for weekend....Hopefully this is not the reason, otherwise it will be annoying if restarting the PLC is necessary when changing something at the code.
09-19-2022 09:43 AM
I did not hear of any case where this had to be done.
Sometimes especially when using pointers it can be necessary to do a full download (not only online login) or even to clear compiling data (clear all) in the ctrlX PLC Engineering so that they are correctly created and initialized.