PROGRAM PLC_PRG
VAR
ix_auto AT %IX0.0:BOOL;(*系统手动/自动*)
ix_safe AT %IX0.1:BOOL;(*循环泵过热故障*)
ix_startpump AT%IX0.2:BOOL;(*循环泵手动启动*)
ix_stoppump AT%IX0.3:BOOL;
ix_statepump AT %IX0.4:BOOL;(*循环泵状态启动*)
qx_pump AT %QX0.0:BOOL:=FALSE;(*循环泵输出*)
qx_alarm AT%QX0.1:BOOL:=FALSE;(*故障灯*)
iw_p AT%IW2:WORD;(*水箱压力*)
iw_ttank AT%IW6:WORD;(*水箱温度*)
iw_tcollectfeed1 AT%IW8:WORD;(*集水器温度1*)
iw_tcollectfeed2 AT%IW10:WORD;(*集水器温度2*)
iw_tcollectback AT%IW12:WORD;(*集水器回水*)
p:REAL;
t_tank:REAL;
t_collectfeed1:REAL;
t_collectfeed2:REAL;
t_collectback:REAL;
dt_set:REAL;
band_set:REAL;
b_firstpoweron:BOOL:=TRUE;
mcgs_tcollectfeed1 AT %MD1008:REAL;
mcgs_tcollectfeed2 AT%MD1022:REAL;
mcgs_tcollectback AT %MD1026:REAL;
mcgs_ttank AT%MD1030:REAL;
mcgs_p AT%MD1034:REAL;
mcgs_setdt AT%MD2000:REAL;
mcgs_setband AT%MD2004:REAL;
(**)
ton_analog:TON;
ton_readmcgs:TON;
ton_pump:TON;
ton_writeretain:TON;
analogin0:Analog_IN;
analogin1:Analog_IN;
p_eh:H_E;
END_VAR
VAR RETAIN
retain_setdt:REAL;
retain_setband:REAL;
END_VAR
(*上电*)
IF(b_firstpoweron=TRUE)THEN
qx_pump:=FALSE;
dt_set:=retain_setdt;
mcgs_setdt:=retain_setdt;
band_set:=retain_setband;
mcgs_setband:=retain_setband;
b_firstpoweron:=FALSE;
END_IF
(*读模拟量并显示到MCGS*)
ton_analog(IN:=TRUE , PT:=t#1s);
IF(ton_analog.Q =TRUE) THEN
analogin0(en:=TRUE,address:=0);
analogin1(en:=TRUE,address:=1);
t_tank:=WORD_TO_REAL(iw_ttank/10);
mcgs_ttank:=t_tank;
t_collectfeed1:=WORD_TO_REAL(iw_tcollectfeed1/10);
mcgs_tcollectfeed1:=t_collectfeed1;
t_collectfeed2:=WORD_TO_REAL(iw_tcollectfeed2/10);
mcgs_tcollectfeed2:=t_collectfeed2;
t_collectback:=WORD_TO_REAL(iw_tcollectback /10);
mcgs_tcollectback:=t_collectback;
p_eh(WH:=iw_p ,MU:=1.6 ,MD:= 0, Mode:=0 );
p:=p_eh.AV ;
mcgs_p:=p;
ton_analog(in:=FALSE);
END_IF
(*从MCGS读指令*)
ton_readmcgs(IN:=TRUE , PT:=t#1s);
IF(ton_readmcgs.Q =TRUE) THEN
dt_set:=mcgs_setdt;
band_set:=mcgs_setband;
ton_readmcgs(in:=FALSE);
END_IF
(*写到永久变量*)
ton_writeretain(IN:=TRUE , PT:=t#1s);
IF(ton_writeretain.Q =TRUE) THEN
retain_setdt:=dt_set;
retain_setband:=band_set;
ton_writeretain(in:=FALSE);
END_IF
(*泵起停*)
ton_pump(IN:=TRUE , PT:=t#5s);
IF(ton_pump.Q =TRUE) THEN
(*现场手动*)
IF( ix_auto=FALSE) THEN
IF( ix_safe=FALSE AND ix_startpump=TRUE) THEN
qx_pump:=TRUE;
ELSE
qx_pump:=FALSE;
END_IF
END_IF
(*自动*)
IF(ix_auto=TRUE) THEN
IF(((t_collectfeed1 END_IF IF(((t_collectfeed1>dt_set+band_set) (t_collectfeed2>dt_set+band_set))AND ix_safe=FALSE)THEN qx_pump:=TRUE; END_IF END_IF OR ton_pump(in:=FALSE); END_IF (*故障灯*) IF(ix_safe=TRUE)THEN qx_alarm:=TRUE; ELSE qx_alarm:=FALSE; END_IF 因篇幅问题不能全部显示,请点此查看更多更全内容