Reading single bit of a drive parameter

Hello,

I'd like to read out a single bit of a drive parameter.

The parameter is: S-0-0135 and bit 3 is to read out.

For that "IL_ECATSoeRead" is used.

The values don't fit.

The drive has: 0b1100.1000.0000.1000

In PLC it's: 0b0000.0000.0000.1111

or something else...What's wrong with that?

Greetings

ย 

Best reply by CodeShepherd

The S-0-0135 is in standard part of your cyclic communication, so do not need to read it acyclic. See here my examples working for both:

Declaration:

PROGRAM POU
VAR
	fb_IL_ECATSoeRead: IL_ECATSoeRead;
	bExecute: BOOL;
	bDone: BOOL;
	bActive: BOOL;
	bError: BOOL;
	ErrorID: CXA_EthercatMaster.ERROR_CODE;
	ErrorIdent: CXA_EthercatMaster.ERROR_STRUCT;
	strMasterName: STRING := 'ethercatmaster';
	uiSlaveAddress: UINT := 1001;
	wValueRead: WORD;
	cyclicS135: WORD;
	bBitAcyclic: BOOL;
	bBitCyclic1: BOOL;
	bBitCyclic2: BOOL;
END_VAR

Implementation:

bBitCyclic1 := %IX100.3;
cyclicS135 := %IW100;
bBitCyclic2 := cyclicS135.3;

fb_IL_ECATSoeRead(
	Execute:= bExecute, 
	Done=> bDone, 
	Active=> bActive, 
	Error=> bError, 
	ErrorID=> ErrorID, 
	ErrorIdent=> ErrorIdent, 
	ClientId:= , 
	MasterName:= ADR(strMasterName), 
	AddressType:= , 
	SlaveAddress:= uiSlaveAddress, 
	DriveNo:= , 
	Element:= , 
	Idn:= IL_ECATSoeIdnCoding(SOE_S_PARAM,0,135), 
	SizeOfValue:= SIZEOF(wValueRead), 
	ValueAdr:= ADR((wValueRead)), 
	Timeout:= , 
	NoOfRecBytes=> , 
	RecvElement=> );
	
bBitAcyclic := wValueRead.3;

Picture:

Read S-0-0135 cyclic and acyclic

View original
2 replies