ryangriggs
Lifetime Supporting Member
TLDR; What's a simple way of generating a "change-over-time" value, indicating the amount of change in a process value over a specified time interval?
Hello, I recently built a control panel with PLC which runs a tank-filling routine (water tank). The routine turns on a pump when the tank level falls below a low-level setpoint, and then turns off the pump after a high-level setpoint is reached. The drain/fill cycle is slow, and may take several hours to complete.
The tank uses a standard 4-20mA pressure transducer and calculates the level based on the standard PSI-to-feet water column conversion.
Recently, however, the line feeding the pressure transducer sprang a tiny pinhole leak, reducing pressure to the transducer and causing it to report a half-full tank when it was actually full and overflowing.
I thought it would be wise add a safety mechanism that determines whether the level is actually changing. For example, I want to implement the following logic:
If the pump is running, and the tank level has not changed by at least X inches in X minutes, throw an alarm to alert the user of the possibility of a problem.
Does anyone have a boilerplate example of tracking the change in a process variable over a specified time window? For example, how much has the level changed in the last 1 hour?
I really hate to create an entire table of historical sampled values, as that seems to add a huge amount of complexity.
The simplistic answer would be to simply sample the level value at the specified interval and compare to the past sample. However, this would ignore large changes/spikes between the sample periods.
I'm thinking a moving average may be the answer, but doesn't it require a reset periodically? I was hoping to hear from someone who has already written a similar algorithm or who has a simpler method.
References:
Simple Running Average: http://www.plctalk.net/qanda/showthread.php?t=19066
Hourly Average: http://www.plctalk.net/qanda/showthread.php?t=17831
Calculating moving averages: https://stackoverflow.com/questions...rage-without-keeping-the-count-and-data-total
Exponential moving averages: https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
and https://stackoverflow.com/questions/10990618/calculate-rolling-moving-average-in-c/10990656#10990656
Thanks for any advice.
Hello, I recently built a control panel with PLC which runs a tank-filling routine (water tank). The routine turns on a pump when the tank level falls below a low-level setpoint, and then turns off the pump after a high-level setpoint is reached. The drain/fill cycle is slow, and may take several hours to complete.
The tank uses a standard 4-20mA pressure transducer and calculates the level based on the standard PSI-to-feet water column conversion.
Recently, however, the line feeding the pressure transducer sprang a tiny pinhole leak, reducing pressure to the transducer and causing it to report a half-full tank when it was actually full and overflowing.
I thought it would be wise add a safety mechanism that determines whether the level is actually changing. For example, I want to implement the following logic:
If the pump is running, and the tank level has not changed by at least X inches in X minutes, throw an alarm to alert the user of the possibility of a problem.
Does anyone have a boilerplate example of tracking the change in a process variable over a specified time window? For example, how much has the level changed in the last 1 hour?
I really hate to create an entire table of historical sampled values, as that seems to add a huge amount of complexity.
The simplistic answer would be to simply sample the level value at the specified interval and compare to the past sample. However, this would ignore large changes/spikes between the sample periods.
I'm thinking a moving average may be the answer, but doesn't it require a reset periodically? I was hoping to hear from someone who has already written a similar algorithm or who has a simpler method.
References:
Simple Running Average: http://www.plctalk.net/qanda/showthread.php?t=19066
Hourly Average: http://www.plctalk.net/qanda/showthread.php?t=17831
Calculating moving averages: https://stackoverflow.com/questions...rage-without-keeping-the-count-and-data-total
Exponential moving averages: https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average
and https://stackoverflow.com/questions/10990618/calculate-rolling-moving-average-in-c/10990656#10990656
Thanks for any advice.
Last edited: