easy-forum
Deutsch - Software => easySoft => Thema gestartet von: Andrus Saar am Februar 27, 2024, 04:52:20 Vormittag
-
Hello
Wie kann ich Stromstoßrelais in strukturiertem Text (ST) implementieren?
Wenn ich zum Beispiel die RECHTS-Taste P03 einmal drücke, wird der Ausgang Q1 eingeschaltet, beim zweiten Drücken wird der Ausgang ausgeschaltet, beim dritten Drücken wird der Ausgang wieder eingeschaltet usw.
Andrus
(übersetzt von DeepL Translate)
-
hi Andrus,
it's very simple ;)
// rising edge
M100 := I01 and not M101;
M101 := I01;
// impulse switch
Q01 := Q01 xor M100;
weiss_nix
-
Hello
Oh, das ist eine wirklich gute und einfache Lösung. Meine ist ein bisschen komplizierter, aber sie funktioniert, wie sie sollte.
(* 2. Impulse relay logic. The RIGHT button turns output Q2 on or off *)
IF P03 AND NOT M02 THEN // Initiate impulse relay function - RIGHT button switches memory M3.
M03 := NOT M03; // Memory, which is switched on the first time, off the second time, on the third time, etc.
END_IF;
M02 := P03;
Q2 := M03; // Output Q2 is assigned a value from memory M3
Andrus
(übersetzt von DeepL Translate)
-
Hi Andrus, if you like very short and crisp ST programming, you can try this code snippet.
// impulse switch
Q01 := Q01 xor (I01 and not M101);
M101 := I01;
weiss_nix
-
weiss_nix, ;) toll
Can anybody to make it else shorter - in one line? ;)
-
Hallo
Oh, diese Option ist noch besser.
Ein kleines Codebeispiel für einen UF-Block, der zwei Impulsrelais mit einem einzigen Eingang ansteuert. Ein kurzer Druck (weniger als 1 Sekunde) schaltet Ausgang 1, und ein langer Druck (mehr als 1 Sekunde) schaltet Ausgang 2.
(* 2-channel impulse relay with trigger (push button) and reset input *)
// Impulse relay 1 - push button falling edge before timer is on (short press).
Q01 := NOT I02 AND ( Q01 XOR ( NOT I01 AND M1 AND NOT T01Q1 ) ) ;
M1 := I01 ;
// Impulse relay 2 - timer rising edge (push button long press).
Q02 := NOT I02 AND ( Q02 XOR (T01Q1 AND NOT M2 ) ) ;
M2 := T01Q1 ;
// On-delayed timer to distinguish between short or long press.
T01 (
EN := I01, // Push button input (trigger).
RE := I02, // Reset input.
ST := ,
I1 := T#1000ms, // 1 sec on-delay.
I2 := ,
Q1 => ,
QV =>
);
Andrus
(übersetzt von DeepL Translate)