//編譯選項(xiàng)
//Compile options
{
Scl_OverwriteBlocks:= 'y' ;
Scl_CreateObjectCode:= 'y' ;
Scl_OptimizeObjectCode:= 'y' ;
Scl_MonitorArrayLimits:= 'y' ;
Scl_CreateDebugInfo := 'y'
}
FUNCTION_BLOCK MonAn
TITLE='Analog Monitoring'
NAME:MonAn
FAMILY:MyLib
AUTHOR:NC
VERSION:'1.0'
// KNOW_HOW_PROTECT
VAR_INPUT
PV : REAL := 0.0; //Process Value
PV_Unit : INT:=1001 ; // Unit 單位
SimOn: BOOL := FALSE; //Simalation On 仿真打開
SimPV : REAL := 0.0; // Simulation Value 仿真值
PVHR : REAL := 100.0; // high range 過程值量程上限
PVLR : REAL := 0.0; // low range過程值量程下限
HHA : REAL := 95.0; // H limit Alarm 高高報(bào)警
HW : REAL := 90.0; // H limit Warning 高警告
LW : REAL := 10.0; // L limit Warning 低警告
LLA : REAL := 5.0; // L Limit Alarm 低低報(bào)警
HHA_EN : BOOL := TRUE; // H Alarm Message Enable 高高報(bào)警消息使能
HW_EN : BOOL := TRUE; // H Warning Message Enable 高警告消息使能
LW_EN : BOOL := TRUE; // L Warning Message Enable 低警告消息使能
LLA_EN : BOOL := TRUE; // L Alarm Message Enable 低低報(bào)警消息使能
Hys : REAL:=0.0; // Hysterese value 滯后
Deadband : REAL:=0.0 ; // Width of Dead band 零點(diǎn)死區(qū)
ADCT : REAL:=0.0; // Alarm delay coming time 報(bào)警延遲到達(dá)時(shí)間
WDCT : REAL:=0.0; // Warning delay coming time警告延遲到達(dá)時(shí)間
ADGT : REAL:=0.0; // Alarm delay going time警告延遲離開時(shí)間
WDGT : REAL:=0.0; // Warning delay going time報(bào)警延遲離開時(shí)間
SAMPLE_T : REAL := 0.2; // Sampletime采樣時(shí)間
PULSE : BOOL;//脈沖輸入
//消息事件ID號
MsgEvID1 :DWORD:=DW#16#0;
MsgEvID2 :DWORD:=DW#16#0;
MsgEvID3 :DWORD:=DW#16#0;
MsgEvID4 :DWORD:=DW#16#0;
SD1 :ANY;
SD2 :ANY;
SD3 :ANY;
SD4 :ANY;
END_VAR
VAR_IN_OUT
OP_dwCmd : DWORD :=16#0; // control word wincc操作命令
END_VAR
VAR_OUTPUT
QdwState : DWORD:=0; // Status WinCC狀態(tài)字
QabyState AT QdwState : ARRAY [0..3] OF BYTE; // look at state byte-wise
QdwPerm : DWORD :=16#FFFFFFFF; // Permssion word wincc權(quán)限字
QabyPerm AT QdwPerm: ARRAY [0..3] OF BYTE;
PV_OUT : REAL := 0.0; // Process Value out
QHHA : BOOL := FALSE; // H Alarm is Active //高高報(bào)警到達(dá)
QHW : BOOL := FALSE; // H Warning is Active//高警告到達(dá)
QLW : BOOL := FALSE; // L Warning is Active//低警告到達(dá)
QLLA : BOOL := FALSE; // L Alarm is Active//低低警告到達(dá)
QHys : REAL := 0.0; //滯后值
END_VAR
VAR
//操作命令高低字節(jié)交換需要,以及AT指令拆分DWORD為32個(gè)BOOL變量
OPdwCmdHMI : DWORD := 16#0; // Operator Commands in HMI format
OPabyCmdHMI AT OPdwCmdHMI : ARRAY [0..3] OF BYTE; // look at HMI command byte-wise
OPdwCmdPLC : DWORD := 16#0; // Operator Commands in PLC format
OPabyCmdPLC AT OPdwCmdPLC : ARRAY [0..3] OF BYTE; // look at plc command byte-wise
OPabCmdPLC AT OPdwCmdPLC : ARRAY [0..31] OF BOOL;
//狀態(tài)字AT指令拆分DWORD為32個(gè)BOOL變量
QdwStatePLC : DWORD := 16#0; // State word in PLC format
QabyStatePLC AT QdwStatePLC : ARRAY [0..3] OF BYTE; // look at state byte-wise
QabStatePLC AT QdwStatePLC : ARRAY [0..31] OF BOOL; // look at state bit-wise
//權(quán)限字AT指令拆分DWORD為32個(gè)BOOL變量
QdwPermPLC : DWORD := 16#FFFFFFFF;
QabyPermPLC AT QdwPermPLC : ARRAY [0..3] OF BYTE; // look at state byte-wise
QabPermPLC AT QdwPermPLC : ARRAY [0..31] OF BOOL; // look at state bit-wise
//警告及報(bào)警延時(shí)到達(dá)或離開計(jì)時(shí)器
ADCT1 : REAL:= 0.0; // Alarm delay coming time
WDCT1 : REAL:= 0.0; // Warning delay coming time
ADGT1 : REAL:= 0.0; // Alarm delay going time
WDGT1 : REAL:= 0.0; // Warning delay going time
FP_Pulse:BOOL; //脈沖上升沿
FP_1,FP_2,FP_3,FP_4:BOOL;
HHLLA_C,HHLLA_G,HLW_G,HLW_C:BOOL;
// First scan
FstScan : BOOL := TRUE; //掃描
RunUpCyc: INT := 5; //運(yùn)行周期預(yù)設(shè)值
//Message
MsgEffOld:BYTE:=B#16#0; //消息字節(jié)狀態(tài)存儲
MsgEff:BYTE:=B#16#0; //當(dāng)前消息字節(jié)
MsgEff1 AT MsgEff :ARRAY[0..7]OF BOOL;
END_VAR
VAR_TEMP
iRet1,iRet2,iRet3,iRet4:INT;
END_VAR
聯(lián)系我們
上海翰粵自動(dòng)化系統(tǒng)有限公司 公司地址:上海市松江區(qū)思賢路2399弄137號 技術(shù)支持:化工儀器網(wǎng)掃一掃 更多精彩
微信二維碼
網(wǎng)站二維碼