SUBSLOT_ID (FUN) ¶ FUNCTION SUBSLOT_ID : DWORD Returns the ID of a subslot. InOut: Scope Name Type Initial Comment Return SUBSLOT_ID DWORD Input EN BOOL TRUE Optional ID DWORD Handle to a PN-slave or a subslot SLOT UINT Slot number SUBSLOT UINT Subslot number. Use 0 for Profibus DP Output ENO BOOL TRUE: Subslot ID found; FALSE: The requested Subslot could not be found.
CNCT (FB) ¶ FUNCTION_BLOCK CNCT This function block establishes a Profinet DeviceAccess-AR or a Profibus-DPV2 connection. Supervisors need this connections to access a Field Device, e.g. for writing parameters. One instance of a CNCT function block provides one instance of a peer-to-peer connection to a Field Device. Only one connection to the same Field Device can be established. A connection is established when the REQ input is equal to TRUE. The IO Subsystem remains connected as long as the function block is called with REQ = TRUE or an error is indicated. The variable given D_ADDR input shall identify the destination Field Device. The ID output identifies the established connection to this Field Device (used for the functions blocks RDREC and WRREC . If the connection is established successfully, the VALID output indicates that the connection can be used. Note In case of inactivity, which means there are no read-/write-services transfered on the established connection, the connection may be aborted by the IO subsystem (e.g. after 20 sec.) Note The CNCT function block defines a connection to a slot or subslot of a Field Device and returns a handle via the ID output. This connection establishes an Application Relationship (AR) to the Field Device. If another connection and handle is needed to the same Field Device the existing AR may be used. Code-Example: establish a Supervisor connection PROGRAM PLC_PRG VAR cnct : CommFB.CNCT ; startConnect : BOOL ; //establish a Supervisor connection rdrec : CommFB.RDREC ; loadData : BOOL ; buffer : ARRAY [0..255] OF BYTE ; END_VAR cnct.D_ADDR.SYSTEM := CommfB.IO_SYSTEM_TYPE.PROFINET_IO ; cnct.D_ADDR.PN.D.STATIONNAME := 'pnDevice' ; cnct.D_ADDR.PN.D.VENDOR := 16#011D ; //get this data from GSDML or DCP_Identify / Scan cnct.D_ADDR.PN.D.DEVICE := 16#02EE ; cnct.D_ADDR.PN.D.INSTANCE := 0 ; cnct.D_ADDR.PN.SLOT := 0 ; cnct.D_ADDR.PN.SUBSLOT := 1 ; cnct.REQ := startConnect ; cnct (); IF ( cnct.VALID ) THEN loadData := TRUE ; ELSIF ( cnct.ERROR ) THEN //re-connect, if connection timed out startConnect := ( cnct.STATUS = CommFB.ErrorCode.TIMEOUT ); END_IF // Read Diagnosis-Data rdrec.REQ := loadData ; rdrec.ID := cnct.ID ; rdrec.INDEX := TO_INT ( ProfinetCommon.DiagnosisRecordIndex.Device ); rdrec.MLEN := TO_INT ( SIZEOF ( buffer )); rdrec.RECORD := ADR ( buffer ); rdrec (); IF ( rdrec.REQ ) THEN IF ( rdrec.VALID ) THEN loadData := FALSE ; startConnect := FALSE ; //Release connection END_IF END_IF rdrec.REQ := rdrec.BUSY ; InOut: Scope Name Type Initial Comment Input REQ BOOL Start Request D_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 VALID BOOL Connection is valid ERROR BOOL Error detected BUSY BOOL FB is busy STATUS DWORD Last detected status ID DWORD Constants.INVALID_ID Identifier of a PROFIBUS DP-slave or a subslot of a PROFINET IO Device. Use for RDREC or WRREC (Class 2 / Supervisor Access)
Constants (GVL) ¶ Attributes: qualified_only InOut: Scope Name Type Initial Constant INVALID_ID UDINT 16#FFFFFFFF MAX_PN_ALARM_DATA UDINT 198
DP Address ¶ ADDR (Function) ID (Function) SLOT_ID (Function)
ADDR (FUN) ¶ FUNCTION ADDR : DWORD This function converts a handle which addresses a slot or a DP-slave into its physical address. InOut: Scope Name Type Initial Comment Return ADDR DWORD Input EN BOOL TRUE ID DWORD Slot or device handle Output ENO BOOL
ID (FUN) ¶ FUNCTION ID : DWORD This function converts the physical identification of a slot or a DP-slave to a handle which can be used with Communication Function Blocks. InOut: Scope Name Type Initial Comment Return ID DWORD Input EN BOOL TRUE MASTER BYTE ID of the DP system SEGMENT BYTE Number of the DP segment STATION BYTE Number of the DP-slave(station address) SLOT BYTE Slot number
SLOT_ID (FUN) ¶ FUNCTION SLOT_ID : DWORD Provides the ID of a Profibus slot to a given Profibus DP-slave handle InOut: Scope Name Type Initial Comment Return SLOT_ID DWORD Input EN BOOL TRUE ID DWORD Handle to a DP-slave or a slot SLOT BYTE Slot number Output ENO BOOL
DP_AINFO (STRUCT) ¶ TYPE DP_AINFO : STRUCT Alarm information of a profibus device (see: RALARM ). (see IEC 61158-6) InOut: Name Type Comment D_LEN BYTE Length of the alarm information: 4 .. 63 bytes ATYPE BYTE Alarm Type SLOT BYTE Slot number ASPEC BYTE Alarm Specifier Bit 0 to 1: 0: no further differentiation 1: Alarm appears and the related module is disturbed 2: Alarm disappears and the related module has no further errors 3: Alarm disappears and the related module is still disturbed Bit 2: Additional acknowledge Bit 3 to 7: Sequence number of alarm ADD_INFO ARRAY [0..58] OF BYTE Additional alarm information
DP_DIAG (STRUCT) ¶ TYPE DP_DIAG : STRUCT Data structure containing DP Slave diagnosis data (see: RDIAG ). (see IEC 61158-6) InOut: Name Type Comment status1 IIoDrvProfibus.DP_StationStatus1 DP station status 1 status2 IIoDrvProfibus.DP_StationStatus2 DP station status 2 status3 IIoDrvProfibus.DP_StationStatus3 DP station status 3 Diag_Master_Add USINT address of the DP-master (Class 1) which has parameterised this DP-slave (255 means invalid or no parameterisation). Ident_Number UINT Ident Number of DP slave ExtDiag ARRAY [0..235] OF BYTE Extended Diagnosis Data
ErrorCode (ENUM) ¶ TYPE ErrorCode : The STATUS output has the data type DWORD which is interpreted as a packed array of four bytes. Byte 0: Function_Num Byte 1: Error_Decode Byte 2: Error_Code_1 Byte 3: Error_Code_2 The Elements are used as specified in IEC 61158-6 (Profibus DP, Profinet IO) Exception: If Function_Num has a value of 16#40, no protocol element is used. This is the case for example if the validation of one input parameter failed. In this case Error_Decode value of 16#82..16#8F reports an error at parameter number 2 - 15. Other fixed error codes are defined in this enum. Attributes: qualified_only InOut: Name Initial Comment NONE 0 No error INVALID_ID 16#40820000 Invalid ID UNKNOWN 16#40000100 Unknown error NOT_IMPLEMENTED 16#40000101 Function not implemented RDIAG_PROFINET 16#40000102 tried to use RDIAG on Profinet device STACK_NOT_RUNNING 16#40000103 Stack not running. NO_RESSOURCE 16#40000104 Out of ressources or ressource busy. BUFFER_SIZE 16#40000105 specified local data-buffer size too small INVALID_STATE 16#40000110 requested operation not possible in this state ADDRESS_NOT_UNIQUE 16#40000111 target-address is not unique ADDRESS_INVALID 16#40000112 address is invalid or unreachable (e.g. different IP subnet) DEVICE_NOT_FOUND 16#40000113 unable to detect/address target-device DEVICETYPE_MISMATCH 16#40000114 target device has wrong type for requested operation TIMEOUT 16#40000115 Operation timed out