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 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #5314
    Avatarnelson.albarran
    Participant

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

    best regards

    #5316
    MikhailMikhail
    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
    Avatarnelson.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
    MikhailMikhail
    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
    MikhailMikhail
    Moderator

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

    #5339
    Avatarnelson.albarran
    Participant

    My setting is

    Captura1

    I have obtained always zero as result.

    #5342
    MikhailMikhail
    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
    Avatarnelson.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
    MikhailMikhail
    Moderator

    Untick “Formula used” checkbox for the destination channel.

    #5352
    Avatarnelson.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
    MikhailMikhail
    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
    MikhailMikhail
    Moderator

    Link to the tested formulas to work with previous values.

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