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

Writing string into drive parameter

Writing string into drive parameter

alink
New Contributor

Hello,

I'd like to write S-0-0141 'Engine-Type' / 'Name' for a connected drive (IndraDrive MPB20) via EtherCat.

When using  IL_ECATSoeWrite like this:

WriteText:='AKM24D'; //WriteText : STRING;

fbIL_ECATSoeWrite(
Execute:= TRUE,
Done=> ,
Active=> ,
Error=> ,
ErrorID=> ,
ErrorIdent=> ,
ClientId:= ,
MasterName:= ,
AddressType:= ,
SlaveAddress:= 1004,
DriveNo:= ,
Element:= ,
Idn:= IL_ECATSOEIdnCoding(SOE_S_PARAM,0,141),
SizeOfValue:= SIZEOF(WriteText),
ValueAdr:= ADR(WriteText),
Timeout:= , );

This ends up in an 'ACCESS_ERROR'

When using an integer for WriteText (between 0..9) there is no error, but the result, what is written into parameter, is complete wrong (for example it is 4D. Using more than 1 integer charakter ends up with 'ACCESS_ERROR' as well.

Because it works with one charakter, there is no ACCESS - issue! And no issue with the FB.

So what's wrong?

Thanks

 

5 REPLIES 5

J0sh
New Poster

Hello @alink,

please check out the example shown in "IL_ECATSoeRead" and use the data type "IL_ST_SOE_STRING".

Kind regards

CodeShepherd
Community Moderator
Community Moderator

I adapted the "CXA_EtherCatMaster -> AcyclicCommunication -> SoE -> _Examples -> Example_IL_ECATSoeWrite" example to your needs. We will add it to the online and library documentation:

 

PROGRAM Write_StringParameter
VAR
	fbECATSoeWrite : IL_ECATSoeWrite ;
	WriteText: IL_ST_SOE_STRING;
	strText: STRING(255):='AKM24D';	
	MaxLength: UINT := 0;
	ActLength: UINT := 6;
	bExecute: BOOL;
	strMasterName  : STRING := 'ethercatmaster';
END_VAR
WriteText.Text := strText;
WriteText.MaxLength := MaxLength; //not relevant for writing
WriteText.ActLength := LEN(strText); //number of bytes/letters of string

fbECATSoeWrite.Execute      := bExecute;
fbECATSoeWrite.MasterName   := ADR(strMasterName);
fbECATSoeWrite.SlaveAddress := 1001;
fbECATSoeWrite.Idn          := IL_ECATSOEIdnCoding(SOE_S_PARAM,0,141);
fbECATSoeWrite.ValueAdr     := ADR(WriteText);
fbECATSoeWrite.SizeOfValue  := WriteText.ActLength + SIZEOF(WriteText.MaxLength) + SIZEOF(WriteText.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

 

Great, thanks, it's working now.

It's a bit hard to find if it is just to find within "Examples"

write.JPG

CodeShepherd
Community Moderator
Community Moderator

Which version of the library are you using? It is present in 1.12.8.0 that is part of the official long term service version.

The example has to be searched in the library manager directly as it is functional code and not an own function block.

PLC Engineering CXA_EtherCATMaster Example_IL_ECATSoeWritePLC Engineering CXA_EtherCATMaster Example_IL_ECATSoeWrite

Ethercat libary 1.16.

It is available, the issue I had/have is that the function "IL_ST_SOE_STRING" is located inside the "Example" - folder instead directly in SoE or Data Types.

Now, it's just an issue because of the ordering (IMO) but not an working problem anymore, so everything is fine 🙂

ethercat.JPG

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