How to calculate flow using level with a PLC (ladder programming)

Hi guys. This is kind of an odd question for EE I know but I thought it was worth giving it a shot.

I'm making a project for my company where we use a PLC/HMI to get real-time data from several transmitters both digital and analog (pressure, on/off switches and level). The level is measured with a HART radar using a 4-20mA loop from Siemens in a tank.

What I need is to calculate the flow of the liquid going into the tank using only the level. If I were using a PC programming language like C++, Basic, Java or even PHP, it would be easy but since the calculation has to be done by the PLC which uses LADDER programming, I don't know what is the best way to calculate it.

The flow calculation doesn't even has to be in real-time. I mean, I can refresh it every 10 to 30 seconds.

We've tried using a BLINK for X seconds (tried 10 and 20 seconds) that grabs the level when the blink began and then the level when the blink ends but I don't like that. Is it possible to use a ramp calculation or something like that? What would be the best (with the less error) way?

Thanks in advance!
LVL 6
Cesar AracenaPHP EnthusiastAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

viki2000Commented:
What kind of PLC do you use?
What kind of data do you get inside the PLC? Only level?
How do you get the data inside the PLC? In what format?
Each PLC has basic arithmetic functions, therefore some calculations can be implemented.
If you get only one parameter inside the PLC liquid level as analog value, then you can calculate only with that parameter and the time.
You measure as fast as possible and make the difference between 2 readings. The knowing the tank volume you know the flow.
The only way to have abetter precision in this case is more readings. There is no other control.
If you have also other info from tank, from other sensors, then the situation may improve.
0
Cesar AracenaPHP EnthusiastAuthor Commented:
It is a FESTO PLC integrated into its own FESTO HMI (model CDPX).

We get 3 pressures, 1 level and 1 gas measurement all using 4-20 mA through the analog ports and only 1 on/off switch using a digital port.
0
viki2000Commented:
Is it a tank under pressure with a liquified gas? Which evaporates in normal ambient conditions in the air? Or when pressure or/and temperature changes?
Why 3 pressure sensors?
And by gas measurement, what do you mean?
What do you measure with the on off switch?
I need to understand the installation a bit.

Here is my advice, if you rely only on one analog level measurement.
If the reading is not required in real time and is also fine to be displayed each 10-15s, that means is not a very fast change in level/flow of the tank,  then to minimize the errors of readings you can do next:
-      You may read 16 times, each 0.5s.
-      Make the difference between each 2 following readings.
-      Then you sort the differences from lower to higher values.
-      Then  you get rid of the lowest 4 and highest 4.
-      With the remaining 8 you make and average and display it.
Then you get an update each 8-10s.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Cesar AracenaPHP EnthusiastAuthor Commented:
Thanks viki2000. Quite good solution to minimize random error reading from the sensor.

All those pressure measures are taken from different places before the tank, in a very high-pressure part of the process (up to 15.000 psi). After that part, the process (flow) goes thru a choke orifice and then into atmospheric pressure and then into the tank so the liquid in the vessel is not under pressure.

The gas sensor is a H2S gas fixed detector for safety and the on/off switch is a floating device placed at 80% of the total capacity of the vessel to warn the operator (in case he's distracted or the radar breaks down) so he can take action.

As I mentioned before, your solution is very good for minimizing errors and will try it but still I wonder if I could make a ramp using the level and then continuously calculate the flow rate? Would be nice to find out if it's possible and how to do it.

BTW, we are trying not to use actual flow meters because there's usually sand mixed with the flow and everything has a very high speed so anything I place inside the lines get eaten in just a few minutes. Magnetic or density could work but they're quite expensive and since I've already have a level measurement, we're trying to minimize costs.
0
viki2000Commented:
I am not so sure what do you mean by "but still I wonder if I could make a ramp using the level and then continuously calculate the flow rate" ?
Do you mean a slope of a line?
In other words you want to measure 2 times and to interpolate/calculate/estimate the points between those 2 measurements?
Something like this?:
https://en.wikipedia.org/wiki/Linear_interpolation

But how do you know if your process is linear or exponential or logarithmic or power or whatever?
If you know that based on a set of previous measurements and you estimate the curve type and you are satisfied with the precision of the equation which emulates your line/curve, then you can think at interpolation. If the process is slow changing, then you may use the model of linear interpolation and then you check the errors of approximation, standard deviation, accuracy.
Is this used to display a nice continuous line/curve on your display?
0
Cesar AracenaPHP EnthusiastAuthor Commented:
Sorry for the delay. Got carried to another project on the field.

This is almost exactly how I did it. Thanks!!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Miscellaneous

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.