RALARM (FB) ¶ FUNCTION_BLOCK RALARM The RALARM function block is used to receive alarm information of alarms from a PROFIBUS DP or a PROFINET IO subsystem. Code-Example: receive Alarm PROGRAM PLC_PRG VAR ralarm : CommFB.RALARM ; alarm : CommFB.AINFO_TYPE ; convertID : CommFB.ID_TO_ADDR ; addr : CommFB.ADDR_TYPE ; message : STRING ; END_VAR ralarm.EN := TRUE ; ralarm.MODE := CommFB.RALARM_MODE.ALL_ALARMS ; // receive all alarms from all devices connected to the controller ralarm.F_ID := PN_Controller.MasterID ; // Filter ID, if MODE = ALL_ALARMS use MasterID here, else the ID of a slot/subslot ralarm ( ainfo := alarm ); WHILE ( ralarm.NEW ) DO convertID ( EN := TRUE , ID := ralarm.ID , ADDR := addr ); IF ( convertID.ENO ) THEN IF ( addr.SYSTEM = CommFB.IO_SYSTEM_TYPE.PROFINET_IO ) THEN message := 'Station ' ; message := concat ( message , addr.PN.D.STATIONNAME ); message := concat ( message , ' (Slot = ' ); message := concat ( message , TO_STRING ( addr.PN.SLOT )); message := concat ( message , ') sends an alarm !' ); //Log Alarm to PLC-Logger CmpLog.LogAdd2 ( CmpLog.LogConstants.LOG_STD_LOGGER , 555 , CmpLog.LogClass.LOG_WARNING , 0 , 0 , message ); END_IF END_IF ralarm ( ainfo := alarm ); // exec-again END_WHILE InOut: Scope Name Type Comment Input EN BOOL Enable MODE INT Function specifier, see RALARM_MODE enum F_ID DWORD Slot / subslot identification to filter the alarms to receive. | If MODE = RALARM_MODE.ALL_ALARMS user MasterID Output ENO BOOL Function enabled, no error NEW BOOL New alarm received STATUS DWORD Host Controller interface status ID DWORD Identifier of the slot / subslot the alarm is received from (see: AddressConcept ) LEN INT Length of the received data record Inout AINFO AINFO_TYPE Alarm data that has been received
RALARM_MODE (ENUM) ¶ TYPE RALARM_MODE : Filter scope of RALARM .F_ID input. Attributes: qualified_only InOut: Name Initial Comment ALL_ALARMS 1 If the Host Controller interface has received an alarm, all function block outputs are updated. The alarm is acknowledged. ALARM_BY_ID 2 Receive an alarm for the slot or subslot the identification of which is given in F_ID input, all function block outputs are updated. The alarm is acknowledged ALARM_BY_SLOT 3 Receive an alarm for the slot the identification of which is given in F_ID input AND for all of it’s subslots ALARM_BY_DEVICE 4 Receive an alarm for the device the identification of which is given in F_ID input AND for all of it’s slots and subslots
RDIAG (FB) ¶ FUNCTION_BLOCK RDIAG Read Diagnosis data from DP Slave. This service is for Profibus only, Profinet uses a different, more advanced Diagnosis. Code-Example: Profibus DP Diagnosis PROGRAM PLC_PRG VAR readDiag : CommfB.RDIAG ; diag : CommFB.DP_DIAG ; sMessage : STRING ; END_VAR readDiag.REQ := TRUE ; readDiag.ID := CommFB.ID ( EN := TRUE , Master := CIFX_PB.MasterID , SEGMENT := 0 , STATION := 3 , SLOT := 0 ); readDiag.MLEN := TO_INT ( SIZEOF ( diag )); readDiag ( DINFO := diag ); IF ( readDiag.VALID ) THEN IF ( diag.status1.Diag.Station_Non_Existent ) THEN sMessage := 'Station with Address = 3 is not available !' ; END_IF END_IF InOut: Scope Name Type Comment Input REQ BOOL Request ID DWORD Identifier of a of DP-slave (see: AddressConcept ) MLEN INT maximum length to be read Output VALID BOOL New diagnosis data received and is valid BUSY BOOL FB is busy ERROR BOOL Error detected STATUS DWORD Last detected status LEN INT Length of diagnosis data Inout DINFO DP_DIAG Read diagnosis data (see: DP_DIAG
RDREC (FB) ¶ FUNCTION_BLOCK RDREC Read Process Data Record (RDREC) This function block executes an acyclic read of user or system record-data. The function is invoked when REQ input is equal to TRUE. The ID parameter identifies the slot or subslot of the Field Device the data record is read from. The INDEX input of the READ function block contains an integer which identifies the data record to be read, e.g. Profinet Diagnosis- or I&M-Data. The MLEN parameter specifies the count of bytes which shall be read as an maximum. The variable given as RECORD parameter shall be at least of MLEN byte. If the data record is read successfully, the VALID output indicates that the read data record is stored in the RECORD parameter. The LEN output contains the actual length of the data that has been read in byte. If an error occurred, the ERROR output indicates an error and the STATUS output contains the error code. Code-Example: use RDREC to read the diagnosis of a PN-Slave PROGRAM PLC_PRG VAR rdrec : CommFB.RDREC ; buffer : ARRAY [0..255] OF BYTE ; readError : DWORD ; diagReader : ProfinetCommon.DiagnosisDataReader ; channelDiag : ProfinetCommon.ChannelDiagnosisData ; END_VAR // Read Diagosis-Data: rdrec.ID := pnDevice.ID ; // "pnDevice" is a Profinet slave in the device tree rdrec.INDEX := TO_INT ( ProfinetCommon.DiagnosisRecordIndex.Device ); // = 16#F80C --> get all diagnosis for this device rdrec.MLEN := TO_INT ( SIZEOF ( buffer )); rdrec.RECORD := ADR ( buffer ); rdrec (); IF ( rdrec.VALID AND rdrec.REQ ) THEN //here we have valid data diagReader.InitData ( rdrec.RECORD , TO_UINT ( rdrec.LEN )); WHILE ( diagReader.Read ()) DO ; // do something useful with diag-data END_WHILE ELSIF ( rdrec.ERROR ) THEN readError := rdrec.STATUS ; // read service failed END_IF rdrec.REQ := rdrec.BUSY ; // only read once InOut: Scope Name Type Comment Input REQ BOOL Request ID DWORD Identifier of a slot / subslot of a Field Device (see: AddressConcept ) INDEX INT Index of the data record MLEN INT maximum length to be read RECORD POINTER TO BYTE Read data record Output VALID BOOL New data record received and is valid BUSY BOOL FB is busy ERROR BOOL Error detected STATUS DWORD Last detected status LEN INT Length of the read data record
SETIO_PART (FB) ¶ FUNCTION_BLOCK SETIO_PART The SETIO_PART function block sets the output data for a subset of the output data associated to a slot or subslot of a Field Device. The output data are addressed within the slot or subslot through the OFFSET and LEN parameters. The SETIO_PART function block sets the output data to the Host Controller interface into the cyclically written output data of the Field Device. The function block is invoked by a 1 of the EN input. If the Output data are stored successfully and the Field Device is still cyclically communicating, the ENO output is set to 1. If the Output data are stored successfully and the Field Device is still cyclically communicating, the ENO output is set to 1 Never use GETIO-/SETIO_PART FBs concurrently with %I/%Q-Input/Output-Mapping for the same slot/subslot ! InOut: Scope Name Type Comment Input EN BOOL Enable ID DWORD Identifier of a slot / subslot of a Field Device OFFSET INT Offset of the subset of output data LEN INT Length of the output data to write OUTPUTS POINTER TO BYTE IO data object to write Output ENO BOOL Flag indication sending data OK STATUS DWORD Last detected status ERROR BOOL Flag indication an error
WRREC (FB) ¶ FUNCTION_BLOCK WRREC Write Data Record (WRREC) This function block executes an acyclic write of user or system record-data. The ID parameter identifies the slot or subslot of the Field Device the process data record is written to. The INDEX input of the WRREC function block contains an integer which identifies the data record to be written. The data record shall be stored in the variable given at the RECORD parameter. The LEN input contains the length of the data record to be written in byte. The variable given as RECORD parameter shall be at least of LEN byte. The values of the RECORD and LEN parameters shall not be changed as long as the BUSY output is true. If the data record is written successfully, the DONE output indicates that the read data record is written to the Field Device. If an error occurred, the ERROR output indicates an error and the STATUS output contains the error code. InOut: Scope Name Type Comment Input REQ BOOL Request ID DWORD Identifier of a slot / subslot of a Field Device (see: AddressConcept ) INDEX INT Index of the data record LEN INT Length of the data record RECORD POINTER TO BYTE Data record Output DONE BOOL Data record written BUSY BOOL FB is busy ERROR BOOL Error detected STATUS DWORD Last detected status
File and Project Information ¶ Scope Name Type Content FileHeader creationDateTime date 29.03.2022, 09:31:49 companyName string 3S-Smart Software Solutions GmbH libraryFile CommFB.library primaryProject True productName CODESYS productProfile CODESYS V3.5 SP16 Patch 3 contentFile CommFB.clean.json version version 2.0.0.0 ProjectInformation IsEndUserLibrary bool True OnlineHelp True Released False LastModificationDateTime date 29.03.2022, 09:31:49 LibraryCategories library-category-list Application|Fieldbus Author string 3S - Smart Software Solutions GmbH Company 3S - Smart Software Solutions GmbH CompiledLibraryCompatibilityVersion CODESYS V3.5 SP15 DefaultNamespace CommFB Description See: Description DocFormat reStructuredText LanguageModelAttribute qualified-access-only Placeholder CommFB Project CommFB Title CommFB Version version 3.5.18.0
Library Reference ¶ This is a dictionary of all referenced libraries and their name spaces. IoDriver Profibus2 Interfaces ¶ Library Identification ¶ Name: IoDriver Profibus2 Interfaces Version: newest Company: System Namespace: IIoDrvProfibus Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: IoDriver Profibus2 Interfaces, * (System) SysMem ¶ Library Identification ¶ Placeholder: SysMem Default Resolution: SysMem, * (System) Namespace: SysMem Library Properties ¶ LinkAllContent: False Optional: False QualifiedOnly: True SystemLibrary: False Key: SysMem
PN_DEVICE_ID (STRUCT) ¶ TYPE PN_DEVICE_ID : STRUCT InOut: Name Type Comment STATIONNAME STRING Station name INSTANCE WORD Instance ID DEVICE WORD Device ID VENDOR WORD Vendor ID