Level Sensor for horizontal oval tank, table lookup

We have a large milk tank in the shape of a horizontal oval, We have no dip stick or sight glass so i'm building a level sensor but as it's not a uniform area through it's height i think i need a lookup table for the volume. Ideally i'd like to be able to read every cm of level change and it's a 170cm tall tank, so 170 rows.

I have the ultrasonic sensor working, including a web page for viewing the data, i will add an lcd too.

I've never done anything with tables before, so i'm looking at guidance here.

Many Thanks

Hello

You may place your tank on a scale.

It's a 10000l refrigerated tank.
It's not the measuring that is the problem, it is whether/how i can read a table between cm of distance and volume

I doubt you need a lookup table. A formula would probably suffice.

If you have the data, fit a curve though the points. Use Excel or any of a number of online calculators. Try a polynomial.

Or use math to determine the formula based on tank dimensions.

Google is your friend.

If the height of the tank is A , the width of the tank B , and the height of the elliptical segment h then the area of the segment is given by the equation:

area = (AB /4)[arccos(1 - 2h/A ) - (1 -  2h/A)sqrt(4h/A - 4h^2/ A^2)]

Use that directly, or use it to make a table, a big one or a smaller one and interpolate.

a7

1 Like

:confused:

The OP needs the volume formula...which is also in the linked page [*]

[*] edited to add the blindingly obvious... :wink:

From the same web page, as clearly stated in the web page title:

volume = (ABL/4)[arccos(1 - 2h/A) - (1 - 2h/A)sqrt(4h/A - 4h2/A2)]

Haha, exercise for the reader.

Careful cutting and pasting formulae:

 volume = (ABL /4)[arccos(1 - 2h/A ) - (1 - 2h/A )sqrt(4h/A - 4h^2/A^2)]

or

a7

1 Like

:grinning:

Now there's a nice response!

Thanks for the replies everyone, i have some test data from when the tanker empties the tank and has an accurate flow meter on board. Using the form linked above i've getting incorrect numbers, so my internal measurements must not be completely accurate, it's hard to measure, even with a laser distance finder.

This is why i was wondering about a lookup table. We can gather more data points every time the tanker empties the tank and we could even calibrate using our own flow meter and water on an empty day.

Maybe a stupid question, but did you mix up degrees and radians in your equations?

Are you talking to me? I have not used radians and degrees, i have merely put figures into the web form linked to above.
I think part of the problem is that the tank has a sloping base to make sure all liquid exits at a low point. So that will throw out the mathematics solution to the problem

There will still be a mathematical solution. But it will be more difficult.
How far is your measurement off from your calculations (lookup on the web)? If it is off by 20% it might be the slope, if it is off by a factor 10 you have other problems... wrong units?
What error would be acceptable?
What is the slope of your bottom?

I thought you had used the formula given above. And in that case it matters if you calculate in degrees or radians. Most calculators use degrees by default, Arduino uses radians by default.

Your lookup table is the practical solution, meanwhile you can work on a mathematical solution for your thesis.
With an analog input giving you values from 0-1023 spread across your 170 cm(i.e. 6 adc counts between cm increments), you should be able to come up with a number that's close to 1% accuracy despite the vagaries of reality(yes, 0.2 cm should be possible, but good luck chasing that rabbit). If that's not good enough, then you'll have to do a more careful fill-slowly in one cm increments, stopping to allow turbulence to settle for every measurement, which would be tedious to say the least.
C

1 Like

Hello greenbeast999

Have you ever thought of using a flow meter? According to Kirchhoff, what flows into the node must also flow out again.

Depending on type, flow meters are not that accurate...
And errors tend to accumulate...

It is a milk tank. Perhaps a flow meter would need to be sterilizable. For sure it must drain completely (which rules out the cheap water meters in your house).

We have a flow meter, both in the milking parlour and on the pasteuriser. And yes, we may be able to use these to calibrate a table/algorithm but no good on a daily basis. Because we bottle milk as well so milk comes out in small quantities as well as in twice a day. The pasteuriser will count all cleaning water and both types of milk we process (we have 2 tanks), so not super reliable

Look up arrays, you will need a 2 by 1024 array of ints. On a small Arduino, this won't fit in RAM, so you may need to use progmem q.v.

Why would you need 1024 ints?
A bit if interpolation and use of symmetry can reduce that to 512 ints...

I don't think symmetry helps as the tank has a somewhat complex shape, but in fact I see that the OP only wants 170 points anyway, which will fit even on an Uno.