Non-linear level measurements

Varri

Member
Join Date
Jan 2020
Location
South
Posts
30
Greetings!

I have a assignment where i have to solve a non-linear level measurement with the use of trend line. I have a tank table showing liters on different levels.

The level is close to linear up to about half the tank, then it flats out more and more. I was not able to make a 2nd polynomial scaling that worked in all of the curve.

If i split the table in two on the middle, and run a polynomial trend line of the two halves seperatly i got something that worked on the entire tank. Minus the very lowest and highest points (doesnt matter, filter that out)

If tank level is below half, run the ladder formula with first set of coefficients and constant, if over half run the second set in the ladder formula.

Is this a efficient solution or am i overthinking this? Whats your best practice for non-linear scaling?
 
Im using a basic ladder program, no function or function blocks like that. I have to write all the calculations..
 
do as L D[AR2,P#0.0] says


say 10% = 7mA and 15% = 8ma


If analog input = 7mA then level =10%
If analog input = 8mA then level =15%


If analog input >7 and < 8 then divide the amount between 7 and 8 into the amount between 10 and 15
 
Many years ago we had a similar problem, the vessel was non linear i.e. a cone from bottom to half way up we created a table and split it into 100 segments, each segment in the table contained the diameter of the vessel, from that we could calculate the volume of each segment and add them up.
It will depend if the vessel is round or square though.
 
Is this a efficient solution or am i overthinking this? Whats your best practice for non-linear scaling?


Greetings in return!


Maybe this is overthinking, but unless there is a lookup table instruction (e.g. FGEN in Logix 5000 for ST or FB), then any solution is going to go through these steps something like this.



I assume there a single level measured value, and there is a break point in level between the two polynomials. That single measured value needs to be broken into two values, either

  • the single level value between 0 and the break point for the first polynomial and 0 for the second polynomial, when the single value is at or below the break point,
  • OR
  • the break point for the first polynomial, and [the single value minus the break point] for the second polynomial, when the single value is above the break point.
Then pass each of the two values as the independent argument to each polynomial to evaluate the volume in each section, then add the volumes.

The lookup table approach will do more or less the same thing, although it is using linear interpolation between the pre-computed volumes of two of several break points; it will end up spending more code and CPU finding which two break points to use, and less code and CPU interpolating, so efficiency is probably a wash.


The most important thing to do is to document clearly whichever path is taken. In fact, I would probably code it both ways, and choose the method for which the comments and code were the most easily understood.


That said, from the OP it appears that the volumes at individual levels are already available, so transcribing those into a lookup table algorithm is the quickest solution in terms of programming time; that argues that the polynomial approach is indeed overthinking. It's also easier to test.



One thing I will mention is that, in the case of a conical top above a prism bottom, where any horizontal cross-section of the top conical section is congruent that of the bottom prism, the top volume polynomial will be cubic in level, regardless of the shape of the horizontal cross-section.
 
It is disheartening to see that this thread has followed a profession and appropriate set of replies.

So, now I need to know if there is a cat on top of the vessel, and if the vessel is next to railroad tracks, and if when a train goes by the cats mate is on the train.
 
It is disheartening to see that this thread has followed a profession and appropriate set of replies.
I don't see the point you are trying to make.


So, now I need to know if there is a cat on top of the vessel, and if the vessel is next to railroad tracks, and if when a train goes by the cats mate is on the train.
Not very useful. You can't hear the cats growling, howling and screeching as the train goes by.



However, it would be good to know the surface area of the vessel at each level if doing level control. The gains change as a function of the level.
 
However, it would be good to know the surface area of the vessel at each level if doing level control. The gains change as a function of the level.


That is available as dV/dh, which is a corollary of either the lookup table method (numerical) or the polynomial method (analytical).
 
I would calculate the volume as a function of height in Excel. Graph it and generate a polynomial equation, and use that poly equation in the plc.
 
OP did a polynomial, and did not think the results were good enough; maybe it needs more coefficients. Perhaps a Chebyshev approach would be better; I suspect the level vs. volume plot is not too far off a sine curve.
 
I would calculate the volume as a function of height in Excel. Graph it and generate a polynomial equation, and use that poly equation in the plc.

+1

For complex functions you generally need to use at least third order equations. The closer R2 is to 1 the more accurate the equation. I generally format the trend equation results in scientific notation and go out to at least five decimal places.
 
L D[AR2,P#0.0] is the best/easiest solution so far.
The OP's PLC probably isn't very sophisticated so simple algorithms are are probably best.



Third order polynomials can have two inflection points. Third order polynomials must be used with care. I would not try to fit one third order polynomial to the whole range.


When provided an accurate table of volume vs level, trying to fit a polynomial to the data is simply wrong because at the polynomial and the table will not match at levels where the volume is known. Using a table and linear interpolation between the points will at least be accurate at the levels where the levels are known.


There is a big difference between doing some sort of regression and interpolation with good data.


I would use third order interpolation between the middle two of four points but that is probably too difficult to implement on a simple PLC.
 

Similar Topics

Hello, I am seeing an issue with inaccurate tank level. It is an elliptical bottom tank with an Anderson Level sensor mounted on the bottom of...
Replies
20
Views
7,462
Hi All, Has anyone any experience in controlling a non linear valve with a PID? Traditionally this valve is controlled on flow but would like to...
Replies
36
Views
10,999
Hi guys and gals I have a severely non linear system that i am trying to develop a controller for. The non linear curve can be broken down...
Replies
8
Views
2,675
Hi, i have a pressure sensor (range 0-10 bar) and its output is 0-20 ma. but the current vs pressure curve is non linear such as. pressure...
Replies
3
Views
2,047
Hi all! I don't get a chance to get on this very often but I know this is a great resource for getting answers. Does anyone know where i can...
Replies
14
Views
3,874
Back
Top Bottom