Autor Thema: Meine Änderung vom Baustein Dimm_I  (Gelesen 11619 mal)

0 Mitglieder und 1 Gast betrachten dieses Thema.

Offline almot89

  • Newbie
  • *
  • Beiträge: 13
    • Profil anzeigen
Meine Änderung vom Baustein Dimm_I
« am: 11. Januar 2018, 03:42:13 »
Hier mal mein geänderter Baustein Dimm_I

Der Baustein dimmt im Gegensatz zum original, bei gerücktem Taster bis 255 hoch und bis zum eingestellten min wird wieder runter.

die Tastererkennung (positiv/negativ schaltend) und entprellung wurde entfernt.

(* the input is first sent through auto reconfiguration and debouncing *)
//config(IN := IN, TD := T_DEBOUNCE, TR := T_RECONFIG);
decode(in := IN, T_LONG := T_DIMM_START);

IF RST THEN
IF rst_out THEN out := 0; END_IF;
Q := FALSE;
dir := out > 127;
ELSIF set THEN
out := val;
Q := TRUE;
(* set direction to up when value < 127 otherwise set dir down dir is reversed because next action will reverse again *)
dir := out > 127;
ELSIF decode.SINGLE THEN
(* a single click reverses output Q *)
Q := NOT Q;
(* when dimmer is turned on we need to limit out to min and max limits *)
IF Q THEN out := LIMIT(MAX(MIN_ON,1), out, MAX_ON); END_IF;
(* set the appropriate direction of dimmer dir is reversed because next action will reverse again *)
dir := out > 127;
ELSIF decode.TP_LONG THEN
IF NOT Q THEN
IF SOFT_DIMM THEN
OUT := 1;
dir := TRUE;
ELSE
OUT := LIMIT(MAX(MIN_ON,1), out, MAX_ON);
DIR := out < 127;
END_IF;
Q := TRUE;
ELSE
(* reverse direction with every long click *)
dir := NOT dir;
END_IF;
END_IF;

(* set the double click output *)
IF NOT dbl_toggle THEN dbl := FALSE; END_IF;
IF decode.DOUBLE THEN dbl := NOT dbl; END_IF;

(* while dimming is active ramp the output out up or down *)
dim(DIR := dir, e := decode.LONG AND Q, TR := T_DIMM, rmp := out);

(* reverse direction when limits are reached *)
//IF out < 30 THEN
//dir := TRUE;
//ELSIF out = 255 THEN
//dir := FALSE;
//END_IF;

(* Sperre für minimum*)
IF  Q AND out < MIN_ON THEN
out := MIN_ON;
END_IF
(* limit the maximum runtime *)
IF t_ON_MAX > t#0s THEN
t3(in := q, pt := T_ON_MAX);
Q := Q XOR t3.Q;
END_IF;


vieleicht hat ja jemand ähnliche vorstellungen.

getestet mit codesys v3.5 (Raspberry pi, wago 750-342, wago 0-10V Ausgangskarte und Finder slave Dimmer 15.11 0-10V)