Attached Images
I think that your formula is too complicated.
It can be simplified if you divide your horizontal cylinder into two separate problems: (1)Level = 1/2 tank radius or less, and (2)Level Greater than 1 radius. These two levels can be easily computed separately at the proper times by using comparison limits.
(1)Level = 1 radius or less (half full or less):
Volume = Area x Length, where Area = R^2[cos^-1(R-h/R)], cos^-1= Inverse Cosine, R = constant Tank Radius, h = measured height of liquid.
(2)Level = Greater than 1 radius (more than half full):
Volume = Area x Length, where Area = R^2[PI-cos^-1(h-R/R)].
Using this formula, you will see that the max error (as liquid is added or removed from tank, waves are produced) will occur at liquid height = tank radius +/- 10%. You could apply your filter at that level only.
A programmed filter routine simply averages reading over some time period, or averages a New Reading with some sum of Old Readings. This will help to reduce errors caused by actual liquid level fluctuations (waves in tank), errors in level sensor, and electrical noise.
I think that your formula is too complicated.
It can be simplified if you divide your horizontal cylinder into two separate problems: (1)Level = 1/2 tank radius or less, and (2)Level Greater than 1 radius. These two levels can be easily computed separately at the proper times by using comparison limits.
(1)Level = 1 radius or less (half full or less):
Volume = Area x Length, where Area = R^2[cos^-1(R-h/R)], cos^-1= Inverse Cosine, R = constant Tank Radius, h = measured height of liquid.
(2)Level = Greater than 1 radius (more than half full):
Volume = Area x Length, where Area = R^2[PI-cos^-1(h-R/R)].
Using this formula, you will see that the max error (as liquid is added or removed from tank, waves are produced) will occur at liquid height = tank radius +/- 10%. You could apply your filter at that level only.
A programmed filter routine simply averages reading over some time period, or averages a New Reading with some sum of Old Readings. This will help to reduce errors caused by actual liquid level fluctuations (waves in tank), errors in level sensor, and electrical noise.
