Up/Down PCS7

: 2014-07-18

: komatic

: SCL



counter



4 Kb ( ~ 1 ) :). , .





counter

.



FC369 SelST16 (Output of the best or worst signal status), , , . AdvLib80 PCS7.




(Advanced Process Library (V8.0 SP2) Function Manual, 06/2013) pdf





Name: FB1806
Symbolic Name: CountScL
Symbol Comment: Up/down counter
Family: Count
Version: 2.1
Author: AdvLib80
Last modified: 08/08/2012
Use: SFC20,SFC6,SFB35,UDT1,UDT12,UDT16,FC369
Size: 3946 byte



counter



FUNCTION_BLOCK FB11806
TITLE ='Up/Down Counter'
{ S7_m_c := 'true'; S7_alarm_ui := '1'; S7_tasklist := 'OB100' }
AUTHOR : AdvLib80
FAMILY : Count
NAME : CountScL
VERSION : '2.1'
//reversed
 
VAR_INPUT
OldOut { S7_visible := 'false'; S7_link := 'false'; S7_read_back := 'always' }: DINT ; //Previous Output value
In { S7_dynamic := 'true' }: STRUCT //Digital Input value
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
LiOp { S7_dynamic := 'true'; S7_edit := 'para' }: STRUCT //1=Link, 0=Operator
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OffOp { Op_Level := '1'; S7_m_c := 'true'; S7_visible := 'false' }: BOOL := TRUE; //Counter Off by Operator: 1 = Counter is Off
UpOp { Op_Level := '1'; S7_m_c := 'true'; S7_visible := 'false' }: BOOL ; //1 = Up Counter
DnOp { Op_Level := '1'; S7_m_c := 'true'; S7_visible := 'false' }: BOOL ; //1 = Down Counter
OffLi { S7_dynamic := 'true' }: STRUCT //Counter Off by Field signal: 1 = Counter is Off
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
UpLi { S7_dynamic := 'true' }: STRUCT //1 = Up Counter
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
DnLi { S7_dynamic := 'true' }: STRUCT //1 = Down Counter
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OutAH_Lim { Op_Level := '2'; S7_visible := 'false'; S7_edit := 'para'; S7_m_c := 'true' }: DINT := 95; //Out Value High Alarm Limit
OutWH_Lim { Op_Level := '2'; S7_visible := 'false'; S7_edit := 'para'; S7_m_c := 'true' }: DINT := 90; //Out Value High Warning Limit
OutTH_Lim { Op_Level := '2'; S7_visible := 'false'; S7_edit := 'para'; S7_m_c := 'true' }: DINT := 85; //Out Value High Tolerance Limit
OutTL_Lim { Op_Level := '2'; S7_visible := 'false'; S7_edit := 'para'; S7_m_c := 'true' }: DINT ; //Out Value Low Tolerance Limit
OutWL_Lim { Op_Level := '2'; S7_visible := 'false'; S7_edit := 'para'; S7_m_c := 'true' }: DINT ; //Out Value Low Warning Limit
OutAL_Lim { Op_Level := '2'; S7_visible := 'false'; S7_edit := 'para'; S7_m_c := 'true' }: DINT ; //Out Value Low Alarm Limit
OutAH_En { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //High Alarm Enable
OutWH_En { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //High Warning Enable
OutTH_En { S7_visible := 'false'; S7_edit := 'para' }: BOOL ; //High Tolerance Enable
OutTL_En { S7_visible := 'false'; S7_edit := 'para' }: BOOL ; //Low Tolerance Enable
OutWL_En { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Low Warning Enable
OutAL_En { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Low Alarm Enable
OutAH_MsgEn { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Message enable for High Alarm
OutWH_MsgEn { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Message enable for High Warning
OutTH_MsgEn { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Message enable for High Tolerance
OutTL_MsgEn { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Message enable for Low Tolerance
OutWL_MsgEn { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Message enable for Low Warning
OutAL_MsgEn { S7_visible := 'false'; S7_edit := 'para' }: BOOL := TRUE; //Message enable for Low Alarm
OutOpHiScale { S7_m_c := 'true'; S7_edit := 'para' }: DINT := 100; //Out - Bar Display Limits for OS High Value
OutOpLoScale { S7_m_c := 'true'; S7_edit := 'para' }: DINT ; //Out - Bar Display Limits for OS Low Value
ResetCount { S7_dynamic := 'true' }: STRUCT //1 = Reset Counter
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
PresetEn { Op_Level := '2'; S7_m_c := 'true'; S7_visible := 'false'; S7_edit := 'para' }: BOOL ; //Preset Out
PresetVal { Op_Level := '2'; S7_m_c := 'true'; S7_edit := 'para'; S7_visible := 'false' }: DINT ; //Preset Value
MS_RelOp { Op_Level := '3'; S7_m_c := 'true'; S7_visible := 'false' }: BOOL ; //Operator input for MS Release, 1: MS release requirement
OnOp { Op_Level := '1'; S7_m_c := 'true'; S7_visible := 'false' }: BOOL ; //1=On Mode: On Mode by Operator
OosOp { Op_Level := '2'; S7_m_c := 'true'; S7_visible := 'false' }: BOOL ; //1=Oos Mode: Oos Mode by Operator
OosLi { S7_dynamic := 'true' }: STRUCT //1=Oos Mode: Oos Mode by Field Signal
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OutUnit { S7_unit := ''; S7_m_c := 'true'; S7_edit := 'para' }: INT ; //Unit of Out
MsgLock { S7_visible := 'false' }: STRUCT //Inhibit process message
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
SampleTime { S7_visible := 'false'; S7_link := 'false'; S7_sampletime := 'true'; S7_param := 'false' }: REAL := 1.000000e-001; //Sample Time[s]
RunUpCyc { S7_visible := 'false' }: INT := 3; //Number of cycles for which all messages are suppressed
MsgEvId { S7_visible := 'false'; S7_param := 'false'; S7_link := 'false'; S7_server := 'alarm_archiv'; S7_a_type := 'alarm_8p' }: DWORD ; //Message Event ID
BatchEn { S7_visible := 'false' }: BOOL ; //Enable Remote Operation of Controller by Batch Recipe
BatchID { S7_visible := 'false'; S7_m_c := 'true' }: DWORD ; //Current Batch ID (number)
BatchName { S7_visible := 'false'; S7_m_c := 'true' }: STRING [32 ]; //Current Batch Name
StepNo { S7_visible := 'false'; S7_m_c := 'true' }: DWORD ; //Batch Step Number
Occupied { S7_visible := 'false' }: BOOL ; //Occupied by Batch
SelFp1 { BLK_Jump := '1'; S7_visible := 'false' }: ANY ; //Select Faceplate 1
SelFp2 { BLK_Jump := '1'; S7_visible := 'false' }: ANY ; //Select Faceplate 2
OS_Perm { S7_visible := 'false' }: STRUCT //Operator Permissions
Bit0 : BOOL := TRUE; //Reserved
Bit1 : BOOL := TRUE; //1 = Operator can switch to On mode
Bit2 : BOOL := TRUE; //Reserved
Bit3 : BOOL := TRUE; //1 = Operator can switch to Out of service mode
Bit4 : BOOL := TRUE; //1 = Operator can switch to Off mode
Bit5 : BOOL := TRUE; //1 = Operator can switch to Up mode
Bit6 : BOOL := TRUE; //1 = Operator can switch to Down mode
Bit7 : BOOL := TRUE; //Reserved
Bit8 : BOOL := TRUE; //Reserved
Bit9 : BOOL := TRUE; //Reserved
Bit10 : BOOL := TRUE; //Reserved
Bit11 : BOOL := TRUE; //Reserved
Bit12 : BOOL := TRUE; //1 = Operator can enable function maintenance release
Bit13 : BOOL := TRUE; //1 = Operator can enter OutAH_Lim
Bit14 : BOOL := TRUE; //1 = Operator can enter OutWH_Lim
Bit15 : BOOL := TRUE; //1 = Operator can enter OutTH_Lim
Bit16 : BOOL := TRUE; //Reserved
Bit17 : BOOL := TRUE; //1 = Operator can enter OutAL_Lim
Bit18 : BOOL := TRUE; //1 = Operator can enter OutWL_Lim
Bit19 : BOOL := TRUE; //1 = Operator can enter OutTL_Lim
Bit20 : BOOL := TRUE; //Reserved
Bit21 : BOOL := TRUE; //1 = Operator can enable preset
Bit22 : BOOL := TRUE; //1 = Operator can enter preset value
Bit23 : BOOL := TRUE; //Reserved
Bit24 : BOOL := TRUE; //Reserved
Bit25 : BOOL := TRUE; //Reserved
Bit26 : BOOL := TRUE; //Reserved
Bit27 : BOOL := TRUE; //Reserved
Bit28 : BOOL := TRUE; //Reserved
Bit29 : BOOL := TRUE; //Reserved
Bit30 : BOOL := TRUE; //Reserved
Bit31 : BOOL := TRUE; //Reserved
END_STRUCT ;
OS_Perm_byte AT OS_Perm : ARRAY [0..3] OF BYTE;
OS_Perm_dw AT OS_Perm : DWORD;

OpSt_In { BLK_Jump := '1'; S7_visible := 'false' }: DWORD ; //Enabled operator stations
Feature { S7_visible := 'false' }: STRUCT //Status of various features
Bit0 : BOOL ; //0 = Start up with defined initializing in OB100; 1 = keep last stored values
Bit1 : BOOL ; //1 = OosLi can switch to Out of Service
Bit2 : BOOL ; //Reserved
Bit3 : BOOL ; //Reserved
Bit4 : BOOL ; //Reserved
Bit5 : BOOL ; //1 = Start up with OldOut
Bit6 : BOOL ; //Reserved
Bit7 : BOOL ; //Reserved
Bit8 : BOOL ; //Reserved
Bit9 : BOOL ; //Reserved
Bit10 : BOOL ; //Reserved
Bit11 : BOOL ; //Reserved
Bit12 : BOOL ; //Reserved
Bit13 : BOOL ; //Reserved
Bit14 : BOOL ; //Reserved
Bit15 : BOOL ; //Reserved
Bit16 : BOOL ; //Reserved
Bit17 : BOOL ; //Reserved
Bit18 : BOOL ; //Reserved
Bit19 : BOOL ; //Reserved
Bit20 : BOOL ; //Reserved
Bit21 : BOOL ; //Reserved
Bit22 : BOOL ; //1 = Enable message state actualization
Bit23 : BOOL ; //Reserved
Bit24 : BOOL ; //1 = Local authorization active
Bit25 : BOOL ; //Reserved
Bit26 : BOOL ; //1 = Reset switching points if switching to Out of Service
Bit27 : BOOL ; //Reserved
Bit28 : BOOL ; //1 = Disable switching points if MsgLock =1
Bit29 : BOOL ; //1 = Signal value =0 (0 active) if limit is violated
Bit30 : BOOL ; //1 = Resetting via input signal if LiOp =1, via faceplate if LiOp =0
Bit31 : BOOL ; //Reserved
END_STRUCT ;
END_VAR
VAR_OUTPUT
MS_Release : STRUCT //1: MS release
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
CountMode { S7_dynamic := 'true' }: INT ; //Counting Mode; 0=Off,1=Up,2=Down
Out { S7_edit := 'para'; S7_m_c := 'true'; S7_dynamic := 'true'; S7_shortcut := ''; S7_trend := 'OutOpLoScale,OutOpHiScale' }: DINT ; //Counter Value
OutAH_Act { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //Alarm High Active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OutWH_Act { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //Warning High Active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OutTH_Act { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //Tolerance High Active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OutTL_Act { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //Tolerance Low Active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OutWL_Act { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //Warning Low Active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OutAL_Act { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //Alarm Low Active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
SumMsgAct { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //Summary message, 1 = Any of the process, external or system messages is active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OosAct { S7_dynamic := 'true'; S7_m_c := 'true'; S7_xm_c := 'Value,true;' }: STRUCT //Out Of Service is active
Value : BOOL ; // Value
ST : BYTE := B#16#80; // Signal Status
END_STRUCT ;
OnAct { S7_visible := 'false'; S7_dynamic := 'true' }: STRUCT //On Mode is active
Value : BOOL := TRUE; //Value
ST : BYTE := B#16#80; //Signal Status
END_STRUCT ;
OS_PermOut { S7_visible := 'false'; S7_m_c := 'true' }: DWORD := DW#16#FFFFFFFF; //Operator Permission: Output for OS
OS_PermLog { S7_visible := 'false'; S7_m_c := 'true' }: DWORD := DW#16#FFFFFFFF; //Operator Permission: Output for OS
OpSt_Out { S7_visible := 'false'; S7_m_c := 'true' }: DWORD ; //Enabled operator stations
ST_Worst { S7_visible := 'false'; S7_m_c := 'true' }: BYTE := B#16#80; //Worst Signal Status
Status1 { S7_visible := 'false'; S7_m_c := 'true'; S7_dynamic := 'true' }: DWORD ; //Status Word1
Status2 { S7_visible := 'false'; S7_m_c := 'true'; S7_dynamic := 'true' }: DWORD ; //Status Word2
MsgErr { S7_visible := 'false' }: BOOL ; //1=Messaging Error Occurs
MsgStat { S7_visible := 'false' }: WORD ; //Message status
MsgAckn { S7_visible := 'false' }: WORD ; //Message acknowledgement status
ErrorNum { S7_visible := 'false'; S7_dynamic := 'true' }: INT := -1; //Error Number
END_VAR
VAR
SfbALARM_8P_1 : SFB35; //Multiple instances of ALARM_8P

SbMsgEff : BYTE ; //Effective message signal
SbMsgEff_bool AT SbMsgEff : ARRAY [0..7] OF BOOL;

SbMsgEffOld : BYTE ; //Effective message signal (Last cycle)
SnMsgToggle : INT ; //Reduce frequencey of call of ALARM_8P waiting for ACK
SnRunUpCyc : INT ; //Counters of run-up-cycle.
SdwPrevBatchId : DWORD ; //saved Batch_Id
SdwStepNoLoc : DWORD ; //variable for StepNo
SdwBatchId : DWORD ; //variable for BatchId
SarBatchName : ARRAY [1 .. 32 ] OF BYTE := 32 (B#16#0) ;
Sar_reserve : ARRAY [0 .. 7 ] OF //8 bytes reserved for future use.
BYTE ; //8 bytes reserved for future use.
SxShowAlarm : BOOL := TRUE; //Call instance of ALARM_8P
SxFirstStart : BOOL := TRUE; //Indicator for initial run/restart.
SxPrevIn : BOOL ; //Indicator for previous In.
SxPrevMode : BOOL := TRUE; //Indicator for previous Mode.
SxOff : BOOL := TRUE; //Off mode indication
SxOosLi : BOOL ; //rising edge of OosLi
SxReset : BOOL ; //rising edge of Reset
SxFeat_SwiPoiFalseActOld : BOOL ; //Old value of Feature Bit29
END_VAR
VAR_TEMP
stcTOP_SI : STRUCT
EV_CLASS : BYTE ; // Bits 0 to 3: Event ID Bits 4 to 7: Event class
EV_NUM : BYTE ; // Event number
PRIORITY : BYTE ; // Number of the priority class (meaning OF B#16#FE: OB NOT available or locked)
NUM : BYTE ; // OB number.
TYP2_3 : BYTE ; // Data ID 2_3: identifies the information entered in ZI2_3
TYP1 : BYTE ; // Data ID 1 : identifies the information entered in ZI1
ZI1 : WORD ; // Additional information 1
ZI2_3 : DWORD ; // Additional information 2_3
END_STRUCT ;
stcSTART_UP_SI : STRUCT
EV_CLASS : BYTE ; // Bits 0 to 3: Event ID Bits 4 to 7: Event class
EV_NUM : BYTE ; // Event number
PRIORITY : BYTE ; // Number of the priority class (meaning OF B#16#FE: OB NOT available or locked)
NUM : BYTE ; // OB number.
TYP2_3 : BYTE ; // Data ID 2_3: identifies the information entered in ZI2_3
TYP1 : BYTE ; // Data ID 1 : identifies the information entered in ZI1
ZI1 : WORD ; // Additional information 1
ZI2_3 : DWORD ; // Additional information 2_3
END_STRUCT ;
stcDigVal : STRUCT
Value : BOOL ; // Value
ST : BYTE ; // Signal Status
END_STRUCT ;
nTemp : INT ; //Temporary variable, Error SFC/SFB call
byTemp : BYTE ; //Variable used in swapping of bytes

dwOS_Perm_Out : DWORD ; //OS_Perm
dwOS_Perm_Out_byte AT dwOS_Perm_Out : ARRAY [0..3] OF BYTE;
dwOS_Perm_Out_bool AT dwOS_Perm_Out : ARRAY [0..31] OF BOOL;

dwStatus1 : DWORD ; //Variable for status1
dwStatus1_bool AT dwStatus1 : ARRAY [0..31] OF BOOL;

dwStatus2 : DWORD ; //Variable for status2
dwStatus2_bool AT dwStatus2 : ARRAY [0..31] OF BOOL;

stcInST : STRUCT //Input 0..15 Signal Status
b0 : BYTE ;
b1 : BYTE ;
b2 : BYTE ;
b3 : BYTE ;
b4 : BYTE ;
b5 : BYTE ;
b6 : BYTE ;
b7 : BYTE ;
b8 : BYTE ;
b9 : BYTE ;
b10 : BYTE ;
b11 : BYTE ;
b12 : BYTE ;
b13 : BYTE ;
b14 : BYTE ;
b15 : BYTE ;
END_STRUCT ;
xFeature_StartUp : BOOL ; //Variable for StartUp characteristics.
xFeature_OosLiEn : BOOL ; //Variable for Oosmode
xFeatStartUpWithOldOut : BOOL ; //1 = Start up with OldOut
xFeature_MsgAck : BOOL ; //Variable to enable Msg Acknowledge
xFeat_SwiPoiDis : BOOL ;
xFeat_SwiPoiFalseAct : BOOL ;
xFeatLocalAuth : BOOL ; //Bit 24 = 1, Function local authorization active
xFeatSwiPoiOOS : BOOL ; //Bit 26 = 1, 1 = Reset switching points if switching to Out of Service
xFeat_ResetDpdsOnLiOp : BOOL ; //Bit 30 = 1, 1 = Resetting via input signal if LiOp =1, via faceplate if LiOp =0
xOS_Perm_On : BOOL ; //Operator permission to switch to On State.
xOS_Perm_Oos : BOOL ; //Operator permission to switch to Oos state.
xOS_Perm_AH_Lim : BOOL ; //Operator permission to set OutAH_Lim value.
xOS_Perm_AL_Lim : BOOL ; //Operator permission to set OutAL_Lim value.
xOS_Perm_WH_Lim : BOOL ; //Operator permission to set OutWH_Lim value.
xOS_Perm_WL_Lim : BOOL ; //Operator permission to set OutWL_Lim value.
xOS_Perm_TH_Lim : BOOL ; //Operator permission to set OutTH_Lim value.
xOS_Perm_TL_Lim : BOOL ; //Operator permission to set OutTL_Lim value.
xOS_Perm_MS_Release : BOOL ; //Operator permission for MS_Release
xOS_Perm_Preset_En : BOOL ; //Operator permission to enable preset.
xOS_Perm_Preset_Val : BOOL ; //Operator permission to enter preset value.
xOS_Perm_Count_Off : BOOL ; //Operator persmission to off.
xOS_Perm_Count_Up : BOOL ; //Operator permission to Count up;
xOS_Perm_Count_Down : BOOL ; //Operator permission to count down.
xUpDn : BOOL ; //Variable to indicate the mode of count i.e Up or Down
xOB_Cycle : BOOL ; //block is running in a cyclic interrupt OB
xOB_Start : BOOL ; //block is running in start OB
xInvalidSignalState : BOOL ; //Status1 Bit14
END_VAR
 
 
BEGIN
stcDigVal.Value :=false;
stcDigVal.ST :=B#16#80;
dwStatus1 :=Status1;
dwStatus2 :=Status2;
xUpDn :=SxPrevMode;
xFeature_StartUp :=Feature.Bit0;
xFeature_OosLiEn :=Feature.Bit1;
xFeatStartUpWithOldOut :=Feature.Bit5;
xFeature_MsgAck :=Feature.Bit22;
xFeatSwiPoiOOS :=Feature.Bit26;
xFeat_SwiPoiDis :=Feature.Bit28;
xFeat_SwiPoiFalseAct :=Feature.Bit29;
xFeatLocalAuth :=Feature.Bit24;
xFeat_ResetDpdsOnLiOp :=Feature.Bit30;
 
dwOS_Perm_Out_byte[3]:=OS_Perm_byte[0];
dwOS_Perm_Out_byte[2]:=OS_Perm_byte[1];
dwOS_Perm_Out_byte[1]:=OS_Perm_byte[2];
dwOS_Perm_Out_byte[0]:=OS_Perm_byte[3];
 
OS_PermOut :=dwOS_Perm_Out;
xOS_Perm_On :=false;
xOS_Perm_Oos :=OS_Perm.Bit3;
xOS_Perm_Count_Off :=OS_Perm.Bit4;
xOS_Perm_Count_Up :=OS_Perm.Bit5;
xOS_Perm_Count_Down :=OS_Perm.Bit6;
xOS_Perm_MS_Release :=OS_Perm.Bit12;
xOS_Perm_AH_Lim :=OS_Perm.Bit13;
xOS_Perm_WH_Lim :=OS_Perm.Bit14;
xOS_Perm_TH_Lim :=OS_Perm.Bit15;
xOS_Perm_AL_Lim :=OS_Perm.Bit17;
xOS_Perm_WL_Lim :=OS_Perm.Bit18;
xOS_Perm_TL_Lim :=OS_Perm.Bit19;
xOS_Perm_Preset_En :=OS_Perm.Bit21;
xOS_Perm_Preset_Val :=OS_Perm.Bit22;
 
nTemp:=RD_SINFO(TOP_SI :=stcTOP_SI,START_UP_SI :=stcSTART_UP_SI );
xOB_Cycle:= (DWORD_TO_INT(BYTE_TO_DWORD(stcTOP_SI.NUM)) >= 30) AND (DWORD_TO_INT(BYTE_TO_DWORD(stcTOP_SI.NUM)) <= 38);
xOB_Start:= BYTE_TO_INT(stcTOP_SI.NUM) = 100;

ErrorNum :=0;
xInvalidSignalState :=false;
MS_Release.Value :=(OnAct.Value OR OosAct.Value) AND MS_RelOp;
 
IF NOT (OnAct.Value OR OosAct.Value) THEN MS_RelOp:=false; END_IF;
 
IF xFeatLocalAuth
THEN
OpSt_Out:=OpSt_In OR DW#16#80000000;
ELSE
OpSt_Out:=OpSt_In AND DW#16#7FFFFFFF;
END_IF;
 
IF OnOp
THEN
OosAct.Value:=false;
ELSE
IF (OosLi.Value AND xFeature_OosLiEn) AND (NOT SxOosLi) OR OosOp THEN OosAct.Value:=true; END_IF;
END_IF;
 
SxOosLi:=OosLi.Value;
OnAct.Value:= NOT OosAct.Value;
 
IF OosAct.Value
THEN
SxOff:=true;
ErrorNum:=0;
CountMode:=0;
IF xFeatSwiPoiOOS
THEN
OutAH_Act:=stcDigVal;
OutWH_Act:=stcDigVal;
OutTH_Act:=stcDigVal;
OutTL_Act:=stcDigVal;
OutWL_Act:=stcDigVal;
OutAL_Act:=stcDigVal;
IF xFeat_SwiPoiFalseAct
THEN
OutAH_Act.Value:=true;
OutWH_Act.Value:=true;
OutTH_Act.Value:=true;
OutTL_Act.Value:=true;
OutWL_Act.Value:=true;
OutAL_Act.Value:=true;
END_IF;
END_IF;
END_IF;

IF SxFirstStart OR xOB_Start
THEN
SxFirstStart:=false;
SxShowAlarm:=true;
IF xOB_Start THEN SnRunUpCyc:=RunUpCyc; END_IF;
IF NOT xFeature_StartUp
THEN
SxOff:=true;
Out:=PresetVal;
CountMode:=0;
OutAH_Act:=stcDigVal;
OutWH_Act:=stcDigVal;
OutTH_Act:=stcDigVal;
OutTL_Act:=stcDigVal;
OutWL_Act:=stcDigVal;
OutAL_Act:=stcDigVal;
SumMsgAct:=stcDigVal;
IF xFeat_SwiPoiFalseAct
THEN
OutAH_Act.Value:=true;
OutWH_Act.Value:=true;
OutTH_Act.Value:=true;
OutTL_Act.Value:=true;
OutWL_Act.Value:=true;
OutAL_Act.Value:=true;
END_IF;
OS_PermLog:=DW#16#FFFFFFFF;
OS_PermOut:=DW#16#FFFFFFFF;
ST_Worst:=B#16#80;
MS_Release.Value:=false;
MsgErr:=false;
MsgStat:=0;
MsgAckn:=0;
SxFeat_SwiPoiFalseActOld:=xFeat_SwiPoiFalseAct;
END_IF;
IF xFeatStartUpWithOldOut THEN Out:=OldOut; END_IF;
END_IF;
 
IF NOT OosAct.Value AND xOB_Cycle //A7de
THEN
IF xFeat_SwiPoiFalseAct XOR SxFeat_SwiPoiFalseActOld
THEN
OutAH_Act.Value:=NOT OutAH_Act.Value;
OutWH_Act.Value:=NOT OutWH_Act.Value;
OutTH_Act.Value:=NOT OutTH_Act.Value;
OutTL_Act.Value:=NOT OutTL_Act.Value;
OutWL_Act.Value:=NOT OutWL_Act.Value;
OutAL_Act.Value:=NOT OutAL_Act.Value;
END_IF;
SxFeat_SwiPoiFalseActOld:=xFeat_SwiPoiFalseAct;
IF LiOp.Value // A7e0
THEN
IF OffLi.Value // A7e1
THEN
SxOff:=true;
IF UpLi.Value OR DnLi.Value // A7e9
THEN
ErrorNum:=51;
xInvalidSignalState:=true;
END_IF;
ELSE // A7e1
IF UpLi.Value AND DnLi.Value //A7e4
THEN
ErrorNum:=51;
xInvalidSignalState:=true;
ELSIF UpLi.Value// A7e5
THEN
xUpDn:=true;
SxOff:=false;
ELSIF DnLi.Value //A7e5
THEN
xUpDn:=false;
SxOff:=false;
END_IF;
END_IF;
ELSE // a7e0
IF OffOp THEN SxOff:=true; END_IF;
IF UpOp THEN xUpDn:=true; SxOff:=false; END_IF;
IF DnOp THEN xUpDn:=false; SxOff:=false; END_IF;
END_IF; // a7e9
 
if SxOff
THEN
CountMode:=0;
ELSIF xUpDn
THEN
CountMode:=1;
ELSE
CountMode:=2;
END_IF;
xOS_Perm_Count_Off:=NOT LiOp.Value AND xOS_Perm_Count_Off AND (NOT SxOff);
xOS_Perm_Count_Up:=NOT LiOp.Value AND xOS_Perm_Count_Up AND (NOT xUpDn OR SxOff);
xOS_Perm_Count_Down:=NOT LiOp.Value AND xOS_Perm_Count_Down AND (xUpDn OR SxOff);
xOS_Perm_AH_Lim:=(xUpDn OR SxOff) AND xOS_Perm_AH_Lim;
xOS_Perm_WH_Lim:=(xUpDn OR SxOff) AND xOS_Perm_WH_Lim;
xOS_Perm_TH_Lim:=(xUpDn OR SxOff) AND xOS_Perm_TH_Lim;
xOS_Perm_AL_Lim:=(NOT xUpDn OR SxOff) AND xOS_Perm_AL_Lim;
xOS_Perm_WL_Lim:=(NOT xUpDn OR SxOff) AND xOS_Perm_WL_Lim;
xOS_Perm_TL_Lim:=(NOT xUpDn OR SxOff) AND xOS_Perm_TL_Lim;

IF xUpDn <> SxPrevMode
THEN
IF xUpDn
THEN
OutTL_Act.Value:=xFeat_SwiPoiFalseAct;
OutWL_Act.Value:=xFeat_SwiPoiFalseAct;
OutAL_Act.Value:=xFeat_SwiPoiFalseAct;
ELSE
OutAH_Act.Value:=xFeat_SwiPoiFalseAct;
OutWH_Act.Value:=xFeat_SwiPoiFalseAct;
OutTH_Act.Value:=xFeat_SwiPoiFalseAct;
END_IF;
END_IF; // a7f1
 
IF (NOT LiOp.Value AND xFeat_ResetDpdsOnLiOp OR NOT xFeat_ResetDpdsOnLiOp) AND PresetEn
THEN
Out:=PresetVal;
END_IF;

IF (((xFeat_ResetDpdsOnLiOp AND LiOp.Value) OR NOT xFeat_ResetDpdsOnLiOp) AND ResetCount.Value) AND NOT SxReset
THEN
Out:=0;
END_IF;

IF ((NOT SxPrevIn AND In.Value) AND NOT PresetEn) AND NOT (NOT SxReset AND ResetCount.Value) AND NOT SxOff
THEN
IF xUpDn // a7f7
THEN
IF Out < 2147483647 //a7f6
THEN
Out:=Out+1;
END_IF;
ELSE
IF Out > -2147483648
THEN
Out:=Out-1;
END_IF;
END_IF;
END_IF; //a7f6

IF Out >= 2147483647 THEN Out:=2147483647; END_IF;
IF Out <= -2147483648 THEN Out:=-2147483648; END_IF;

IF CountMode = 1
THEN
IF (Out >= OutAH_Lim AND OutAH_En) AND NOT (MsgLock.Value AND xFeat_SwiPoiDis)
THEN
OutAH_Act.Value:=NOT xFeat_SwiPoiFalseAct;
ELSE
OutAH_Act.Value:=xFeat_SwiPoiFalseAct;
END_IF;

IF ((Out>=OutWH_Lim) AND OutWH_En) AND NOT (MsgLock.Value AND xFeat_SwiPoiDis)
THEN
OutWH_Act.Value:=NOT xFeat_SwiPoiFalseAct;
ELSE
OutWH_Act.Value:=xFeat_SwiPoiFalseAct;
END_IF;
 
IF ((Out>=OutTH_Lim) AND OutTH_En) AND NOT (MsgLock.Value AND xFeat_SwiPoiDis)
THEN
OutTH_Act.Value:=NOT xFeat_SwiPoiFalseAct;
ELSE
OutTH_Act.Value:=xFeat_SwiPoiFalseAct;
END_IF;
ELSIF CountMode=2
THEN
IF ((Out <= OutAL_Lim) AND OutAL_En) AND NOT (MsgLock.Value AND xFeat_SwiPoiDis)
THEN
OutAL_Act.Value:=NOT xFeat_SwiPoiFalseAct;
ELSE
OutAL_Act.Value:=xFeat_SwiPoiFalseAct;
END_IF;
 
IF ((Out<=OutWL_Lim) AND OutWL_En) AND NOT (MsgLock.Value AND xFeat_SwiPoiDis)
THEN
OutWL_Act.Value:=NOT xFeat_SwiPoiFalseAct;
ELSE
OutWL_Act.Value:=xFeat_SwiPoiFalseAct;
END_IF;

IF ((Out<=OutTL_Lim) AND OutTL_En) AND NOT (MsgLock.Value AND xFeat_SwiPoiDis)
THEN
OutTL_Act.Value:=NOT xFeat_SwiPoiFalseAct;
ELSE
OutTL_Act.Value:=xFeat_SwiPoiFalseAct;
END_IF;
END_IF;

SumMsgAct.Value:=(xFeat_SwiPoiFalseAct XOR OutAH_Act.Value) OR
(xFeat_SwiPoiFalseAct XOR OutWH_Act.Value) OR
(xFeat_SwiPoiFalseAct XOR OutTH_Act.Value) OR
(xFeat_SwiPoiFalseAct XOR OutTL_Act.Value) OR
(xFeat_SwiPoiFalseAct XOR OutWL_Act.Value) OR
(xFeat_SwiPoiFalseAct XOR OutAL_Act.Value);

IF CountMode<>0 THEN OldOut:=Out; END_IF;

SxPrevIn:=In.Value;
SxPrevMode:=xUpDn;
SxReset:=ResetCount.Value;
OutAH_Act.ST:=In.ST;
OutWH_Act.ST:=In.ST;
OutTH_Act.ST:=In.ST;
OutTL_Act.ST:=In.ST;
OutWL_Act.ST:=In.ST;
OutAL_Act.ST:=In.ST;
stcInST.b0:=In.ST;
ST_Worst:=SelST16(InST :=stcInST,Num := 1,SelPrio :=0);
 
IF SnRunUpCyc > 0 THEN SnRunUpCyc:=SnRunUpCyc-1; END_IF;
END_IF;
 
IF SnRunUpCyc=0 AND xOB_Cycle OR xOB_Start // A80e
THEN
IF SnMsgToggle>=1
THEN
SnMsgToggle:=0;
ELSE
SnMsgToggle:=1;
END_IF;

IF SdwBatchId<>BatchID
THEN
FOR nTemp:=1 TO 32 BY 1 DO
SarBatchName[nTemp]:=B#16#0;
END_FOR;

nTemp:=BLKMOV(SRCBLK :=BatchName,DSTBLK :=SarBatchName);
SdwBatchId:=BatchID;
END_IF;
 
IF OosAct.Value
THEN
SbMsgEff:=B#16#0;
ELSE
SbMsgEff_bool[0]:=((xFeat_SwiPoiFalseAct XOR OutAH_Act.Value) AND OutAH_MsgEn) AND NOT MsgLock.Value;
SbMsgEff_bool[1]:=((xFeat_SwiPoiFalseAct XOR OutWH_Act.Value) AND OutWH_MsgEn) AND NOT MsgLock.Value;
SbMsgEff_bool[2]:=((xFeat_SwiPoiFalseAct XOR OutTH_Act.Value) AND OutTH_MsgEn) AND NOT MsgLock.Value;
SbMsgEff_bool[3]:=((xFeat_SwiPoiFalseAct XOR OutTL_Act.Value) AND OutTL_MsgEn) AND NOT MsgLock.Value;
SbMsgEff_bool[4]:=((xFeat_SwiPoiFalseAct XOR OutWL_Act.Value) AND OutWL_MsgEn) AND NOT MsgLock.Value;
SbMsgEff_bool[5]:=((xFeat_SwiPoiFalseAct XOR OutAL_Act.Value) AND OutAL_MsgEn) AND NOT MsgLock.Value;
SbMsgEff_bool[6]:=false;
SbMsgEff_bool[7]:=false;
END_IF;

IF (SbMsgEffOld<>SbMsgEff OR SxShowAlarm) OR
((NOT OosAct.Value AND xFeature_MsgAck) AND (SnMsgToggle=0)) AND
(((MsgAckn AND W#16#FF) <> W#16#FF) OR (SfbALARM_8P_1.STATUS<>W#16#0))
THEN
SfbALARM_8P_1.EN_R:=true;
SfbALARM_8P_1.ID:=W#16#EEEE;
SfbALARM_8P_1.EV_ID:=MsgEvId;
SfbALARM_8P_1.SIG_1:=SbMsgEff_bool[0];
SfbALARM_8P_1.SIG_2:=SbMsgEff_bool[1];
SfbALARM_8P_1.SIG_3:=SbMsgEff_bool[2];
SfbALARM_8P_1.SIG_4:=SbMsgEff_bool[3];
SfbALARM_8P_1.SIG_5:=SbMsgEff_bool[4];
SfbALARM_8P_1.SIG_6:=SbMsgEff_bool[5];
SfbALARM_8P_1.SIG_7:=SbMsgEff_bool[6];
SfbALARM_8P_1.SIG_8:=SbMsgEff_bool[7];

SfbALARM_8P_1(SD_1 := SarBatchName
,SD_2 := StepNo
,SD_3 := BatchID
);
IF xFeature_MsgAck
THEN
MsgErr:=SfbALARM_8P_1.ERROR;
MsgStat:=SfbALARM_8P_1.STATUS;
MsgAckn:=SfbALARM_8P_1.ACK_STATE;
ELSE
MsgErr:=false;
MsgStat:=W#16#0;
MsgAckn:=W#16#0;
END_IF;
SbMsgEffOld:=SbMsgEff;
SxShowAlarm:=SfbALARM_8P_1.STATUS = W#16#14;
END_IF;
END_IF;
 
IF xOB_Start OR xOB_Cycle
THEN
IF xOB_Start
THEN
OS_PermLog:=DW#16#0;
ELSE
IF OosAct.Value
THEN
OS_PermLog:=DW#16#1002 AND OS_PermOut;
ELSE
dwOS_Perm_Out:=OS_Perm_dw;
dwOS_Perm_Out_bool[1]:=xOS_Perm_On;
dwOS_Perm_Out_bool[3]:=xOS_Perm_Oos;
dwOS_Perm_Out_bool[4]:=xOS_Perm_Count_Off;
dwOS_Perm_Out_bool[5]:=xOS_Perm_Count_Up;
dwOS_Perm_Out_bool[6]:=xOS_Perm_Count_Down;
dwOS_Perm_Out_bool[12]:=xOS_Perm_MS_Release;
dwOS_Perm_Out_bool[13]:=xOS_Perm_AH_Lim;
dwOS_Perm_Out_bool[14]:=xOS_Perm_WH_Lim;
dwOS_Perm_Out_bool[15]:=xOS_Perm_TH_Lim;
dwOS_Perm_Out_bool[17]:=xOS_Perm_AL_Lim;
dwOS_Perm_Out_bool[18]:=xOS_Perm_WL_Lim;
dwOS_Perm_Out_bool[19]:=xOS_Perm_TL_Lim;

dwOS_Perm_Out_bool[21]:= ((NOT LiOp.Value AND xFeat_ResetDpdsOnLiOp) OR (NOT xFeat_ResetDpdsOnLiOp)) AND xOS_Perm_Preset_En;

dwOS_Perm_Out_bool[22]:=xOS_Perm_Preset_Val;
byTemp:=dwOS_Perm_Out_byte[3];
dwOS_Perm_Out_byte[3]:=dwOS_Perm_Out_byte[0];
dwOS_Perm_Out_byte[0]:=byTemp;
byTemp:=dwOS_Perm_Out_byte[2];
dwOS_Perm_Out_byte[2]:=dwOS_Perm_Out_byte[1];
dwOS_Perm_Out_byte[1]:=byTemp;

OS_PermLog:=dwOS_Perm_Out;
END_IF;
END_IF;

IF NOT OosAct.Value
THEN
dwStatus1_bool[24]:=Occupied;
dwStatus1_bool[25]:=BatchEn;
dwStatus1_bool[19]:=LiOp.Value;
dwStatus1_bool[22]:=xInvalidSignalState;
dwStatus2_bool[24]:=MsgLock.Value;
dwStatus2_bool[31]:=OutAH_En;
dwStatus2_bool[16]:=OutWH_En;
dwStatus2_bool[17]:=OutTH_En;
dwStatus2_bool[18]:=OutTL_En;
dwStatus2_bool[19]:=OutWL_En;
dwStatus2_bool[20]:=OutAL_En;
dwStatus2_bool[21]:=OutAH_MsgEn;
dwStatus2_bool[22]:=OutWH_MsgEn;
dwStatus2_bool[23]:=OutTH_MsgEn;
dwStatus2_bool[8]:=OutTL_MsgEn;
dwStatus2_bool[9]:=OutWL_MsgEn;
dwStatus2_bool[10]:=OutAL_MsgEn;
ELSE
dwStatus1:=DW#16#0;
dwStatus2:=DW#16#0;
END_IF;
 
dwStatus1_bool[27]:=OosAct.Value;
dwStatus1_bool[28]:=OosLi.Value;
dwStatus1_bool[30]:=OnAct.Value;

dwStatus2_bool[25]:=OutAH_Act.Value;
dwStatus2_bool[26]:=OutWH_Act.Value;
dwStatus2_bool[27]:=OutTH_Act.Value;
dwStatus2_bool[28]:=OutTL_Act.Value;
dwStatus2_bool[29]:=OutWL_Act.Value;
dwStatus2_bool[30]:=OutAL_Act.Value;

dwStatus2_bool[12]:=NOT SxOff AND xUpDn;
dwStatus2_bool[13]:=SxOff;
 
dwStatus2_bool[14]:=NOT SxOff AND NOT xUpDn;
dwStatus2_bool[7]:=MS_RelOp;

Status1:=dwStatus1;
Status2:=dwStatus2;

OnOp:=false;
OosOp:=false;
OffOp:=false;
UpOp:=false;
DnOp:=false;
PresetEn:=false;
END_IF;
END_FUNCTION_BLOCK



:





nTemp:=RD_SINFO(TOP_SI :=stcTOP_SI,START_UP_SI :=stcSTART_UP_SI );
xOB_Cycle:= (DWORD_TO_INT(BYTE_TO_DWORD(stcTOP_SI.NUM)) >= 30) AND (DWORD_TO_INT(BYTE_TO_DWORD(stcTOP_SI.NUM)) <= 38);
xOB_Start:= BYTE_TO_INT(stcTOP_SI.NUM) = 100;



ALARM_8P (SFB35)



SfbALARM_8P_1.EN_R:=true;
SfbALARM_8P_1.ID:=W#16#EEEE;
SfbALARM_8P_1.EV_ID:=MsgEvId;
SfbALARM_8P_1.SIG_1:=SbMsgEff_bool[0];
SfbALARM_8P_1.SIG_2:=SbMsgEff_bool[1];
SfbALARM_8P_1.SIG_3:=SbMsgEff_bool[2];
SfbALARM_8P_1.SIG_4:=SbMsgEff_bool[3];
SfbALARM_8P_1.SIG_5:=SbMsgEff_bool[4];
SfbALARM_8P_1.SIG_6:=SbMsgEff_bool[5];
SfbALARM_8P_1.SIG_7:=SbMsgEff_bool[6];
SfbALARM_8P_1.SIG_8:=SbMsgEff_bool[7];

SfbALARM_8P_1(SD_1 := SarBatchName
,SD_2 := StepNo
,SD_3 := BatchID
);



counter

Block checksum , ,
.





PCS7 (Advanced Process Library (V8.0 SP2) (zip, 3.5Mb)







: 5964

.

:

(4000 max):

: