UPGRADE IP 9 verfügbar!
Timberwolf VISU jetzt mit NEUEM Layout Editor
Freie Anordnung, Reihenfolge und Größe der Widgets - viele weitere Verbesserungen
Infos im Wiki: https://elabnet.atlassian.net/l/cp/06SeuHRJ

NEU! Insider & Leistungsmerkmale FÜR ALLE freigeschaltet
Damit kann nun jeder das Upgrade vornehmen und VISU & IFTTT testen. Alle Info hier: viewtopic.php?f=8&t=5074

[TOP TIPP] Automatische Bewässerungssteuerung

Hier stellen Foristen und Kunden Ihre EIGENEN Logikbausteine vor. Diese Logikbausteine stehen jedem im Rahmen der vom Autor eingeräumten / genannten Lizenz zur Verfügung.
Forumsregeln
  • Denke bitte an aussagekräftige Titel und gebe dort auch die [Firmware] an. Wenn ETS oder CometVisu beteiligt sind, dann auch deren Version
  • Bitte mache vollständige Angaben zu Deinem Server, dessen ID und dem Online-Status in Deiner Signatur. Hilfreich ist oft auch die Beschreibung der angeschlossener Hardware sowie die verwendeten Protokolle
  • Beschreibe Dein Projekt und Dein Problem bitte vollständig. Achte bitte darauf, dass auf Screenshots die Statusleiste sichtbar ist
  • Bitte sei stets freundlich und wohlwollend, bleibe beim Thema und unterschreibe mit deinem Vornamen. Bitte lese alle Regeln, die Du hier findest: https://wiki.timberwolf.io/Forenregeln

Ersteller
MiniMaxV2
Reactions:
Beiträge: 274
Registriert: Sa Jan 12, 2019 8:41 pm
Wohnort: Bremen
Hat sich bedankt: 342 Mal
Danksagung erhalten: 151 Mal

#21

Beitrag von MiniMaxV2 »

Hi Robert,
Das klingt nach einer guten Idee. Mit dem Status ist ja eh nicht gewollt, da die Logiken eigene Statusausgänge haben. Das wird dann wohl bald eingebaut werden.
LG
Hans Martin
timberwolf413 (950Q) - VPN offen - reboot erlaubt / timberwolf610 (950Q) - VPN offen - reboot erlaubt

Robert_Mini
Reactions:
Beiträge: 3741
Registriert: So Aug 12, 2018 8:44 am
Hat sich bedankt: 1164 Mal
Danksagung erhalten: 2058 Mal

#22

Beitrag von Robert_Mini »

Ein paar Dinge sind mir beim Vergleich mit meiner WG Logik aufgefallen - quasi als Anregung ;):

- Anzeige Dauer hisher und Restlaufzeit je Kreis in Minuten (im Baustein Bew.-Kreis) getriggert durch die Rückmeldeobjekte
- Globaler Zeit-Faktor als Eingang (im Baustein Bew.-Kreis)
- Gesamtdauer (abgelaufen seit Starttrigger) im Sequenzer
- Zyklisches Senden getrennt für aktiv/inaktiv je Baustein (wichtig zum Erhalten der Sicherheitsachaltung per Treppenlichtzeit am Aktor)
- Aktor-Sperrobjekt einbinden (Kreis und Sequenz), damit die Logik erst gar kein Start/Ein schickt, wenn die Sequenz oder der Kreis gesperrt ist

Kann ich gerne später beisteuern oder dich dabei mit meiner Erfahrung unterstützen :lol: .

Hast du zum Thema Automatik zum Triggern der Sequenz auch schon was im Kopf?
Hab bei mir was einfaches ohne Messung am Start, könnte aber eine Kombi aus Messung der Feuchte + Außentemperatur (+Wind?) sein.

In jedem Fall muss ich mich bald mal mit der state machine vertraut machen! :doh:

Lg
Robert
Timberwolf Server 2500 / #117 (VPN offen + reboot nach Rückfrage) / zusätzlich: 3500M/#935, 3500L/#1297

Ersteller
MiniMaxV2
Reactions:
Beiträge: 274
Registriert: Sa Jan 12, 2019 8:41 pm
Wohnort: Bremen
Hat sich bedankt: 342 Mal
Danksagung erhalten: 151 Mal

#23

Beitrag von MiniMaxV2 »

