FUNCTION_BLOCK ADDR_TO_ID
The function block ADDR_TO_ID converts the physical identification of a slot of a PROFIBUS DP-slave or subslot of a PROFINET IO Device to a handle which can be used with the Communication Function Blocks.
Code-Example: get ID with ADDR_TO_ID
PROGRAM PLC_PRG
VAR
ID : DWORD := CommFB.Constants.INVALID_ID;
convertAddr : CommFB.ADDR_TO_ID;
addr : CommFB.ADDR_TYPE;
errorCode : UDINT;
END_VAR
addr.SYSTEM := CommFB.IO_SYSTEM_TYPE.PROFINET_IO;
addr.PN.MASTER := PN_Controller.MasterID;
addr.PN.D.STATIONNAME := 'wago1';
//addr.PN.D.INSTANCE := ?; Instance Nr - not relevant for ADDR_TO_ID()
//addr.PN.D.DEVICE := ?; Device-ID - not relevant for ADDR_TO_ID()
//addr.PN.D.VENDOR := ?; Vendor-ID - not relevant for ADDR_TO_ID()
addr.PN.API := 0;
addr.PN.SLOT := 2;
addr.PN.SUBSLOT := 1;
convertAddr(EN := TRUE, ADDR := addr);
IF(convertAddr.ENO) THEN
ID := convertAddr.ID; // --> use this ID in RDREC, WRREC etc.
ELSE
errorCode := convertAddr.STATUS; //failed !
END_IF
InOut:
Scope |
Name |
Type |
Initial |
Comment |
Input |
EN |
BOOL |
TRUE |
Enable |
Inout |
ADDR |
Data structure to define the address of a slot of a PROFIBUS DP-slave or a subslot of a PROFINET IO Device |
||
Output |
ENO |
BOOL |
Flag |
|
STATUS |
DWORD |
Last detected status |
||
ID |
DWORD |
Handle |