Channel with Self Increase / Decrease Value

Forum Home Forums Understanding the Software Using Formulas Channel with Self Increase / Decrease Value

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #13357
    JW
    Participant

    How to make a channel value increase / decrease by 1 when conditions are met?

    E.g.
    I set value of channel no.1 to 10, then set formula of channel no.1 to
    Val(1)>1?Val()+1:Val()

    I want to use this value as a timer to give the alarm detection as time delay / tolerance.

    With configuration of Current Data writing period of 1s,
    I excepted the value of channel no.2 increase every time the data refreshed.

    But the value increased rapidly, maybe 9-10 every second, seems the channel keep updating the value endlessly.

    Any solution or alternative solution?

    #13358
    manjey73
    Participant

    Yes, channels are processed several times in one second. Use the built-in formulas once per Second, if available. Or use timers with the necessary delay before adding or subtracting.

    #13367
    JW
    Participant

    The case I am worrying about was the formula referencing and updating self-value will trigger the channel updating again as a endless feedback loop.

    If it’s not the case, but only all channels are calculated around 8-10 times per second, I can use a counter counting down from 300 to 0 to simulate a 30s delay.

    #13368
    manjey73
    Participant

    All formulas in Scada channels are always executed in a loop. Imagine that you are programming a PLC in LAD language. That’s about how formulas are processed in Scada channels. The sequence of calculations of formulas from the smallest channel number to the highest. Therefore, if periodic calculation of formulas is required, or you need to use built-in tools Every minute, every hour, or create your own timers, triggers, and so on, according to which you already perform actions.

    #13373
    Mikhail
    Moderator

    You need an additional variable to store a flag that the condition change has already processed. After adding 1, set the flag ON. When the condition becomes false, set the flag to OFF. The formula is not very simple, because it executes in a loop as written above.

    Alternatively, you could increase a channel inside the formula of the condition if it’s applicable.

    #13374
    Mikhail
    Moderator

    Automatic Control Module works in this way. It can send command when condition is met. According to the command, channel value can be simply increased.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.