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.
 
 
 
 
 
 

63 lines
1.2 KiB

FUNCTION_BLOCK BS_RunTime
VAR_EXTERNAL
END_VAR
VAR_INPUT
Run :BOOL;
RunTimeSet :REAL;
RunTimeRST :BOOL;
RunTimeRec_In :REAL;
END_VAR
VAR_OUTPUT
RunTime :REAL;
END_VAR
VAR
Time_m :TON;
Time_RST :TON;
Cycle :BOOL;
Minute :REAL;
ini :BOOL;
Runtime_ini :REAL;
END_VAR
(*
时 间:20190907
版 本:1.0
作 者:姚立
名 称:运行时间累计程序
说 明:运行时间累计程序,单位分钟,可通过重置按钮修改计数基础值
时 间:20220210
版 本:1.1
作 者:潘平
名 称:运行时间累计程序
说 明:增加断电数据写入值变量,以使断电数据进行
备 注:
依赖块:
*)
(*初始化将断电前数据写入累计值*)
if ini=0 then
Runtime_ini:=RunTimeRec_In;
ini:=1;
end_if;
(*计时周期为分钟*)
if RunTimeRST=0 then
time_m(in:=Cycle,pt:=t#60s);
Cycle:= not Time_m.q;
if Run then
if Time_m.q then
Minute:=Minute+1.0;
end_if;
end_if;
Runtime:=Minute/60.0+Runtime_ini;
end_if;
(*重置按钮按下时,期间Minute的读值按RunTimeSet赋值*)
if RunTimeRST=1 then
Minute:=RunTimeSet*60.0;
end_if;
END_FUNCTION_BLOCK