Hi Robert,
zu deinen Ideen/Anregungen:
- Die ganzen Dauern werden in der Logik über eine Statemachine gesteuert. Das heißt, dass die Logik sich aktviert und dann einen Timer startet, bis die Logik wieder getriggered wird. Bedeutet, dass die Zeit-Abfragen in der TimberwolfLogic ermöglicht werden müssten.
- Zeit Faktor hab ich jetzt keinen Anwendungsfall bisher gehabt
- Die Sicherheitsfunktionen (zyklisches Senden) ist halb eingeplant. Im Prinzip kannst du das CircuitControl beliebig oft triggern, ohne dass eine State-Transition eintritt, aber die Ausgänge aktualisiert werden. Man müsste nur den Valve Ausgang auf "A" statt "C" setzen.
- Die Sperre, kann ja an den Aktor weitergegeben werden (direkt verbunden oder einfach als Ausgang in der Logik). Nur hab ich hier auch noch nicht die Notwendigkeit gesehen, da nur durch die Logiken eig. die entsprechenden Impulse an den Aktor gehen.
- Automatisches Triggern ist geplant, nachdem erstmal die Automatik läuft. Im Prinzip kann alles vorgeschaltet werden, was dann den Trigger einmal mit einer Flanke versieht. Alles nach und nach (oder ihr steuert diese Logiken bei ;) - zumal bei mir nur erstmal ein Timer dran kommt.
LG
Hans Martin
timberwolf413 (950Q) - VPN offen - reboot erlaubt / timberwolf610 (950Q) - VPN offen - reboot erlaubt
Benutzeravatar

tws88_user
Reactions:
Beiträge: 428
Registriert: So Aug 12, 2018 9:42 am
Wohnort: Raum Magdeburg
Hat sich bedankt: 242 Mal
Danksagung erhalten: 148 Mal

#24

Beitrag von tws88_user »

Also das nenne ich mal eine Bewässerung! 👍🏻

Bei mir hält das „Erschlagensein“ noch an 😬

Bin gespannt, wie ihr das in das Wolf-System portieren werdet, Hans-Martin
Viele Grüße, Kai
______________________
Timberwolf88 (2500er) - VPN offen. Reboot bitte nach Absprache.

StefanW
Elaborated Networks
Reactions:
Beiträge: 9689
Registriert: So Aug 12, 2018 9:27 am
Wohnort: Frauenneuharting
Hat sich bedankt: 4831 Mal
Danksagung erhalten: 7632 Mal
Kontaktdaten:

#25

Beitrag von StefanW »

Hallo Robert,
Robert_Mini hat geschrieben: Sa Apr 25, 2020 9:41 pmGesamtdauer (abgelaufen seit Starttrigger) im Sequenzer
Das müssten wir, wie Hans-Martin schon geschrieben hat, in der Logikengine vorsehen, wir werden das mal diskutieren.

Robert_Mini hat geschrieben: Sa Apr 25, 2020 9:41 pmIn jedem Fall muss ich mich bald mal mit der state machine vertraut machen!
Jep, das lohnt sich, damit wird vieles sehr viel einfacher! Die State-Maschine ist die ideale Umsetzung einer prozeduralen und komplexen "If...then..else" Logik mit vielen Zuständen und Verzweigungen. Erst Aufmalen und dann die Tabelle anlegen. Das ist ein sehr universeller Baustein.


lg

Stefan
Stefan Werner
Product Owner für Timberwolf Server, 1-Wire und BlitzART
Bitte WIKI lesen. Allg. Support nur im Forum. Bitte keine PN
Zu Preisen, Lizenzen, Garantie, HW-Defekt an service at elabnet dot de

Link zu Impressum und Datenschutzerklärung oben.

Robert_Mini
Reactions:
Beiträge: 3741
Registriert: So Aug 12, 2018 8:44 am
Hat sich bedankt: 1164 Mal
Danksagung erhalten: 2058 Mal

#26

Beitrag von Robert_Mini »

StefanW hat geschrieben: So Apr 26, 2020 8:21 am Das müssten wir, wie Hans-Martin schon geschrieben hat, in der Logikengine vorsehen, wir werden das mal diskutieren.
Mit dem "Hobbsmeter" oder Stoppuhr kann man das bereits ganz gut lösen. Man braucht eben diese Zeitzähler zusätzlich zum Monoflop, schön wäre natürlich eine Abgelaufene Zeit und Restzeit als Ausgabe am Monoflop.

lg
Robert
Timberwolf Server 2500 / #117 (VPN offen + reboot nach Rückfrage) / zusätzlich: 3500M/#935, 3500L/#1297

Ersteller
MiniMaxV2
Reactions:
Beiträge: 274
Registriert: Sa Jan 12, 2019 8:41 pm
Wohnort: Bremen
Hat sich bedankt: 342 Mal
Danksagung erhalten: 151 Mal

#27

