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

This topic contains 11 replies, has 2 voices, and was last updated by Mikhail Mikhail 4 months, 1 week ago.

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

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

    best regards

    #5316
    Mikhail
    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
    Avatar
    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
    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
    Mikhail
    Moderator

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

    #5339
    Avatar
    nelson.albarran
    Participant

    My setting is

    Captura1

    I have obtained always zero as result.

    #5342
    Mikhail
    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
    Avatar
    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
    Mikhail
    Moderator

    Untick “Formula used” checkbox for the destination channel.

    #5352
    Avatar
    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
    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
    Mikhail
    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.