No announcement yet.

How to determine if a set point (integer) has changed

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to determine if a set point (integer) has changed

    I'm a beginner. Thank you for your help. I have a tag named SP PSIG. I need to know when it changes and whether the value increased or decreased. It looks like the compare values instruction is ideal. My issue is I don't know how to store the previous value to compare it with the current value. I'm sure there must be a simple way. Thanks for the help.

  • #2
    Just use a CPD instruction when the two values are not equal to copy the value you are monitoring to the value you are storing for the compare.

    Click image for larger version

Name:	compare.PNG
Views:	83
Size:	6.2 KB
ID:	129343


    • #3
      To handle first scan situation where you probably receive false > or < condition (since VALUE_B has not yet been set before the compare instructions), have another copy of the COPYDATA at the top of your program that you run on first scan, i.e. on first scan, make sure VALUE_B matches VALUE_A. After the first scan, it will all work as desired.

      First Scan
      ---] [--------------------[COPYDATA VALUE_A to VALUE_B]
      There are 10 kinds of people in this world, those who know binary, and those who do not.


      • #4
        My 'Logic' is to have a 'Human Value' that is entered by the Operator, and a 'Machine Value' that is the Set point the Device is working on Presently..
        The Line Logic will cycle through and if Device Set point = Operator Set Point, No Action..
        If Device Set Point <> Operator Set Point, then do your Logic, and when your done make Machine Set Point = Operator Set point and the First Line will become true and No Aditional Action will happen..

        This is just a Longer Explanation of what was said above.. I'm a Visual Guy, rather than Formula Person.. So it takes me longer to Understand things..