Autor Thema: Demo program - set, reset, toggle, edge detection  (Gelesen 2533 mal)

Offline Andrus Saar

  • Jr. Member
  • **
  • Beiträge: 21
Demo program - set, reset, toggle, edge detection
« am: Februar 15, 2024, 21:32:39 Nachmittag »
Hello everyone

I'm quietly practicing programming in ST.

I'm quite at the beginning, only a few months of practice.

I made a demo program with set and reset, pulse relay function and edge detection.

Program description and code in .zip file.

Andrus

Offline Andrus Saar

  • Jr. Member
  • **
  • Beiträge: 21
Antw:Demo program - set, reset, toggle, edge detection
« Antwort #1 am: Februar 16, 2024, 23:29:48 Nachmittag »
Question:


(* 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;  // Impulse relay function termination - button RIGHT affects memory M2.


Is there any way to make this function shorter or easier?

Andrus

Offline weiss_nix

  • Sr. Member
  • ****
  • Beiträge: 608
  • it has to be easy, it's a easy!
Antw:Demo program - set, reset, toggle, edge detection
« Antwort #2 am: Februar 27, 2024, 08:00:05 Vormittag »
Hi Andrus,
I think your question is answered here!

weiss_nix
Sollte ich (gefährliches) Halbwissen verbreiten, beuge ich demütig mein Haupt mit der Gewissheit versagt zu haben!
WICHTIG: Sämtliche Programme dienen lediglich der Veranschaulichung von Funktionen und sind nicht für den Produktiveinsatz geeignet!

Offline Andrus Saar

  • Jr. Member
  • **
  • Beiträge: 21
Antw:Demo program - set, reset, toggle, edge detection
« Antwort #3 am: März 02, 2024, 07:11:20 Vormittag »
Hello

New version of the program, modified according to Weiss_nix instructions.

Andrus