CREATE_ID (FB)

 

FUNCTION_BLOCK CREATE_ID

This function block creates a temporary ID from the physical identifica­tion of a slot of a PROFIBUS DP-slave or subslot of a PROFINET IO Device which can be used with the Communication Function Blocks.

In contrast to the other address conversion functions, it does not retrieve the ID from the projected devices of the application, but creates a tempo­rary assignment of ID and the given address.

Use case is for example a Profinet implicit read-service. (RDREC without established connection CNCT)

Note

Implementations may choose to only support a single or a limitted number of these temporary IDs and the underlying services.

Code-Example: Profinet implicit read

PROGRAM READ_Implicit
VAR
   addr : CommFB.ADDR_TYPE;
   createID : CommFB.CREATE_ID;

   execRead : BOOL;
   rdrec : CommFB.RDREC;
   buffer : ARRAY[0..63] OF BYTE;
END_VAR

// init address:
// (this data might be retrieved by a bus-scan)
addr.SYSTEM := CommFB.IO_SYSTEM_TYPE.PROFINET_IO;
addr.PN.D.STATIONNAME := 'pnDevice';      // 'pnDevice' is some online device
addr.PN.D.INSTANCE := 1;                  // typically 0 or 1

createID(ADDR := addr);
IF(createID.ENO AND execRead) THEN
   // Read data from profinet device
    rdrec.ID := createID.ID;            // ENO = TRUE, so the ID is valid and can be used for RDREC
   rdrec.INDEX := TO_INT(16#AFF0);     // I&M1-Data
   rdrec.MLEN := TO_INT(SIZEOF(buffer));
   rdrec.RECORD := ADR(buffer);
   rdrec(REQ := execRead);

   IF(rdrec.VALID OR rdrec.ERROR) THEN
       //execution done
       execRead := FALSE;
       rdrec(REQ := execRead);
   END_IF
END_IF

InOut:

Scope

Name

Type

Initial

Comment

Input

EN

BOOL

TRUE

Enable

Inout

ADDR

ADDR_TYPE

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

Provided ID is valid.

STATUS

DWORD

Last detected status, see enum ErrorCode

ID

DWORD

Handle