FUNCTION_BLOCK "ADD_FB" TITLE = 'ADD_FB' { // List of system attributes S7_tasklist:= 'OB100'; // Block is called if there is in a warm restart S7_m_c:= 'true'; // Block can be controlled and monitored S7_alarm_ui:= '1' // Setting “1” for PCS 7 message dialog ('0' for standard message dialog) } AUTHOR: ABC NAME: ADD_FB VERSION: '0.01' FAMILY: XYZ KNOW_HOW_PROTECT //???? VAR_INPUT EV_ID { S7_visible:='false'; S7_link:='false'; S7_param :='false'; // Parameter cannot be set in CFC S7_server:='alarm_archiv'; // Message no. assigned by server S7_a_type:='alarm_8p' // Block signals with ALARM_8P }:DWORD := 0; // Message ID RUNUPCYC{ S7_visible:='false'; S7_link:='false' } :INT := 3; // Number of run up cycles MSG_LOCK { S7_visible:='false'; S7_dynamic:='true'; S7_m_c:='true' } : BOOL := 0; // Enable 1=Messages locked IN1 { //??1 S7_shortcut:='addend1'; S7_unit:=''; S7_m_c:='true'; S7_dynamic:='true'; S7_archive:='shortterm' } :REAL :=0.0; //input value 1 IN2 { //??2 S7_shortcut:='addend2'; S7_unit:=''; S7_m_c:='true'; S7_dynamic:='true'; S7_archive:='shortterm' } :REAL :=0.0; //input value 2 HLIMIT { //???? S7_shortcut:='limit value'; S7_unit:=''; S7_m_c:='true'; S7_dynamic:='true'; S7_archive:='shortterm' } :REAL :=100.0; //limit value for output HYS { //????? S7_shortcut:='HYS'; S7_unit:=''; S7_m_c:='true' } :REAL :=1.0; //Hysteresis settings END_VAR //???? VAR_OUTPUT OUT1 { //???? S7_shortcut:='sum'; S7_unit:=''; S7_m_c:='true'; S7_dynamic:='true'; S7_archive:='shortterm' } :REAL :=0.0; //output value 1 QH_ALM { //????? S7_dynamic:='true'} : BOOL := 0; // 1=H-Alarm active QMSG_ERR { S7_visible:='false'; S7_dynamic:='true'} : BOOL := 0; // ALARM_8P: Error output QMSG_SUP { S7_visible:='false'; S7_dynamic:='true'; S7_m_c:='true'} : BOOL := 0; // 1=Message Suppression Active MSG_STAT { S7_visible:='false'; S7_dynamic:='true'} : WORD := 0; // Message: STATUS output MSG_ACK { S7_visible:='false'; S7_dynamic:='true'} : WORD := 0; // Message: ACK_STATE output END_VAR //???? VAR sbRESTART :BOOL := TRUE; // Initial start memory bit siRUNUPCNT :INT := 0; // Counter for RUNUPCYC execution sb_SIG_1: BOOL := FALSE; //Merker ALARM_8P Signal 1 sb_SIG_2: BOOL := FALSE; //Merker ALARM_8P Signal 2 sb_SIG_3: BOOL := FALSE; //Merker ALARM_8P Signal 3 sb_SIG_4: BOOL := FALSE; //Merker ALARM_8P Signal 4 sb_SIG_5: BOOL := FALSE; //Merker ALARM_8P Signal 5 sb_SIG_6: BOOL := FALSE; //Merker ALARM_8P Signal 6 sb_SIG_7: BOOL := FALSE; //Merker ALARM_8P Signal 7 sb_SIG_8: BOOL := FALSE; //Merker ALARM_8P Signal 8 //************************************************************************************** // Declaration Section Multiple Instances(SFB/FB), remember to copy the FB/FC blocks into //your projects manually! //************************************************************************************** ALARM_8P_1: ALARM_8P; // Generation of max. 8 messages with max. 10 auxiliary values END_VAR //???? VAR_TEMP pbALARM: BOOL; // Call up ALARM_8P pbM_SUP: BOOL; // Message suppression pb_SIG_1,pb_SIG_2,pb_SIG_3,pb_SIG_4,pb_SIG_5,pb_SIG_6,pb_SIG_7,pb_SIG_8:BOOL; // temp variable for alarm function // Start info: Structure with info for the OB that has just called the block TOP_SI: STRUCT EV_CLASS :BYTE; EV_NUM :BYTE; PRIORITY :BYTE; NUM :BYTE; TYP2_3 :BYTE; TYP1 :BYTE; ZI1 :WORD; ZI2_3 :DWORD; END_STRUCT; // Start info: Structure with info for the last called startup OB START_UP_SI: STRUCT EV_CLASS :BYTE; EV_NUM :BYTE; PRIORITY :BYTE; NUM :BYTE; TYP2_3 :BYTE; TYP1 :BYTE; ZI1 :WORD; ZI2_3 :DWORD; END_STRUCT; DUMMY :INT; // Auxiliary variable END_VAR //??????????OB? // Dependence on Calling OB //************************************************************************************* // Read out start info with SFC6 (RD_SINFO) DUMMY := RD_SINFO (TOP_SI := TOP_SI, START_UP_SI := START_UP_SI); pbM_SUP := MSG_LOCK; IF sbRESTART THEN // Initial start TOP_SI.NUM := 100; // Execute initial start as warm restart sbRESTART := FALSE; // Reset initial start END_IF; //????OB???????? // In which OB was the block called ? CASE WORD_TO_INT(BYTE_TO_WORD(TOP_SI.NUM)) OF //************************************************************************************ // Startup //************************************************************************************ // OB100: Warm restart 100: QH_ALM := 0; OUT1:=0; //default reset commands QMSG_ERR := 0; QMSG_SUP := 0; MSG_STAT := 0; MSG_ACK :=0; pb_SIG_1:= 0; pb_SIG_2:= 0; pb_SIG_3:= 0; pb_SIG_4:= 0; pb_SIG_5:= 0; pb_SIG_6:= 0; pb_SIG_7:= 0; pb_SIG_8:= 0; siRUNUPCNT := RUNUPCYC; // Save RUNUPCYC value ELSE //********************************************************************************** // Technological Section //********************************************************************************** OUT1:=IN1+IN2; IF OUT1>HLIMIT THEN QH_ALM:=true; ELSIF OUT1pb_SIG_1; ELSE siRUNUPCNT := siRUNUPCNT - 1; pbALARM :=FALSE; // Initialization no ALARM pbM_SUP := TRUE; END_IF; END_CASE; //???? // Messages with ALARM_8P //************************************************************************************** // STRING variables must not be linked to ALARM8_P as auxiliary values // so transfer in array of bytes IF pbALARM THEN ALARM_8P_1 (EN_R := TRUE, // Update output ACK_STATE ID := 16#EEEE, // Data channel for messages (always 16#EEEE) EV_ID:= EV_ID, // Message number > 0 SIG_1:= pb_SIG_1, // Signal 1 to be monitored SIG_2:= 0,//pb_SIG_2, // Signal 2 to be monitored SIG_3:= 0,//pb_SIG_3, // Signal 3 to be monitored SIG_4:= 0,//pb_SIG_4, // Signal 4 to be monitored SIG_5:= 0,//pb_SIG_5, // Signal 5 to be monitored SIG_6:= 0,//pb_SIG_6, // Signal 6 to be monitored SIG_7:= 0,//pb_SIG_7, // Signal 7 to be monitored SIG_8:= 0,//pb_SIG_8, // Signal 8 to be monitored SD_1 := AUX_PR01, // Auxiliary value 1 SD_2 := AUX_PR02, // Auxiliary value 2 SD_3 := AUX_PR03, // Auxiliary value 3 SD_4 := AUX_PR04, // Auxiliary value 4 SD_5 := AUX_PR05, // Auxiliary value 5 SD_6 := AUX_PR06, // Auxiliary value 6 SD_7 := AUX_PR07, // Auxiliary value 7 SD_8 := AUX_PR08, // Auxiliary value 8 SD_9 := AUX_PR09, // Auxiliary value 9 SD_10:= AUX_PR10); // Auxiliary value 10 QMSG_ERR := ALARM_8P_1.ERROR; // ERROR status parameter MSG_STAT := ALARM_8P_1.STATUS; // STATUS status parameter MSG_ACK := ALARM_8P_1.ACK_STATE; // Current OS confirmation status END_IF; IF (NOT QMSG_ERR) THEN // Note historical signals. sb_SIG_1:= pb_SIG_1; END_IF; IF (MSG_STAT = 21) THEN // Block locked pbM_SUP := TRUE; END_IF; QMSG_SUP := pbM_SUP; ; END_FUNCTION_BLOCK