В codesys 2.3 нет SYS.CTN; SYS.TON и SYS.RTRIG SYS.FTRIG; , надо заменить на TON и R_TRIG, F_TRIG, а счётчик нужно сделать свой 32 битный.(код ниже)
GET_TIME() заменить на TIME()
Сброс при 0 можно добавить.
Скрытый текст:
Код:
function_block CTN (*// CTN *)
var_input
U : bool;
D : bool;
Res : bool;
N : udint;
end_var
var_output
Q : udint;
end_var
var
RT: bool; (*//переменная для определения переднего фронта на входе «U» *)
x:bool:=true;
end_var
____________________________________________________
if Res or x then
Q := N; x:=false;end_if
if U and not RT and not Res then
Q := (Q + 1); RT := U; end_if
if D and not RT and not Res then
Q := (Q - 1); RT := D; end_if
if not U and not D and RT then
RT := false; end_if