Dear Community User! We are updating our platform to a new system.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

Writing local output on IndraDrive P-0-0304

Writing local output on IndraDrive P-0-0304

alink
New Contributor

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.

7 REPLIES 7

CodeShepherd
Community Moderator
Community Moderator

In the drive you have to make sure your values do get overwritten by other settings:

ctrlX DRIVE Engineering IndraDrive IO settingsctrlX DRIVE Engineering IndraDrive IO 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:

ctrlX DRIVE Engineering S-0-0144 digital outputctrlX DRIVE Engineering S-0-0144 digital output

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. 

IO_drive.JPG

 Input bits are shown on Visu, output bit should be controlled by Visu input.

Visu.JPG

FB reports:

error.JPG

 

CodeShepherd
Community Moderator
Community Moderator

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.

Oh, sorry, yes it has to be SlaveAdress.

I copied your code and modified it so that it fits, but still Access_Error:

2IO_drive.JPG

Maybe I did something wrong again or there is somewhere else an issue.

The IndrDrive (SlaveAdress := 1004) is in OM

iValueLocOutput : UINT

CodeShepherd
Community Moderator
Community Moderator

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?

alink
New Contributor

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.

CodeShepherd
Community Moderator
Community Moderator

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.

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist