Ankündigung

Einklappen
Keine Ankündigung bisher.

Infinite Loop! Help!

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    HS/FS Infinite Loop! Help!

    Hello,

    I really can't sort out my problem of infinite loop! I'm reading other discussions on the forum but nothing works here.

    I have an overall water counter (Counter Water Garden), I also store the "last value before a change (in "Counter Last Value"), and I'd like to increment a daily counter (I understand there might be different ways to do this but in the future i'll have different daily counters for different situations so I need to solve this use case first).

    So, the idea is: when the total counter changes, I compare it to the previous value, and add the difference in my "Delta-day water" counter (and reset the last value to the current value)

    This obviously doesn't work: I get an infinite loop.

    How should I solve this? Thank you!
    image.png

    #2
    Hi!

    You will not get it solved with one logic where the same object appears in the input box and in in the output box - whenever the value in the output box is updated it starts the logic again and you have the infinite loop. You have to split the logic...

    In such logics I use help objects to avoid the loops. The following should work:
    • in the upper part of the first logic you just determine the difference between the last value and the new value
    • in the lower part of the first logic you takeover the current value from Delta-day water to a help object (same data format) only if the new value is higher than the last value
    • In the second part you do the calculation - add DifferenceOldNew to the Delta-day water help object (which at that moment has the same value as the original Delta-day water)
    • Finally update the "Counter - last value" with the value of "Counter Water Garden - L"
    Yes, with the last step you start the first logic (ID 493647) again - but just the upper part of the first logic. As "Counter Water Garden - L" and "Counter - Last value" have the same values, the "grösser" (bigger) is false and the command in output box 493659 is not triggered! Same in the 2nd part of the logic: The DifferenceOldNew is null, DifferenceOldNew + Delta-day water help does not change and therefore in the 2nd run the bottom part (ID 493671) is not triggered

    grafik.png​​

    You might suppress the 2nd run as follows (I assume that you get a new value for the "Counter Water Garden - L" every 20 seconds):​
    • double click on the gray headline of the substraction module
    • in the upcoming dialogue check "telegram interval" and set a a value of 10 seconds
    Now the 2nd run is stopped at the substraction module as it only allows one telegram every 10 seconds.


    grafik.png
    Angehängte Dateien
    Möchte den Komfort meiner Installation nicht mehr missen!

    Kommentar


      #3
      Rubbish!

      Just forget my last post!

      Just put the interval (a few seconds smaller than the period you receive a new total value) I explained at the end of the post into the addition box - the addition box will then only let a value through once, then it is blocked for the interval. Your Delta-day water object will not be updated again and so the logic is not triggered again!

      Question: What is the sense of the multiplication modules? I cannot assume why you need them?
      Möchte den Komfort meiner Installation nicht mehr missen!

      Kommentar


        #4
        Hello High-tech,

        Thanks, I really appreciate you taking the time. I’ll try this as soon as I’ve access to the system later today. To be clear, in your last post, you are suggesting NOT to split the process in two « layers », but to just keep one as I had in my initial post and add the telegram interval you were talking about, right?

        As for the multiplication by 1, the goal was to have a SBC (send by change only) semantic to minimize the risk of « echo » of messages from input to output to input when no data was actually changed.

        I’ll let you know how it works, but thanks in advance!

        Kommentar


          #5
          OK, so I had to use two "timing" elements to make this work. First one was to indeed add a 1 second delay. Second one was to have a telegram interval, in the lower section, larger than 1 second, which in this case I've put to 2 seconds. The reason is that when I finish the second logic (the one below), it resets TWO values: the buffer is set to 0 and the last known value of the counter is set to the current value. This actually re-trigger the logic TWICE, one for each change, leading to wrong transition isssues. Setting the telegram to 2 seconds (but I actually think it could be just one), prevents this and only computes the new logic with BOTH values changed at the same time:
          image.png​Thanks again!

          Kommentar


            #6
            (ignore that part of the logic btw, I started modifying my logic before replying to the thread!)
            image.png

            Kommentar


              #7
              Nice to read that it works now
              Möchte den Komfort meiner Installation nicht mehr missen!

              Kommentar

              Lädt...
              X