Beitrag von MiniMaxV2 »

Hi Stefan,
StefanW hat geschrieben: So Apr 26, 2020 8:21 am Das müssten wir [...] in der Logikengine vorsehen, [...]
in meiner Logik müssten die Restzeiten aus dem Monoflop ausgelesen werden, um Roberts Idee umzusetzen:

Code: Alles auswählen

["Monoflop", "$TimerShouldRun", 0, "$TimerActive", "$AutoTime", 2]
Um dann noch die "Offset Zeiten" (Vorlauf, Nachlauf) mitzubekommen, müsste man ach die Statemachine auslesen können.
StefanW hat geschrieben: So Apr 26, 2020 8:21 am Jep, das lohnt sich, damit wird vieles sehr viel einfacher! Die State-Maschine ist die ideale Umsetzung einer prozeduralen und komplexen "If...then..else" Logik mit vielen Zuständen und Verzweigungen. Erst Aufmalen und dann die Tabelle anlegen. Das ist ein sehr universeller Baustein.
Wenn man dazu dann noch die Funktionsweise der Logik kapiert hat (Es wird immer alles berechnet und nur am Ende entschieden, was "ausgegeben" wird um If-Then abzubilden), ist das alles zusammen ein mächtiges Werkzeug.
LG
Hans Martin
timberwolf413 (950Q) - VPN offen - reboot erlaubt / timberwolf610 (950Q) - VPN offen - reboot erlaubt

Sun1453
Reactions:
Beiträge: 1849
Registriert: Do Feb 07, 2019 8:08 am
Hat sich bedankt: 1541 Mal
Danksagung erhalten: 788 Mal

#28

Beitrag von Sun1453 »

StefanW hat geschrieben: So Apr 26, 2020 8:21 am
Jep, das lohnt sich, damit wird vieles sehr viel einfacher! Die State-Maschine ist die ideale Umsetzung einer prozeduralen und komplexen "If...then..else" Logik mit vielen Zuständen und Verzweigungen. Erst Aufmalen und dann die Tabelle anlegen. Das ist ein sehr universeller Baustein.


lg

Stefan
Die muss ich wenn IP 2 da ist auch in Stellung bringen. Hab da so Binär Eingänge die darauf warten.
Gruß Michael

Timberwolf 950 QL #344 | Mit Internetanbindung | VPN Offen | Reboot nach Absprache | PROD Server
Timberwolf 2500 #602 | VPN offen | TEST Server | Reboot nach Absprache |

Robert_Mini
Reactions:
Beiträge: 3741
Registriert: So Aug 12, 2018 8:44 am
Hat sich bedankt: 1164 Mal
Danksagung erhalten: 2058 Mal

#29

Beitrag von Robert_Mini »

Das Monoflop braucht beides: Restzeit und abgelaufene Zeit (wegen re-trigger). Ich prüfe, ob es den FR dazu gibt.

Ich poste meine Lösung dazu später noch:
In kurz: Hobbsmeter für die Gesamtdauer der Sequenz und Stoppuhr für Laufzeit/Restzeit.

Lg
Robert
Timberwolf Server 2500 / #117 (VPN offen + reboot nach Rückfrage) / zusätzlich: 3500M/#935, 3500L/#1297

Ersteller
MiniMaxV2
Reactions:
Beiträge: 274
Registriert: Sa Jan 12, 2019 8:41 pm
Wohnort: Bremen
Hat sich bedankt: 342 Mal
Danksagung erhalten: 151 Mal

#30

Beitrag von MiniMaxV2 »

So es ging weiter. Ich glaube, dass der jetzige Zustand so weit ausgereift ist, dass als nächstes dieser an die reale Bewässerung angeschlossen werden kann. Dazu muss ich jetzt aber erstmal das Projektimport Thema auf die Reihe bekommen :angry-banghead:

Der Einfachheithalber, poste ich hier den Changelog aus meinem VCS:

Code: Alles auswählen

[Timberwolf_Logics] Fixed inhibit inputs. Changed circuit controls manual input to edge controlled inputs.

[Timberwolf_Logics CircuitControl] Added reset of edge controlled inputs. Added stop logic. Added manual-start logic. Changed announce finished behaviour to only trigger if automatic mode was active or triggered.
[Timberwolf_Logics Sequencer] Added reset of edge controlled inputs. Updated to 20 circuits. 
[Timberwolf_Logics SystemControl] Added state transition for new request within system follow up.
Und hier der Code, sowie im Anhang meine .TWL files (ich entwickle die Scripte in VSCode und hab mir da angefangen eine kleine Extension geschrieben. Bisher kann sie hauptsächlich nur Highlighting aber ich hab da noch mehr geplant...). Nicht wundern, ist als ZIP, da das Forum keine TWL Files erlaubt (noch nicht? :whistle: )

Code: Alles auswählen

/**
 * File: Irrigation_SystemControl.twl V1.0 ALPHA 4
 * Logic for Garden irrigation. This module is the SystemControl which controls the pump and other related systems (like power supplies).
 * Author: Hans Martin
 * 
 */

{
  "Input": [
        ["System Request", "(0/1) Indicates whether the system should be activated", "$VAR<SystemRequest?>", "c"],
        ["System Forerun", "(T_s) Time how long the system should run before the pump is activated", "$SystemForerun", "u"],
        ["Pump Forerun", "(T_s) Time how long the pump should run before system goes into the OK state", "$PumpForerun", "u"],
        ["System FollowUp", "(T_s) Time how long the system should run after the pump is shut down", "$SystemFollowUp", "u"],
        ["Pump FollowUp", "(T_s) Time how long the pump should run after the request gone", "$PumpFollowUp", "u"],
        ["Inhibit", "", "$VAR<Inhibit?>", "c"]
  ],
  "Output": [
        ["System State","(0/1) Indicates whether the system has a request","$SystemState","c"],
        ["System OK", "(0/1) Indicates that the system is in fully operational state", "$SystemOk", "c"],
        ["System Warning", "(0/1) Indicates that the system is partially operating", "$SystemWarn", "c"],
        ["System Error", "(0/1) Indicates that the system is in faulted state", "$SystemError", "c"],
        ["System", "(0/1) Output to activate the system devices (e.g. power supply)", "$SystemOut", "c"],
        ["Pump", "(0/1) Output to activate the pump", "$PumpOut", "c"]
  ],
  "Level": [
        // Inputs
        ["$VAR<Inhibit?>","bool",false],
        ["$VAR<SystemRequest?>", "bool", false],
        ["$SystemForerun", "float", 0],
        ["$PumpForerun", "float", 0],
        ["$SystemFollowUp", "float", 0],
        ["$PumpFollowUp", "float", 0],

        // Outputs
        ["$SystemState", "bool", false],
        ["$SystemOk", "bool", false],
        ["$SystemWarn", "bool", false],
        ["$SystemError", "bool", false],
        ["$SystemOut", "bool", false],
        ["$PumpOut", "bool", false],
        
        // Consts
        ["$Konst1", "int", 1],
        ["$Konst5", "int", 5],

        //Internals
        ["$State","integer",0],
        ["$InternalSystemWarn", "bool", false],
        ["$SystemRequestInternal", "bool", false]
  ],
  "Module": [
        ["Break", ["$VAR<Inhibit?>"]], // this is a problem! Fix it! (If system is running and inhibit is set, there is no way to reset the system!)
        ["Or", ["$VAR<SystemRequest?>"], "$SystemRequestInternal"],

        // build state
        ["Statemachine",
            // 0: System Off
            // 1: System Forerun
            // 2: Pump Forerun
            // 3: Running
            // 4: Pump FollowUp
            // 5: System FollowUp
            [
                // [condition , current state, next state, timeout]
                ["$SystemRequestInternal", 0, 1, "$SystemForerun"], // new request
                ["-$SystemRequestInternal", 1, 0, 0], // request canceled during system forerun
                [0, 1, 2, "$PumpForerun"], // system forerun done
                ["-$SystemRequestInternal", 2, 0, 0], // request canceled during pump forerun
                [0, 2, 3, 0], // pump forerun done, system fully operating
                ["$SystemRequestInternal", 3, 3, 0], // request still true
                ["-$SystemRequestInternal", 3, 4, "$PumpFollowUp"], // pump follow up
                ["$SystemRequestInternal", 4, 3, 0], // request within pump follow up
                [0, 4, 5, "$SystemFollowUp"], //system follow up
                ["$SystemRequestInternal", 5, 2, "$PumpForerun"], // request within system follow up
                [0, 5, 0, 0] // system off
            ],
            "$State"
        ],

        // map state to output
        ["Comparator", "$State", "$SystemOut", 0], // System Out (only 1 when state > 0)
        ["Multiplexer", [0, 0, "$Konst1", "$Konst1", "$Konst1", 0], "$PumpOut", "$State"], // Pump Out (1 when 5 > state > 1)

        // map state to state outputs
        ["Comparator", "$State", "$SystemState", 0], // SystemState (only 1 when state > 0)
        ["Multiplexer", [0, "$Konst1", "$Konst1", 0, "$Konst1", "$Konst1"], "$InternalSystemWarn", "$State"], // system has warning if not in state 3 and has request
        ["And", ["-$SystemError", "$InternalSystemWarn"], "$SystemWarn"], // system has only warning exposed if no error is active
        ["And", ["-$SystemError", "-$SystemWarn", "$SystemRequestInternal"], "$SystemOk" ] // system is ok if no error and no warning is active and request was made
  ]
}

