ErrorCode1_RW (ENUM) ¶ TYPE ErrorCode1_RW : Some encodings of ErrorCode1 of STATUS (byte 3) that are use for acyclic read-/write services. Could be used for access errors in RCVREC or PRVREC function blocks, for example. Attributes: qualified_only InOut: Name Initial Invalid_index 16#B0 Write_length_error 16#B1 Invalid_slot_or_subslot 16#B2 Type_conflict 16#B3 Invalid_area_or_API 16#B4 State_conflict 16#B5 Access_denied 16#B6 Invalid_range 16#B7 Invalid_parameter 16#B8 Invalid_type 16#B9 Backup 16#BA
FieldDevice ¶ PRVREC (FunctionBlock) PRVREC_MODE (Enum) RCVREC (FunctionBlock) RCVREC_MODE (Enum) SALARM (FunctionBlock)
PRVREC (FB) ¶ FUNCTION_BLOCK PRVREC A Field Device can receive a request to provide a process data record to a Host Controller or Supervisor. The host may use the RDREC function block. The application program is informed about this request and can provide the requested process data record using the PRVREC function block. This function blocks contains the methods to check, receive and respond a request for a process data record. All aspects of providing a process data record may use one function block instance, the different methods are distinguished using the MODE input. If a data record is received (with MODE=1 or MODE=2), the NEW output indicates that the data record is stored in the variable given at the RECORD parameter. If the function block refuses to accept the data record, the CODE1 input sets the Error Code1, and the CODE2 input sets the Error Code 2 of the negative response. If an error occurred, the ENO=0 indicates an error and the STATUS output contains the error code.// | If an error occurred, the ENO=0 indicates an error and the STATUS output contains the error code. Note The application program of the Field Device shall acknowledge the received request, otherwise the Host Controller will get a timeout error or the device stack will send a negative response. Code-Example PROGRAM ProvideData VAR prvData : CommFB.PRVREC ; data : ARRAY [0..3] OF BYTE := [0,1,2,3] ; // some dummy data END_VAR // Variant 1: receive data for a specific slot: prvData.EN := 1 ; prvData.F_ID := CommFB.SUBSLOT_ID ( EN := TRUE , PN_Device.DeviceID , 2 , 1 ); // get ID of Slot 2 of the specified device prvData ( MODE := CommFB.PRVREC_MODE.RECEIVE_BY_SLOT ); // get request IF prvData.NEW THEN // process record IF ( prvData.SLOT = 1 AND prvData.INDEX = 2 ) THEN prvData ( MODE := 3 , LEN := 4 , RECORD := ADR ( data )); // pos. response with data END_IF END_IF // Variant 2: check for request, then decide to process it (receive + pos./neg. response) prvData ( MODE := CommFB.PRVREC_MODE.CHECK , F_ID := PN_Device.DeviceID ); // get request IF ( prvData.NEW ) THEN // Reject everything else. // If a request from the host is not confimed by the aplication, the stack may send a neg. response after a timeout. prvData ( MODE := 4 , CODE1 := 16#B2 ); END_IF InOut: Scope Name Type Comment Input EN BOOL Enable MODE UINT Function specifier, see PRVREC_MODE F_ID DWORD Slot / subslot to filter the data records to receive CODE1 BYTE Reason for negative response. (see ErrorCode1_RW ) CODE2 BYTE Reason for negative response. (0 or user specific) LEN UINT Length of a data record to provide RECORD POINTER TO BYTE Provided data record Output ENO BOOL Function enabled NEW BOOL New data record requested STATUS DWORD Field Device interface status SLOT UINT Slot the record is requested for SUBSLOT UINT Subslot the record is requested for INDEX UINT Index of the requested data record RLEN UINT Length of the requested data record
PRVREC_MODE (ENUM) ¶ TYPE PRVREC_MODE : Attributes: qualified_only InOut: Name Initial Comment CHECK 0 If the Field Device interface has received a request to provide a process data record, only the outputs NEW, SLOT, INDEX and RLEN are set. Multiple calls of this function block with MODE=0 returns the outputs for the same request. RECEIVE 1 If the Field Device interface has received a request, the function block outputs are updated. RECEIVE_BY_SLOT 2 If the Field Device interface has received a request for the slot and subslot the numbers of which are given in F_ID input, the function block outputs are updated. POS_RESPONSE 3 After checking or receiving the request to provide a process data record, this function block provides the requested process data record with its RECORD parameter and sends a positive response to the Host Controller. NEG_RESPONSE 4 After checking or receiving the request to provide a process data record, this function block refuses to provide this record and sends a negative response to the Host Controller. The error reason is given with the inputs CODE1 and CODE2.
CommFB Library Documentation ¶ Company : 3S - Smart Software Solutions GmbH Title : CommFB Version : 3.5.18.0 Categories : Application|Fieldbus Namespace : CommFB Author : 3S - Smart Software Solutions GmbH Placeholder : CommFB Description [ 1 ] ¶ Contents: ¶ CommFB AINFO_TYPE (Union) AddressConcept (GVL) Addresses CNCT (FunctionBlock) Constants (GVL) DP Address DP_AINFO (Struct) DP_DIAG (Struct) ErrorCode (Enum) ErrorCode1_RW (Enum) FieldDevice GETIO_PART (FunctionBlock) PN_AINFO (Struct) RALARM (FunctionBlock) RALARM_MODE (Enum) RDIAG (FunctionBlock) RDREC (FunctionBlock) SETIO_PART (FunctionBlock) WRREC (FunctionBlock) Images Indices and tables ¶ [ 1 ] Based on CommFB.library, last modified 29.03.2022, 09:31:49. LibDoc 4.4.0.0-b.37 The content file CommFB.clean.json was generated with CODESYS V3.5 SP16 Patch 3 on 29.03.2022, 09:31:49.
CommFB ¶ AINFO_TYPE (Union) AddressConcept (GVL) Address Concept Generating a CommFB-ID Profibus DP Profinet IO Device Diagnosis Address Conversion Addresses ADDR_TO_ID (FunctionBlock) ADDR_TYPE (Union) CREATE_ID (FunctionBlock) DP_ADDR (Struct) DP_DEVICE_ID (Struct) ID_TO_ADDR (FunctionBlock) IO_SYSTEM_TYPE (Enum) PN_ADDR (Struct) PN_DEVICE_ID (Struct) SUBSLOT_ID (Function) CNCT (FunctionBlock) Constants (GVL) DP Address ADDR (Function) ID (Function) SLOT_ID (Function) DP_AINFO (Struct) DP_DIAG (Struct) ErrorCode (Enum) ErrorCode1_RW (Enum) FieldDevice PRVREC (FunctionBlock) PRVREC_MODE (Enum) RCVREC (FunctionBlock) RCVREC_MODE (Enum) SALARM (FunctionBlock) GETIO_PART (FunctionBlock) PN_AINFO (Struct) RALARM (FunctionBlock) RALARM_MODE (Enum) RDIAG (FunctionBlock) RDREC (FunctionBlock) SETIO_PART (FunctionBlock) WRREC (FunctionBlock)
AINFO_TYPE (UNION) ¶ TYPE AINFO_TYPE : UNION This union either contain Profibus or Profinet alarm information, depending on the used IO subsytem type (see: RALARM ). InOut: Name Type Comment DP DP_AINFO Profibus alarm information PN PN_AINFO Profinet alarm information
AddressConcept (GVL) ¶ Address Concept ¶ IO Systems like PROFIBUS DP and PROFINET IO use different address concepts. This results in different functions or function parameters to identify a Field Device, a slot or subslot inside a Field Device. In order to provide an uniform interface for the use with different types of IO communication subsystems, all Communication Function Blocks hide the address concept of the specific IO Systems. The Function Blocks use an abstract ‘’ID’’, a handle of data type DWORD, to uniquely identify a Profibus-Module or a Profinet-Submodule within an application. Therefore an application program is able to use the Communication Function Blocks without knowledge of the explicit hardware configuration (e.g. the MAC address or Station-Name of a Field Device or the slot-position of a module). This way an application or library can be developed without dependencies to hardware configuration data such as a specific IO-Driver or an addressing method. Generating a CommFB-ID ¶ There are different methods, generic and more specific ones, to generate an ID for identifying a Profibus/Profinet device: Note The actual value of ID should never be manipulated or created, only use the IDs created from theses sources described here. The value of ID can differ depending on the project structure or the driver version ! Profibus DP ¶ The input parameter ID of the Communication Function Blocks addresses one slot of a DP-slave or a DP-slave (Slot 0). This handle may be generated by using one of the following functions: ID : Conversion of a physical address of a DP-slave to the handle ADDR : Conversion of a handle to the physical address of a DP-slave SLOT_ID : Addressing a slot of a DP-slave Profinet IO ¶ The input parameter ID of the Communication Function Blocks addresses a Profinet-Submodule. A Profinet Module is just a container for at least one submodule. IO-Data and Parameters are always assigned to a submodule. The shortest way to get the ID of a submodule is to call the GetID()-method of the Profinet-Slave function block which is generated for each Profinet-Slave device: Code-Example: ID with GetID() - method PROGRAM PLC_PRG VAR ID : DWORD := CommFB.Constants.INVALID_ID ; END_VAR ID := PNSlave.GetID ( API := 0 , SLOT := 1 , SUBSLOT = 1 ); // get ID of 1. module Device Diagnosis ¶ A generic way for obtaining an CommFB-ID is by calling the method IDevice.GetDeviceInfo(). For an underlying Profinet/Profibus slave or module, the generic DEVICE_INFO structure, which is returned by this method, contains the unique CommFB-ID: Code-Example: ID with generic Device Diagnosis FUNCTION ListStationnames : DINT VAR_IN_OUT controller : DED.IDevice ; END_VAR VAR i : DINT ; childDevice : DED.IDevice ; deviceInfo : DED.DEVICE_INFO ; convertID : CommFB.ID_TO_ADDR ; pnAddress : CommFB.ADDR_TYPE ; stationName : STRING ; END_VAR FOR i := 0 TO TO_DINT ( controller.ChildNodeCount - 1 ) DO childDevice := DED.INode_TO_IDevice ( controller.GetChild ( TO_UDINT ( i ))); IF ( childDevice <> 0 AND_THEN childDevice.GetDeviceInfo ( deviceInfo ) = DED.ERROR.NO_ERROR ) THEN convertID ( EN := TRUE , ID := deviceInfo.idSystem , ADDR := pnAddress ); IF ( convertID.ENO ) THEN IF ( pnAddress.SYSTEM = CommFB.IO_SYSTEM_TYPE.PROFINET_IO ) THEN //we have a valid Profinet Address: stationName := pnAddress.PN.D.STATIONNAME ; END_IF END_IF END_IF END_FOR Address Conversion ¶ For some use cases it may be necessary to use native PROFIBUS DP and PROFINET IO addressing. These function blocks can be used for obtaining an ID to a native, protocol specific address and vice versa (see examples in the function block’s description) The handle may be generated by local means of the PLC or its configuration system or may be generated by using one of the following functions: ADDR_TO_ID : Conversion of a address of a PROFINET IO Device to the handle ID_TO_ADDR : Conversion of a handle to the address of a PROFINET IO Device InOut: Scope Name Type Initial Constant dummy UDINT 0
Addresses ¶ ADDR_TO_ID (FunctionBlock) ADDR_TYPE (Union) CREATE_ID (FunctionBlock) DP_ADDR (Struct) DP_DEVICE_ID (Struct) ID_TO_ADDR (FunctionBlock) IO_SYSTEM_TYPE (Enum) PN_ADDR (Struct) PN_DEVICE_ID (Struct) SUBSLOT_ID (Function)
ADDR_TO_ID (FB) ¶ 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 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 Flag STATUS DWORD Last detected status ID DWORD Handle