Forum Home › Forums › Understanding the Software › Using Formulas › Difference between current and previous data of same channel
- This topic has 12 replies, 3 voices, and was last updated 2 years, 4 months ago by
myscada.
-
AuthorPosts
-
April 18, 2019 at 2:20 pm #5314
nelson.albarran
ParticipantHi,
I want to calculate the diference between the previous data and current data.best regards
April 18, 2019 at 2:44 pm #5316
MikhailModeratorHi,
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.April 18, 2019 at 8:45 pm #5322nelson.albarran
ParticipantHi, 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?
April 19, 2019 at 11:17 am #5330
MikhailModeratorHi,
I need more info. Could you provide the screenshots of the settings and the steps how you test and what you actually get?April 19, 2019 at 11:19 am #5331
MikhailModeratorTry SetVal(2, Val()) instead of SetVal(2, Cnl)
April 22, 2019 at 1:25 pm #5339nelson.albarran
ParticipantMy setting is
I have obtained always zero as result.
-
This reply was modified 6 years, 7 months ago by
nelson.albarran.
April 22, 2019 at 1:50 pm #5342
MikhailModeratorWell…
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 typeApril 22, 2019 at 3:30 pm #5346nelson.albarran
ParticipantApril 23, 2019 at 1:14 pm #5348
MikhailModeratorUntick “Formula used” checkbox for the destination channel.
April 23, 2019 at 3:28 pm #5352nelson.albarran
ParticipantApril 24, 2019 at 1:34 pm #5363
MikhailModeratorPlease 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.
May 13, 2019 at 6:42 am #5438
MikhailModeratorLink to the tested formulas to work with previous values.
July 24, 2023 at 1:21 am #13027 -
This reply was modified 6 years, 7 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.




