beckhoff ModbusRTU程序记录 EL6021

FUNCTION_BLOCK FB_MeteorologyIn
VAR_IN_OUT CONSTANT
	DAct : ST_TurbineActual;
	IIn : ST_MeteorologyInput;
END_VAR

VAR_IN_OUT
	DIn : ST_MeteorologyInbox;
	DOut : ST_MeteorologyOutbox;	
END_VAR

VAR
	nSta : BYTE := 0;
	nStaLast : BYTE := 0;
	tonTmOu : TON;	
	arrDat : ARRAY[0..31] OF BYTE;
	nDev : BYTE := 2;
	j : BYTE;	
	bRcvFsh : BOOL;
	tonRcvFsh : TON;
	fbModbusMetTid: ModbusRtuMaster_KL6x22B;
	iStep: INT:=0;
	iCount: INT;
	arrMetTidMb:ARRAY[0..7] OF INT;
	arrMetTidMb2X:ARRAY[0..7] OF INT;
	iCount1: INT;
	iCount2: INT;
	fMetTidTmp: LREAL;
	fMetTidSpdInst: LREAL;	
	fMetTidTmp2: LREAL;
	fMetTidSpdInst2: LREAL;	
	
END_VAR

程序具体

DIn.bVld := TRUE;


CASE iStep OF
	0:
	fbModbusMetTid.ReadRegs(Execute:=FALSE );
	iStep:=10;
	10:
	fbModbusMetTid.ReadRegs(
	UnitID:=1 , 
	Quantity:=8 , 
	MBAddr:=10 , 
	cbLength:=SIZEOF(arrMetTidMb) , 
	pMemoryAddr:=ADR(arrMetTidMb) , 
	Execute:=TRUE , 
	Timeout:=T#

你可能感兴趣的:(TwinCAT图解教程,TwinCAT,自动化,ADS,modbusRTU)