Code: Alles auswählen

/**
 * File: Irrigation_Sequencer.twl V1.0 ALPHA 3
 * Logic for Garden irrigation. This module is the sequencer which controls an automatic run of all circuits 
 * Author: Hans Martin
 * 
 */

{
  "Input": [
        ["Start", "(RISING) Trigger to start an automatic irrigation cycle", "$TriggerInpStart", "c"],
        ["Stop", "(RISING) Trigger to stop an automatic irrigation cycle", "$TriggerInpStop", "c"],
        ["Next", "(RISING) Trigger to step to next circuit", "$TriggerInpNext", "a"],
        ["Number of circuits", "(0-20) Configure the number of active circuits", "$NumberOfSteps", "u"],
        ["Inhibit", "", "$VAR<Inhibit?>", "c"]
  ],
  "Output": [
        ["Sequencer Active", "(0/1) State of sequencer", "$SequencerActive", "c"],
        ["Sequencer Number", "(R+) Current active output number", "$SequencerNumber", "c"],
        ["Stop", "(RISING) Signal to stop all irrigation circuits", "$SequencerStop", "c"],

        // repeat as many time as desired irrigation circuits
        ["Channel 1", "(0/1) Trigger for irrigation circuit", "$Circuit_1_?", "c"],
        ["Channel 2", "(0/1) Trigger for irrigation circuit", "$Circuit_2_?", "c"],
        ["Channel 3", "(0/1) Trigger for irrigation circuit", "$Circuit_3_?", "c"],
        ["Channel 4", "(0/1) Trigger for irrigation circuit", "$Circuit_4_?", "c"],
        ["Channel 5", "(0/1) Trigger for irrigation circuit", "$Circuit_5_?", "c"],
        ["Channel 6", "(0/1) Trigger for irrigation circuit", "$Circuit_6_?", "c"],
        ["Channel 7", "(0/1) Trigger for irrigation circuit", "$Circuit_7_?", "c"],
        ["Channel 8", "(0/1) Trigger for irrigation circuit", "$Circuit_8_?", "c"],
        ["Channel 9", "(0/1) Trigger for irrigation circuit", "$Circuit_9_?", "c"],
        ["Channel 10", "(0/1) Trigger for irrigation circuit", "$Circuit_10_?", "c"],
        ["Channel 11", "(0/1) Trigger for irrigation circuit", "$Circuit_11_?", "c"],
        ["Channel 12", "(0/1) Trigger for irrigation circuit", "$Circuit_12_?", "c"],
        ["Channel 13", "(0/1) Trigger for irrigation circuit", "$Circuit_13_?", "c"],
        ["Channel 14", "(0/1) Trigger for irrigation circuit", "$Circuit_14_?", "c"],
        ["Channel 15", "(0/1) Trigger for irrigation circuit", "$Circuit_15_?", "c"],
        ["Channel 16", "(0/1) Trigger for irrigation circuit", "$Circuit_16_?", "c"],
        ["Channel 17", "(0/1) Trigger for irrigation circuit", "$Circuit_17_?", "c"],
        ["Channel 18", "(0/1) Trigger for irrigation circuit", "$Circuit_18_?", "c"],
        ["Channel 19", "(0/1) Trigger for irrigation circuit", "$Circuit_19_?", "c"],
        ["Channel 20", "(0/1) Trigger for irrigation circuit", "$Circuit_20_?", "c"]
  ],
  "Level": [
        // Inputs
        ["$VAR<Inhibit?>","bool",false],
        ["$TriggerInpStart","bool",false],
        ["$TriggerInpStop","bool",false],
        ["$TriggerInpNext","bool",false],

        // Outputs
        ["$SequencerActive","bool",false], // also used as internal state
        ["$SequencerNumber","int",0],
        ["$SequencerStop","bool",false],

        // Channels
        // Configure number of circuits
        ["$NumberOfSteps","int",0],
        // channel outs - repeat as many irrigation circuits are configured above
        ["$Circuit_1_","bool",false],
        ["$Circuit_2_","bool",false],
        ["$Circuit_3_","bool",false],
        ["$Circuit_4_","bool",false],
        ["$Circuit_5_","bool",false],
        ["$Circuit_6_","bool",false],
        ["$Circuit_7_","bool",false],
        ["$Circuit_8_","bool",false],
        ["$Circuit_9_","bool",false],
        ["$Circuit_10_","bool",false],
        ["$Circuit_11_","bool",false],
        ["$Circuit_12_","bool",false],
        ["$Circuit_13_","bool",false],
        ["$Circuit_14_","bool",false],
        ["$Circuit_15_","bool",false],
        ["$Circuit_16_","bool",false],
        ["$Circuit_17_","bool",false],
        ["$Circuit_18_","bool",false],
        ["$Circuit_19_","bool",false],
        ["$Circuit_20_","bool",false],

        // Constants
        ["$Konst1", "int", 1],
        ["$KonstFalse", "bool", false],
        ["$KonstTrue", "bool", true],

        // Internals
        ["$CurrentStep","int",0],
        ["$NextStep","int",0],
        ["$StepOverflow", "bool", false],
        ["$ResetSystem", "bool", false],
        ["$Inhibit","bool",false],
        ["$TriggerInpStartRising","bool",false],
        ["$TriggerInpStopRising","bool",false],
        ["$TriggerInpNextRising","bool",false],
        ["$TriggerInpStartLast","bool",false],
        ["$TriggerInpStopLast","bool",false],
        ["$TriggerInpNextLast","bool",false]
  ],
  "Module": [
        ["Or", ["$VAR<Inhibit?>"], "$Inhibit"],
        
        // calculate rising edges
        ["And", ["$TriggerInpStart","-$TriggerInpStartLast", "-$SequencerActive"], "$TriggerInpStartRising"],
        ["And", ["$TriggerInpStop","-$TriggerInpStopLast", "$SequencerActive"], "$TriggerInpStopRising"],
        ["And", ["$TriggerInpNext","-$TriggerInpNextLast", "$SequencerActive"], "$TriggerInpNextRising"],

        // set last trigger variables
        ["And", ["$TriggerInpStart"], "$TriggerInpStartLast"],
        ["And", ["$TriggerInpStop"], "$TriggerInpStopLast"],
        ["And", ["$TriggerInpNext"], "$TriggerInpNextLast"],

        // calculate start of system
        ["Multiplexer", ["$SequencerActive", "$Konst1"], "$SequencerActive", "$TriggerInpStartRising"],

        // calculate next step
        ["Polynomial", "$Konst1", "$NextStep", ["$CurrentStep", "$Konst1"] ], // ++$CurrentStep
        ["Comparator", "$NextStep", "$StepOverflow", "$NumberOfSteps"],
        ["Multiplexer", ["$NextStep", 0], "$NextStep", "$StepOverflow"],

        // set next step when next was triggered or system was started
        ["Multiplexer", ["$CurrentStep","$NextStep"], "$CurrentStep", "$TriggerInpNextRising"],
        ["Multiplexer", ["$CurrentStep","$NextStep"], "$CurrentStep", "$TriggerInpStartRising"],
        
        // reset current step when stop was issued or inhibit was set
        ["Or", ["$TriggerInpStopRising", "$Inhibit"], "$ResetSystem"],
        ["And", ["$ResetSystem", "$SequencerActive"], "$ResetSystem"], // only reset when system runs
        ["Multiplexer", ["$CurrentStep",0], "$CurrentStep", "$ResetSystem"],

        // start timer to reset stop output later on
        ["Monoflop","$ResetSystem", 0, 0,"$Konst1",2],
        
        // write common outputs
        ["Polynomial", 0, "$SequencerNumber", ["$CurrentStep"]],
        ["Multiplexer", [0, "$Konst1"], "$SequencerStop", "$ResetSystem"],
        ["Multiplexer", [0, "$SequencerActive"], "$SequencerActive", "$CurrentStep"],

        // Reset Inputs
        ["Latch", "$KonstFalse", "$TriggerInpStart", "$KonstTrue", 0],
        ["Latch", "$KonstFalse", "$TriggerInpStop", "$KonstTrue", 0],
        ["Latch", "$KonstFalse", "$TriggerInpNext", "$KonstTrue", 0],

        // write circuit outputs
        // copy as many circuit exists. Put a zero in front of $Konst1 for each new step. 
        ["Multiplexer", [0, "$Konst1", 0], "$Circuit_1_", "$CurrentStep"],
        ["Multiplexer", [0, 0, "$Konst1", 0], "$Circuit_2_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, "$Konst1", 0], "$Circuit_3_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, "$Konst1", 0], "$Circuit_4_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_5_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_6_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_7_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_8_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_9_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_10_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_11_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_12_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_13_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_14_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_15_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_16_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_17_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_18_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_19_", "$CurrentStep"],
        ["Multiplexer", [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "$Konst1", 0], "$Circuit_20_", "$CurrentStep"]

  ]
}

