adccommunitymod (AutomationDirect) asked a question.

CLICK PLC - Absolute value of a math operation

Created Date: February 08,2017

Created By: ryangriggs

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I may just be missing it, but I can't find a simple way to get the absolute value of a math operation. I want to set up a deadband for a value: if the value has changed by more than X, then do Y. However, for this to be simple, I need to calculate the absolute value of current process value - previous process value. Yes, I could do SQRT((Current - Prev) ^ 2) but that seems like hugely overkill, plus you could easily hit the integer limits with larger numbers... not to mention the added CPU cycles required for those SQRT and exponent operations. There doesn't appear to be an "ABS " instruction. Any suggestions or pointers welcome! Thanks!


  • adccommunitymod (AutomationDirect)

    Created Date: February 08,2017

    Created by: ryangriggs

    I may just be missing it, but I can't find a simple way to get the absolute value of a math operation. I want to set up a deadband for a value: if the value has changed by more than X, then do Y. However, for this to be simple, I need to calculate the absolute value of current process value - previous process value.

    Yes, I could do SQRT((Current - Prev) ^ 2) but that seems like hugely overkill, plus you could easily hit the integer limits with larger numbers... not to mention the added CPU cycles required for those SQRT and exponent operations.

    There doesn't appear to be an "ABS " instruction.

    Any suggestions or pointers welcome!

    Thanks!

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: February 08,2017

    Created by: bcarlton

    Values in DF1 and DF2, result in DF3

    Rung 1: If DF1> DF2 then MATH (result in DF3, formula DF1 - DF2) --- in parallel with MATH - OUT C1

    Rung 2: If NOT C1 then MATH (result in DF3, formula DF2 - DF1)

    (Of course use any registers you wish)

  • adccommunitymod (AutomationDirect)

    Created Date: February 09,2017

    Created by: ryangriggs

    Thanks Bernie. That's exactly what I ended up doing... Was just looking for the simplest way to accomplish this, and I was surprised the Math feature didn't include an ABS function.

  • adccommunitymod (AutomationDirect)

    Created Date: September 26,2017

    Created by: JabboGibbs76

    Berine,

    Could you share the click program using this deadband

  • adccommunitymod (AutomationDirect)

    Created Date: September 27,2017

    Created by: bcarlton

    I don't have a program. Just this quick method to derive an absolute value.