Quantcast
Channel: Siemens Latest Topics
Viewing all articles
Browse latest Browse all 698

Working with rate of change and decimals in TIA portal

$
0
0

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!


Viewing all articles
Browse latest Browse all 698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>