Working with rate of change and decimals in TIA portal

  • Working with rate of change and decimals in TIA portal

    Posted by Sheel Patel on September 28, 2023 at 7:17 pm

    I am working on a PLC program that requires an analog valve to close a given percentage in a given time in seconds. I give the start position, the final position, and the time. I calculate the rate of change and I add that to the start position every second until it reaches the final position. For example, the start position is 0%, the final position is 50%, time is 5s. So the rate of change = (50-0)/5 = 10%/s. So every second I add 10% to the current position of the valve until it equals the final position and then it stops. This becomes tricky when the rate of change has many decimals or a recurring decimal and using the equal to comparator. for example, the start position is 0%, the final position is 40%, time is 7s. the rate of change = (40-0)/9 = 4.444444…%/s. The current position is never exactly equal to the final position and the logic keeps executing infinitely and the valve is either fully open or fully closed. I have tried a few different things such as rounding the numbers or using limits instead of equal to, but none of it seems to be working perfectly.

    Is there a better way to do this?

    Thanks!

    Sheel Patel replied 1 year, 2 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.

Share via
Follow us and never miss an update!