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.
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.
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.
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
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
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.