schau dir mal unsewr rechts´- bzw up-dn modul mit vielen raffinessen an:
zu finden in der lib oscat1.3 auf
www.oscat.de
FUNCTION_BLOCK actuator_UD
VAR_INPUT
UD : BOOL;
ON : BOOL;
TON : TIME;
TOF : TIME;
Manual : BOOL := 0;
Up : BOOL;
Dn : BOOL;
off : BOOL := 0;
YUP_in : BOOL;
YDN_in : BOOL;
END_VAR
VAR_OUTPUT
Yup : BOOL;
Ydn : BOOL;
END_VAR
VAR
tx : TIME;
last : TIME;
init: BOOL;
END_VAR
(*
version 1.0 12 Nov 2006
programmer hugo
tested by tobias
out_ud is a up/dn or Right/left locked output driver.
if can be controlled by automatic inputs UD and ON as well as manual inputs for up and dn.
a security input to shut off at any time is prvided by the off input.
to time set inputs ton and toff specify a minimum on time for outputs and a minimum off time befoore the next output can become active.
the module assures that only one output can be active at any time.
for higher security pls make sure you use hardware locking of the outputs to prevent from defective wiring or outputs.
further security is provided b feedback inputs Yup_in and Ydn_in which are separate inputs for the output signal, if these inputs are not available
pls connect them directly to Yup and Ydn.
automatic mode can override manual mode by setting the on input high while the manual input is high.
*)
tx := TIME();
IF NOT init THEN
(* INITIALIZATION AT FIRST CALL *)
last := tx;
init := TRUE;
ELSIF off THEN
(* emergency shut off detected *)
Yup := FALSE;
Ydn := FALSE;
last := tx;
ELSIF ((Yup OR Ydn) AND tx - last < Ton) OR ((NOT Yup AND NOT Ydn) AND tx - last < tof) THEN
(* WATH FOR MIN TON AND TOF TIME *)
RETURN;
ELSIF manual AND NOT on THEN
(* manual operation detected *)
IF UP AND NOT DN AND NOT OFF THEN
Ydn := 0;
IF NOT Ydn_in THEN Yup := 1; END_IF;
last := tx;
ELSIF DN AND NOT UP AND NOT OFF THEN
Yup := 0;
IF NOT Yup_in THEN Ydn := 1; END_IF;
last := tx;
ELSE
IF YUP OR YDN THEN LAST := tx; END_IF;
Yup := 0;
Ydn := 0;
END_IF;
ELSE
(* automatic operation *)
IF Ud AND on AND NOT OFF THEN
Ydn := 0;
IF NOT ydn_in THEN Yup := 1; END_IF;
last := tx;
ELSIF NOT UD AND on AND NOT OFF THEN
Yup := 0;
IF NOT yup_in THEN Ydn := 1; END_IF;
last := tx;
ELSE
IF Yup OR Ydn THEN last := tx; END_IF;
Yup := 0;
Ydn := 0;
END_IF;
END_IF;
(* make sure Yup and Ydn are never on at the same time *)
IF Ydn AND Yup_in THEN Ydn := 0; END_IF;
IF Yup AND Ydn_in THEN Yup := 0; END_IF;