The Object Routing Function (ORF) allows an eDip message to be relayed via the gateway to a specific device. This allows the host PLC to gain access to 'ALL Bus Parameters' of a specific device. Its advisable to set each device on the bus to a fixed node ID to avoid any message errors.
First we need to add the ORF registers in your Modbus Configuration for the Gateway.In this test case I am using an ME63 the ORF registers are different on the ME43
As we have a single connection to the gateway we need to create a message queue for the manager to process. so we can create a request data type then and array in Global memory
TYPE ORF_Request :
STRUCT
Device_Index:WORD;
Device_SubIndex:BYTE;
Device_Node:BYTE;
Raw_Data:ARRAY[0..1] OF WORD;
Write_Length:BYTE;
Enabled:BOOL;
Complete:BOOL;
END_STRUCT
END_TYPE
ORF:ARRAY[0..29] OF ORF_Request;
For a simple read we fill in the Node, Index & Subindex then set the enable True. The manager will continuously scan the array looking for enabled True.
The message is processed and Complete flag set and the True made False.
It's useful to create a Union to parse the 2 Words returned into any other given format.
TYPE Bytes_DWord :
UNION
tByte:ARRAY[0..3] OF BYTE;
tInt:ARRAY[0..1] OF INT;
tWord:ARRAY[0..1] OF WORD;
tReal:REAL;
tDint:DINT;
END_UNION
END_TYPE
An instance of the union can be declared locally. The received word data can then be loaded into tWord[0] & tWord[1]. All entries in a union share the same memory address so if the response is a real then the actual repose will be in tReal. On most occasions the word order is incorrect from the Gateway so
tWord[0]:=Raw_Data[1];
tWord[1]:=Raw_Data[0];
Real_Value:=tReal;
The ORF manager needs to be tasked to run at least twice as fast as the message interval, I find a messaged rate of 100ms for the cyclic read and a task rate of 50ms.