You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

353 lines
9.3 KiB

FUNCTION_BLOCK IJ_AHU
VAR_EXTERNAL
END_VAR
VAR_INPUT
AHU_STRUCT_IN :AHU_IN;
END_VAR
VAR_OUTPUT
AHU_STRUCT_OUT :AHU_OUT;
END_VAR
VAR
AHU_SPID :BS_PID;
AHU_WPID :BS_PID;
AHU_RunTime :BS_Runtime;
AHU_WVCTEMP :REAL;
RunTon1 :TON;
RunTon2 :TON;
RunTon3 :TON;
RunTon5 :TON;
RunTof1 :TOF;
RunTof2 :TOF;
RunTof3 :TOF;
DevCheck1_time :TIME :=t#15s; (**)
DevCheck2_time :TIME :=t#15s; (**)
AFSDelay_time :TIME :=t#60s;
Status0 :INT;
Status1 :INT;
Status2 :INT;
Status3 :INT;
AHU_SPID_VP :REAL;
AHU_SPID_VI :REAL;
AHU_WPID_VP :REAL;
AHU_WPID_VI :REAL;
PID_in :BOOL;
PID_timer :TON;
AFSM :BOOL;
FDSM :BOOL;
FDOM :BOOL;
FDOTon :TON;
FDSTon :TON;
(*AHU_FEC :BS_FEC;*)
AHU_CM :BOOL;
AHU_VFCSM :INT;
ini :BOOL;
VFMVM :INT;
AFSON :BOOL;
AFSOF :BOOL;
AFSTON :TON;
AFSTOF :TOF;
END_VAR
(*
20200724
1.0
AHU_IN:STRUCT
SM :INT ; 季节模式 0夏季 1冬季 2过渡
LM :BOOL; 逻辑联动模式预留 0无联动 1联动
FM :BOOL; 风阀联动模式 0无联动 1联动
Run :BOOL; 运行状态
AHUlt :BOOL; 故障状态
Auto :BOOL; 自动状态
Control :BOOL; 程序控制
FDB :BOOL; 新风阀开度反馈
RDB :BOOL; 回风阀开度反馈
TSET :REAL; 温度设定
WVMC :BOOL; 水阀手动控制
WVMV :REAL; 水阀手动控制值
VFMV :INT; 变频手动控制值
RTS :REAL; 回风温度
RST :BOOL; 运行时间累计重置
RSTV :REAL; 运行时间累计重置值
IPS :BOOL; 滤网压差
AFS :BOOL; 低温断路开关
ISO1 :BOOL; 运行故障反馈隔离
ISO3 :BOOL; 低温断路报警隔离
VP :REAL; PI设定值P
VI :REAL; PI设定值I
FDELAY :TIME; 风机启动延时
CO2SET :REAL; 二氧化碳浓度设定
CO2S :REAL; 二氧化碳浓度
FDMV :INT; 新风阀手动控制值
RDMV :INT; 回风阀手动控制值
END_STRUCT;
输出变量
AHU_OUT:STRUCT
WVCS :INT ; 水阀控制转换值100
VFCS :INT; 变频控制
FDCS :INT; 新风阀控制
RDCS :INT; 回风阀控制
Control :BOOL; 启停控制
RH :REAL; 运行小时
SN :INT ; 设备状态代码
END_STRUCT;
包含以下几点功能
1.,
2.PID/
3.
4.
5.
6.
7.
8.
BS_PID;
BS_Runtime;
*)(*
if ini=0 then
AHU_STRUCT_IN.VFMV:=40;
ini:=1;
end_if;*)
(**************************************************************************************************************)
if AHU_STRUCT_IN.FM=0 then
if (AHU_STRUCT_IN.Control=1 and AHU_STRUCT_IN.Auto=1) or (AHU_STRUCT_IN.Run=1 and AHU_STRUCT_IN.Auto=0) then
AHU_STRUCT_OUT.FDCS:=100;
AHU_STRUCT_OUT.RDCS:=100;
else
AHU_STRUCT_OUT.FDCS:=0;
AHU_STRUCT_OUT.RDCS:=0;
end_if;
else AHU_STRUCT_OUT.FDCS:=AHU_STRUCT_IN.FDMV;
AHU_STRUCT_OUT.RDCS:=AHU_STRUCT_IN.RDMV;
end_if;
(******************************************************CO2联动程序*******************************************************
if AHU_STRUCT_IN.LM=1 then
AHU_FEC(RUN :=AHU_STRUCT_IN.CM , SET :=AHU_STRUCT_IN.CO2SET , FB :=AHU_STRUCT_IN.CO2S , DEAD_BAND :=10.0 , DELAY :=t#20s | AHU_CM:= DevC);
end_if;
*)
(**************************************************************************************************************)
if AFSM=0 then(**)
(*************************************************************************************)
RunTon3 ( IN:=AHU_STRUCT_IN.Control , PT:=AHU_STRUCT_IN.FDELAY | AHU_STRUCT_OUT.Control:=q );
(**)
if AHU_STRUCT_IN.VFMV<=50 and AHU_STRUCT_IN.VFMV>=40 then
AHU_STRUCT_OUT.VFCS:=AHU_STRUCT_IN.VFMV;
end_if;
if AHU_STRUCT_IN.VFMV>50 then
AHU_STRUCT_OUT.VFCS:=50;
end_if;
if AHU_STRUCT_IN.VFMV<40 then
AHU_STRUCT_OUT.VFCS:=40;
end_if;
(************************************************************************************************************)
PID_in:= not PID_timer.q;
PID_timer(in:=PID_in, pt:=t#1s );(*PID积分时间*)
if AHU_STRUCT_IN.WVMC=0 then
if AHU_STRUCT_IN.Run=1 then
if AHU_STRUCT_IN.VP<>0.0 and AHU_STRUCT_IN.VI<>0.0 then
AHU_SPID_VP:=-AHU_STRUCT_IN.VP;
AHU_SPID_VI:=-AHU_STRUCT_IN.VI;
AHU_WPID_VP:=AHU_STRUCT_IN.VP;
AHU_WPID_VI:=AHU_STRUCT_IN.VI;
else
AHU_SPID_VP:=-30.0;
AHU_SPID_VI:=-150.0;
AHU_WPID_VP:=30.0;
AHU_WPID_VI:=150.0;
end_if;
(**)
if AHU_STRUCT_IN.SM=0 then
if AHU_STRUCT_IN.RTS-AHU_STRUCT_IN.TSET>=3.0 then
AHU_WVCTEMP:=100.0;
end_if;
if PID_timer.q then
AHU_SPID(RUN:= AHU_STRUCT_IN.RUN,STOP_D:=1,STOP_I:=0,SET:=AHU_STRUCT_IN.TSET,FB:=AHU_STRUCT_IN.RTS,KFB:=1.0,KP:=AHU_SPID_VP,TI:=AHU_SPID_VI,TD:=-1.0,DEAD_BAND:=0.2,YMAX:=100.0,YMIN:=0.0 | AHU_WVCTEMP:=OUT);
end_if;
end_if;
(**)
if AHU_STRUCT_IN.SM=1 then
if AHU_STRUCT_IN.TSET-AHU_STRUCT_IN.RTS>=3.0 then
AHU_WVCTEMP:=100.0;
end_if;
if PID_timer.q then
AHU_WPID(RUN:= AHU_STRUCT_IN.RUN,STOP_D:=1,STOP_I:=0,SET:=AHU_STRUCT_IN.TSET,FB:=AHU_STRUCT_IN.RTS,KFB:=1.0,KP:=AHU_WPID_VP,TI:=AHU_WPID_VI,TD:=1.0,DEAD_BAND:=0.2,YMAX:=100.0,YMIN:=0.0 | AHU_WVCTEMP:=OUT);
end_if;
end_if;
(**)
if AHU_STRUCT_IN.SM=2 then
AHU_WVCTEMP:=0.0;
end_if;
else
AHU_WVCTEMP:=0.0;
end_if;
else
AHU_WVCTEMP:=AHU_STRUCT_IN.WVMV;
end_if;
end_if;(**)
(**)
AHU_STRUCT_OUT.WVCS:=REAL_TO_INT(AHU_WVCTEMP*100.0);
(**)
(*,
RunTon5 ( IN:=RunTon5M , PT:=DevDelay5_time );
RunTon5M:= not RunTon5.q;
if RunTon3.Q =1 then
if RunTon5.Q then
AHU_VFCSM:=AHU_VFCSM+1;
end_if;
if AHU_VFCSM>AHU_STRUCT_IN.VFMV then
AHU_VFCSM:=AHU_STRUCT_IN.VFMV;
end_if;
end_if;
if AHU_CM =0 then
if RunTon5.Q then
AHU_VFCSM:=AHU_VFCSM-1;
end_if;
if AHU_VFCSM<1 then
AHU_VFCSM:=0;
AHU_STRUCT_OUT.Control :=0;
FDOM:=0;
FDSM:=1;
end_if;
end_if;
if RunTon3.q=1 then
if AHU_VFCSM=AHU_STRUCT_IN.VFMV then
AHU_STRUCT_OUT.Control:=1;
end_if;
if AHU_VFCSM=0 then
AHU_STRUCT_OUT.Control:=0;
end_if;
end_if;
AHU_STRUCT_OUT.VFCS :=AHU_VFCSM;
*)
(************************************************************************************************************)
if AHU_STRUCT_IN.ISO3=0 and AHU_STRUCT_IN.SM=1 then
AFSTON ( IN:=AHU_STRUCT_IN.AFS , PT:=AFSDelay_time | AFSON:=q );
AFSTOF ( IN:=AHU_STRUCT_IN.AFS , PT:=AFSDelay_time | AFSOF:=q );
if AFSON=1 and AFSOF=1 then
AFSM:=1 ;
end_if;
if AFSOF=0 and AFSON=0 then
AFSM:=0 ;
end_if;
if AFSM=1 then
AHU_STRUCT_OUT.Control:=0;
AHU_WVCTEMP:=100.0;
AHU_STRUCT_OUT.FDCS:=0;
AHU_STRUCT_OUT.RDCS:=0;
Status3:=1;
else
Status3:=0;
end_if;
end_if;
(**)
if AHU_STRUCT_IN.ISO3=1 or AHU_STRUCT_IN.SM<>1 then
AFSM:=0;
end_if;
(************************************************************************************************************)
RunTon1( IN:=AHU_STRUCT_IN.Control , PT:=DevCheck1_time);
RunTof1( IN:=AHU_STRUCT_IN.Control , PT:=DevCheck1_time);
RunTon2( IN:=AHU_STRUCT_IN.Control , PT:=DevCheck2_time);
RunTof2( IN:=AHU_STRUCT_IN.Control , PT:=DevCheck2_time);
(*Status0*);
if AHU_STRUCT_IN.ISO1=0 then
if RunTon1.q or not RunTof1.q then
if AHU_STRUCT_OUT.Control<>AHU_STRUCT_IN.Run then
Status0:=1;
else
Status0:=0;
end_if;
if AHU_STRUCT_IN.fault=1 then
Status1:=1;
else
Status1:=0;
end_if;
end_if;
else
Status0:=0;
Status1:=0;
end_if;
(*;
if AHU_STRUCT_IN.ISO2=0 then
if RunTon2.q or not RunTof2.q then
if AHU_STRUCT_OUT.Control<>AHU_STRUCT_IN.FPS then
Status2:=1;
else
Status2:=0;
end_if;
end_if;
else
Status2:=0;
end_if;
*)
(**)
if AHU_STRUCT_OUT.Control<>0 then
AHU_STRUCT_OUT.SN := Status0 * 1 + Status1* 2 + Status2* 4 + Status3*8;
else
AHU_STRUCT_OUT.SN := 0 ;
end_if;
(************************************************************************************************************)
AHU_RunTime(RUN :=AHU_STRUCT_IN.Run , RUNTIMESET :=AHU_STRUCT_IN.RSTV , RUNTIMERST :=AHU_STRUCT_IN.RST | AHU_STRUCT_OUT.RH:= RUNTIME);
END_FUNCTION_BLOCK