Code: Alles auswählen

/**
 * File: Irrigation_CircuitControl.twl V1.0 ALPHA 3
 * Logic for Garden irrigation. This module is the Circuit Control which controls one single irrigation circuit 
 * Author: Hans Martin
 * 
 */

{
  "Input": [
        ["Trigger Automatic", "(RISING) Trigger to start an automatic irrigation cycle", "$TriggerInpAutomatic", "c"],
        ["Trigger Start", "(RISING) Activation of irrigation circuit", "$TriggerInpStart", "c"],
        ["Trigger Stop", "(RISING) Stops any active cycle", "$TriggerInpStop", "c"],
        ["Automatic Time", "(T_s) Time of one irrigation cycle", "$AutoTime", "u"],
        ["System OK Feedback", "(0/1) Loopback of SystemControl", "$SystemOk", "c"],
        ["Inhibit", "", "$VAR<Inhibit?>", "c"]
  ],
  "Output": [
        ["Valve", "(0/1) Output for the valve", "$ValveOut", "c"],
        ["System Request", "(0/1) Request for the SystemControl", "$SystemRequest", "c"],
        ["Circuit State", "(0/1) State indicating whether the circuit is running", "$CircuitState", "c"],
        ["Circuit finished", "(0/1) Flag indicating that the circuit is finished", "$CircuitFinished", "c"]
  ],
  "Level": [
        // Inputs
        ["$VAR<Inhibit?>","bool",false],
        ["$TriggerInpAutomatic", "bool", false],
        ["$TriggerInpStart", "bool", false],
        ["$TriggerInpStop", "bool", false],
        ["$AutoTime", "float", 0],
        ["$SystemOk", "bool", false],

        // Output
        ["$ValveOut", "bool", false],
        ["$SystemRequest", "bool", false],
        ["$CircuitState", "bool", false],
        ["$CircuitFinished", "bool", false],

        // Constants
        ["$Konst1", "int", 1],
        ["$Konst2", "int", 2],
        ["$KonstFalse", "bool", false],
        ["$KonstTrue", "bool", true],

        // Internals
        ["$State","integer",0],
        ["$Inhibit","bool",false],
        ["$Cancel","bool",false],
        ["$ShouldRun", "bool", false],
        ["$LastShouldRun", "bool", false],
        ["$ShouldRunAndSysOk", "bool", false],
        ["$TimerActive", "bool", false],
        ["$TriggerAutomaticSaved", "bool", false],
        ["$TimerShouldRun", "bool", false],
        ["$CancelFinished", "bool", false],
        ["$TriggerInpStartRising","bool",false],
        ["$TriggerInpStopRising","bool",false],
        ["$TriggerInpAutomaticRising","bool",false],
        ["$TriggerInpStartLast","bool",false],
        ["$TriggerInpStopLast","bool",false],
        ["$TriggerInpAutomaticLast","bool",false],
        ["$ManualOn","bool",false],
        ["$SetOutputs","bool",false],
        ["$AutomaticModeActive","bool",false],
        ["$AutomaticModeActiveOrRequested","bool",false],
        ["$CancelAndAutoActive","bool",false]
  ],
  "Module": [
        // calculate rising edges
        ["And", ["$TriggerInpStart","-$TriggerInpStartLast"], "$TriggerInpStartRising"],
        ["And", ["$TriggerInpStop","-$TriggerInpStopLast"], "$TriggerInpStopRising"],
        ["And", ["$TriggerInpAutomatic","-$TriggerInpAutomaticLast"], "$TriggerInpAutomaticRising"],
      
        // calculate cancel state
        ["Or", ["$VAR<Inhibit?>"], "$Inhibit"],
        ["Or", ["$Inhibit", "$TriggerInpStopRising"], "$Cancel"],

        // calculate manual state
        ["Or",["$TriggerInpStartRising", "$ManualOn"],"$ManualOn"],
        ["And", ["$ManualOn", "-$TimerActive", "-$Cancel"], "$ManualOn"], // if automatic mode was triggered, cancel manual mode

        // calculate start of system
        ["Or", ["$TriggerAutomaticSaved", "$TriggerInpAutomaticRising"], "$TriggerAutomaticSaved"], // save trigger
        ["And", ["$TriggerAutomaticSaved", "-$TimerActive", "-$Cancel"], "$TriggerAutomaticSaved"], // reset trigger if timer has taken over control or cancel was issued

        // Set timer if automatic mode was triggered
        ["And", ["$TriggerAutomaticSaved", "$SystemOk"], "$TimerShouldRun"], // start timer only if also system ok was announced
        ["Monoflop", "$TimerShouldRun", "$Cancel", "$TimerActive", "$AutoTime", 2], // not retriggerable, rising-edge controlled, reset on cancel

        // build target state (run or not)
        ["Or", ["$TriggerAutomaticSaved", "$TimerActive"], "$AutomaticModeActive"],
        ["Or", ["$AutomaticModeActive", "$TriggerInpAutomaticRising"], "$AutomaticModeActiveOrRequested"],
        ["Or", ["$ManualOn", "$AutomaticModeActive"], "$ShouldRun"],

        // build state
        ["And", ["$ShouldRun", "$SystemOk"], "$ShouldRunAndSysOk"], //bypass to skip state 1
        ["And", ["$AutomaticModeActiveOrRequested", "$Cancel"], "$CancelAndAutoActive"], // bypass to only announce finished on cancel from state 0, 1 or 2 when automatic mode was active

        ["Statemachine",
            // 0: Circuit Off
            // 1: Requesting for SystemOK
            // 2: Circuit On
            // 3: Finishing
            [
                // [condition , current state, next state, timeout]
                // cancel state transitions
                ["$CancelAndAutoActive", 0, 3, "$Konst1"],
                ["$CancelAndAutoActive", 1, 3, "$Konst1"],
                ["$CancelAndAutoActive", 2, 3, "$Konst1"],

                ["$Cancel", 1, 0, 0],
                ["$Cancel", 2, 0, 0],        

                // normal operation state transitions
                ["$ShouldRunAndSysOk", 0, 2, 0], // bypass to skip state 1
                ["$ShouldRun", 0, 1, 0], // new request
                ["-$ShouldRun", 1, 0, 0], // cancel request
                ["$SystemOk", 1, 2, 0], // system reported ok
                ["$ShouldRun", 2, 2, 0], // running
                ["-$ShouldRun", 2, 3, "$Konst1"], // finishing
                [0, 3, 0, 0] // end
            ],
            "$State"
        ],

        // set some outputs only if system should run now or was running in last tick
        ["Or", ["$ShouldRun", "$LastShouldRun"], "$SetOutputs"],

        // Map state to outputs
        ["Comparator", "$State", "$CircuitFinished", "$Konst2"], // Finished (only 1 when state > 2)
        ["Comparator", "$State", "$CircuitState", 0], // Circuit State (only 1 when state > 0)
        ["Comparator", "$State", "$SystemRequest", 0], // SystemRequest (only 1 when state > 0)
        ["Multiplexer", [0, 0, "$Konst1", 0], "$ValveOut", "$State"], // Valve (1 only in state 2)

        ["And", ["$SetOutputs", "$CircuitState"], "$CircuitState"],
        ["And", ["$SetOutputs", "$SystemRequest"], "$SystemRequest"],
      
        // announce finished when canceld or automatic finished
        ["And", ["$Cancel", "$ShouldRun"], "$CancelFinished"],
        ["Or", ["$CancelFinished", "$CircuitFinished"], "$CircuitFinished"],

        // Reset Trigger
        ["Multiplexer", [0, "$TriggerAutomaticSaved", "$TriggerAutomaticSaved", "$TriggerAutomaticSaved"], "$TriggerAutomaticSaved", "$State"],

        // set last trigger variables
        ["And", ["$TriggerInpStart"], "$TriggerInpStartLast"],
        ["And", ["$TriggerInpStop"], "$TriggerInpStopLast"],
        ["And", ["$TriggerInpAutomatic"], "$TriggerInpAutomaticLast"],
        ["And", ["$ShouldRun"], "$LastShouldRun"],

        // Reset Inputs
        ["Latch", "$KonstFalse", "$TriggerInpAutomatic", "$KonstTrue", 0],
        ["Latch", "$KonstFalse", "$TriggerInpStart", "$KonstTrue", 0],
        ["Latch", "$KonstFalse", "$TriggerInpStop", "$KonstTrue", 0]
  ]
}
Du hast keine ausreichende Berechtigung, um die Dateianhänge dieses Beitrags anzusehen.
Zuletzt geändert von MiniMaxV2 am So Apr 26, 2020 1:26 pm, insgesamt 1-mal geändert.
LG
Hans Martin
timberwolf413 (950Q) - VPN offen - reboot erlaubt / timberwolf610 (950Q) - VPN offen - reboot erlaubt
Antworten

Zurück zu „Zusätzliche Logikbausteine“