<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
  <POU Name="ModbusMaster" Id="{e576d081-138c-4b4f-ac84-6c40f982c227}" SpecialFunc="None">
    <Declaration><![CDATA[PROGRAM ModbusMaster
VAR
	iSlaveID:USINT:=1;
	bPcCOM:BOOL;

	MB_EL6x22B	:ModbusRtuMaster_KL6x22B;
	MB_PcCOM	:ModbusRtuMaster_PcCOM;

	MBData_Read : ARRAY[0..9] OF WORD;	(* Read from Modbus  Slaves *)
	MBdata_Write : ARRAY[0..9] OF WORD;	(* Write to  Modbus  Slaves *)
	bRead: BOOL;
	bWrite: BOOL;
	iReadMBAddr:WORD:=1;
	iWriteMBAddr:WORD:=1;
	iReadQty:WORD:=1;
	iWriteQty:WORD:=1;

	fbTrigerWrite:R_TRIG;
	nErrID:MODBUS_ERRORS;
END_VAR]]></Declaration>
    <Implementation>
      <ST><![CDATA[MB_EL6x22B.ReadRegs(
	UnitID:=iSlaveID,
	Quantity:=iReadQty ,
	MBAddr:=iReadMBAddr ,
	cbLength:= iReadQty*2,
	pMemoryAddr:= ADR(MBData_Read),
	Execute:=bRead ,
	Timeout:=t#500ms ,
	BUSY=> ,
	Error=> ,
	ErrorId=>nErrID ,
	cbRead=> );


fbTrigerWrite(CLK:=bWrite, Q=> );

MB_EL6x22B.WriteRegs(
	UnitID:= iSlaveID,
	Quantity:=iWriteQty ,
	MBAddr:=iWriteMBAddr ,
	cbLength:= iWriteQty*2,
	pMemoryAddr:= ADR(MBData_Write),
	Execute:=fbTrigerWrite.Q,
	Timeout:=t#500ms ,
	BUSY=> ,
	Error=> ,
	ErrorId=>nErrID ,
	cbRead=> );
]]></ST>
    </Implementation>
    <LineIds Name="ModbusMaster">
      <LineId Id="44" Count="27" />
      <LineId Id="24" Count="0" />
    </LineIds>
  </POU>
</TcPlcObject>