Difference between current and previous data of same channel

Forum Home Forums Understanding the Software Using Formulas Difference between current and previous data of same channel

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #5314
    nelson.albarran
    Participant

    Hi,
    I want to calculate the diference between the previous data and current data.

    best regards

    #5316
    Mikhail
    Moderator

    Hi,

    You need to create extra input channels:
    1st to save the previous value. Use SetData function in the formulas of the source channel for this purpose.
    2nd to calculate the difference.

    #5322
    nelson.albarran
    Participant

    Hi, I followed your advice, but I have not achieved to obtain the result that i wish.

    Channel 1: The data of sensor. // SetVal(2,Cnl)
    Channel 2:
    Channel 3: Val(1)-Val(2)

    Wich is my error?

    #5330
    Mikhail
    Moderator

    Hi,
    I need more info. Could you provide the screenshots of the settings and the steps how you test and what you actually get?

    #5331
    Mikhail
    Moderator

    Try SetVal(2, Val()) instead of SetVal(2, Cnl)

    #5339
    nelson.albarran
    Participant

    My setting is

    Captura1

    I have obtained always zero as result.

    #5342
    Mikhail
    Moderator

    Well…

    Add this to the Formulas table

    double MySetVal(int n)
    {
      SetVal(n, Val());
      return Cnl;
    }

    and use in the channel 1: MySetVal(2)
    Channel 2 must be of Calculated real type

    #5346
    nelson.albarran
    Participant

    I have set the channels like you said me. But I havent obtain the correct result. Always obtain zero.

    Captura2
    Captura3

    For checking the formulas, I generate data to the channel as “source”. But in the channel as “result” always I obtain zero.

    Captura4

    #5348
    Mikhail
    Moderator

    Untick “Formula used” checkbox for the destination channel.

    #5352
    nelson.albarran
    Participant

    The problem is kept. I have set the channels like you say me but in the channel “RESULT” I have obtained zero again. I checked the channel values “SOURCE” and “AUX”, current and previous respectively and both are the same value, then, the AUX channel dont save the previous value.

    Captura

    #5363
    Mikhail
    Moderator

    Please try updating the formula

    double MySetVal(int n)
    {
      SetData(n, Val(), 1);
      return Cnl;
    }

    Also we can quickly solve the issue by connecting to your machine. This service is commercial.

    #5438
    Mikhail
    Moderator

    Link to the tested formulas to work with previous values.

    #13027
    myscada
    Participant

    Pls. try to change input channel 4051 (SOURCE) from “Calculated Real” to “Real”, and 4052 (AUX) from “Real” to “Calculated Real” (like what Mikhail said). It should be OK.

    • This reply was modified 1 year, 2 months ago by myscada.
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.