We have a tank having petroleum product in it. There is a level transmitter whose value is coming in a PLC. The level is increasing or decreasing based on receipt or dispatch. We need to calculate flow as liter per minute or m3/hour from this level which is changing based on the operation.
what will be formulae for this which can be executed in PLC?
At least we need to know volume (V) and level of tank (l).
Assuming uniform area of tank, you can use formula max V / max l, to get volume per cm. For example. Now measure change of level, for example, every minute and you have Q in m3/min.
To calculation to work correctly, you can't fill and empty tank simultaneously.
I hope this is a school assignment because flow metering a valuable petroleum product without a flow meter is a silly idea.
Level is good for making volume based decisions like, "is there sufficient product to make the next batch" or is there "sufficient empty volume to accept a load of certain size". Level is a poor value to use in a flow rate calculation.
The problem with calculating flow rate from level is that it is a the calculation is a rate, a derivative function, dy/dt. A fixed time base is might be and is probably achieveable in a PLC so that the dt factor is a constant, but dy is an issue.
The problem with a using the change in level for a calculation is that most tanks of any size spread a given volume over a huge area to a very, very tiny depth. The charge or discharge rates generally do not create a useable change in level value with which to calculate a viable flow rate because those changes are very, very tiny changes in depth (level) which fall into the noise region of level-inferring instrumentation.
Given all that, the rate calc needs a holding register to hold the 'previous' level value, the ability to subtract, and a register to hold the difference between the previous value and the current value. Dividing the difference value by the time interval between previous and current samples gives you a rate, which can be normalized to seconds or minutes by a factor.
Don't be surprised if some readings appear to going in the wrong direction -filling rather than emptying - because noise is noise; some is positive, some is negative. and you're subtracting noise from noise.
If this is real, not school work, give serious consideration to a flow meter.
As others have said a flow meter, I would think a coreolis meter should be able to read center zero and integrate in both directions.
I would also recommend using a Flow meter since any calculation will, in time, be subject to cumulative errors. The advantage of real time flow monitoring is error is instantaneous. There are several outstanding Coriolis meters on the market one which is our CoriolisMaster product. You should investigate this device.