You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old May 16th, 2018, 10:24 AM   #1
ryangriggs
Member
United States

ryangriggs is offline
 
Join Date: Jun 2016
Location: USA
Posts: 118
Calculating change-over-time for slow process variable

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/...and-data-total
Exponential moving averages: https://en.wikipedia.org/wiki/Moving...moving_average
and https://stackoverflow.com/questions/...90656#10990656








Thanks for any advice.

Last edited by ryangriggs; May 16th, 2018 at 10:31 AM.
  Reply With Quote
Old May 16th, 2018, 01:34 PM   #2
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,680
The rate of change of level is ( inflow - outflow )/area. If you know both the inflow and the outflow you can predict, estimate, the rate of change in level. If the actual change in level does not match the estimated change in level within some bounds then you know you have a problem.

You know what the inflow should be but you don't mention the outflow. If you don't know the outflow there isn't a away to estimate the rate of change in level.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old May 16th, 2018, 06:22 PM   #3
ryangriggs
Member
United States

ryangriggs is offline
 
Join Date: Jun 2016
Location: USA
Posts: 118
@Peter - I don't have access to a rate of inflow or outflow. All I have is access to a tank level value. From this, I need to calculate the rate of change, so I can compare with the desired minimum rate of change specified by the operator.
  Reply With Quote
Old May 16th, 2018, 10:22 PM   #4
Peter Nachtwey
Member
United States

Peter Nachtwey is offline
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,680
Quote:
Originally Posted by ryangriggs View Post
@Peter - I don't have access to a rate of inflow or outflow. All I have is access to a tank level value. From this, I need to calculate the rate of change, so I can compare with the desired minimum rate of change specified by the operator.
oops! You have been given the impossible task.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old May 16th, 2018, 10:29 PM   #5
seth350
Member
United States

seth350 is offline
 
seth350's Avatar
 
Join Date: Jul 2011
Location: Over yonder
Posts: 195
Best you can do is use the information from the pump curve to determine how much volume the pump pumps. That value used together with a timer/counter to grossly estimate how much volume SHOULD have been pumped into the tank vs what has actually been pumped given by the pressure sensor.
I would imagine this could work marginally well for filling the tank, although will probably require some hysteresis.

You would basically be giving an alarm based on theoretical vs actual pump efficiency. Less than 80%? Less than 60%? Without the actual flow of what’s going in and out, it’s a **** shoot.
__________________
“Did the Lord say that machines outta take the place of livin’, and what’s the substitute for bread and beans? Do engines get rewarded for their steam?” -John Henry
  Reply With Quote
Old May 16th, 2018, 10:39 PM   #6
ryangriggs
Member
United States

ryangriggs is offline
 
Join Date: Jun 2016
Location: USA
Posts: 118
I think I must have expressed the question badly... sorry about that. I think everyone is missing the point of what I'm actually asking.



I don't care about how much the pump *should* transfer in a given time. That's outside the scope of this question. All I want to do is calculate an approximate "rate of change" value based on the tank level, and keep this value up-to-date, so that at all times, I can look at this value to determine how much the level is changing per (minute/second/hour/other unit of time).



Is there a simpler algorithm than storing an array of previous values to generate a calculated rate-of-change value?


For example, I want to output a value that indicates "the tank level is currently changing at approximately 2.5 ft per hour."



One way I could do this is to set a timer to expire once per hour. Each time the timer expires, I could subtract the current level value from the previous one, then overwrite the previous level with the current one. This would give me a "rate of change" over that hour, but would only look at two snapshots. I would prefer to have an "averaged" rate of change with a sample taken every minute, but I don't want to store the 60 sampled values in an array.


Hopefully this clarifies the question. Most basic form of my question: "how to calculate reasonably accurate rate-of-change over a specified period without storing lots of values in an array".


Thanks!

Last edited by ryangriggs; May 16th, 2018 at 10:43 PM.
  Reply With Quote
Old May 16th, 2018, 11:03 PM   #7
danw
Member
United States

danw is offline
 
danw's Avatar
 
Join Date: Oct 2004
Location: midwest, USA
Posts: 2,772
Quote:
Originally Posted by ryangriggs View Post
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 the stated problem, a faulty continuous level sensor that causes an overflow, the conventional industry solution is a high limit point level switch using a different technology than the primary continuous level sensor.

Be my guest doing some rate of change calc, but there are commercial solutions available.

Last edited by danw; May 16th, 2018 at 11:19 PM.
  Reply With Quote
Old May 17th, 2018, 12:49 AM   #8
janner_10
Supporting Member
United Kingdom

janner_10 is offline
 
Join Date: Dec 2014
Location: Tewkesbury
Posts: 603
There is a Rate of Change alarm inside the ALMA instruction, both +ve and -ve, which is %/s in a given period (s)

For simplicity, you could monitor this for NOT alarm, when your pump is running.
  Reply With Quote
Old May 17th, 2018, 12:58 AM   #9
Mickey
Lifetime Supporting Member
United States

Mickey is offline
 
Mickey's Avatar
 
Join Date: May 2003
Location: Palmdale,Ca
Posts: 10,075
More to read..

https://www.google.com/search?q=rate...hrome&ie=UTF-8
__________________
Mickey

If you want happiness for an hour-take a nap. If you want happiness for a day-go fishing. If you want happiness for a month-getmarried. If you want happiness for a year-inherit a fortune. If you want happiness for a lifetime-help someone else.
----- Chinese Proverb
  Reply With Quote
Old May 17th, 2018, 03:11 AM   #10
AustralIan
Member
United Kingdom

AustralIan is offline
 
Join Date: Jan 2013
Location: UK
Posts: 730
MAVE block in Logix 5000?
only Function Block or Structured text, but does the job. Yes, you need to store N samples of data for a MAVE.

If not logix 5000, here is a moving average algorithm in structured text syntax.
https://github.com/simsum/oscat/blob...LTER_MAV_W.EXP

Alternative to a MAVE is a single order low pass filter:

Code:
// execute at a fixed period.  smaller k = longer filter time.
Filtered level change := Filtered level change + k * instantaneous rate of level change;
  Reply With Quote
Old May 17th, 2018, 04:21 AM   #11
chopin
Member
United Kingdom

chopin is offline
 
Join Date: May 2012
Location: Milton Keynes
Posts: 106
Simplest I could think of
Attached Images
File Type: jpg 1.jpg (26.9 KB, 55 views)
  Reply With Quote
Old May 17th, 2018, 07:32 AM   #12
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Fields of corn
Posts: 878
So you're looking at a weighed average? If you calculate your rate of change once a minute and add that to a weighed average consistently and map both current level and the weighed average side by side you should get a trailing or lagging value effect where if something changed rapidly it will leave a trace behind it until it settles at a stable value.
  Reply With Quote
Old May 17th, 2018, 09:32 AM   #13
Tark
Member
United States

Tark is offline
 
Tark's Avatar
 
Join Date: Apr 2004
Posts: 503
If you want to pursue your rate of change solution then you'll need a fairly accurate level transmitter. For example, if your rate of change per hour is 2.5 feet / 60 samples per hour = 0.041 feet per minute. If your rate of change was 1 foot per hour then that would be 0.016 feet per minute. I would guess that your level sensor isn't that accurate, so a sample rate of 10 minutes would probably be better. 2.5 feet / 6 samples per hour = 0.41 feet per 10 minutes or 1.0 feet / 6 samples per hour = 0.16 feet per 10 minutes. The basic equation is (current level - previous level) * samples per hour.

But there is a simpler and probably more beneficial solution to the problem. Put current runtime meters on the tank's request for lead and lag and on the pumps themselves. Then you add an alarm to the current runtime meters called High Runtime. So if it generally takes 4 hours to fill the tank then the operators could set the High Runtime alarm for 5 or 6 hours. You can also give the operators a previous runtime reading.

Going with a High Runtime alarm is simple to implement, simple for the operators to understand and gives additional beneficial information.
Attached Images
File Type: jpg TankMeters.JPG (44.9 KB, 34 views)
  Reply With Quote
Old May 17th, 2018, 10:10 AM   #14
jamesau
Lifetime Supporting Member
United States

jamesau is offline
 
Join Date: Mar 2004
Posts: 163
Quote:
Originally Posted by danw View Post
For the stated problem, a faulty continuous level sensor that causes an overflow, the conventional industry solution is a high limit point level switch using a different technology than the primary continuous level sensor.
The above is the correct way to address your problem. Alarm and interlock off both sensors as necessary.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
ENBT-1756 Connection Time OUT xyzinfo LIVE PLC Questions And Answers 8 April 6th, 2017 08:30 PM
Factorytalk view password reset button problem Nan LIVE PLC Questions And Answers 6 September 29th, 2015 01:16 PM
How to change time base logix pro simulator google08 LIVE PLC Questions And Answers 3 August 22nd, 2011 08:57 AM
Electronics Questions peavey_wolfgang_2000 LIVE PLC Questions And Answers 4 May 23rd, 2005 08:05 PM
how often should I trigger the PID? Ron Beaufort LIVE PLC Questions And Answers 11 February 22nd, 2003 10:57 AM


All times are GMT -5. The time now is 12:34 AM.


.