asked on # 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!

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!

MiscellaneousProgramming

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.

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.

View this solution by signing up for a free trial.

Members can start a 7-Day free trial and enjoy unlimited access to the platform.

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.

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.

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?

Do you mean a slope of a line?

In other words you want to measure 2 times and to interpolate/calculate/esti

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?

Sorry for the delay. Got carried to another project on the field.

This is almost exactly how I did it. Thanks!!!

This is almost exactly how I did it. Thanks!!!

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.