The solution that is described below stems from a problem that a few friends and I were discussing at lunch one day in Boulder, Colorado. The question is: how do you measure the volume of liquid in a partially filled, irregularly shaped container, such as a motorcycle fuel tank? The rest of this article presents one way to solve this problem based on the ideal gas law.
Throughout this article the term "gas" is used in the chemistry sense, a substance in the gaseous phase (like air). The solution I thought of to the volume measurement problem was that the ideal gas law could be used to determine the volume by introducing a known additional volume of gas into a container and determining the resulting change in pressure, which would be proportional to the volume of gas in the container. The easy way to think of this is attempting to blow air into a small space vs. a large space, it will be much more difficult to blow air into the small space since the pressure increases more rapidly.
The ideal gas law is:
PV = nRT, where
P is pressure in Pascals
V is volume in cubic meters
n is the number of moles
R is the Boltzman constant (8.314 J·K−1·mol−1)
T is the Temperature expressed in Kelvin
To make this concrete, here is a table (spreadsheet) which calculates
what the change in pressure should be
for a 20 liter tank with the volume being adjusted with a piston which moves 5 ml of air:
Volume piston retracted (liters) | Pressure (hPa) | Volume piston extended (liters) | Pressure (hPa) | Difference (hPa) |
0.1 | 1013.27 | 0.095 | 1066.60 | 53.33 |
1 | 1013.27 | 0.995 | 1018.36 | 5.09 |
2 | 1013.27 | 1.995 | 1015.81 | 2.54 |
3 | 1013.27 | 2.995 | 1014.96 | 1.69 |
4 | 1013.27 | 3.995 | 1014.54 | 1.27 |
5 | 1013.27 | 4.995 | 1014.28 | 1.01 |
6 | 1013.27 | 5.995 | 1014.11 | 0.85 |
7 | 1013.27 | 6.995 | 1013.99 | 0.72 |
8 | 1013.27 | 7.995 | 1013.90 | 0.63 |
9 | 1013.27 | 8.995 | 1013.83 | 0.56 |
10 | 1013.27 | 9.995 | 1013.78 | 0.51 |
11 | 1013.27 | 10.995 | 1013.73 | 0.46 |
12 | 1013.27 | 11.995 | 1013.69 | 0.42 |
13 | 1013.27 | 12.995 | 1013.66 | 0.39 |
14 | 1013.27 | 13.995 | 1013.63 | 0.36 |
15 | 1013.27 | 14.995 | 1013.61 | 0.34 |
16 | 1013.27 | 15.995 | 1013.59 | 0.32 |
17 | 1013.27 | 16.995 | 1013.57 | 0.30 |
18 | 1013.27 | 17.995 | 1013.55 | 0.28 |
19 | 1013.27 | 18.995 | 1013.54 | 0.27 |
20 | 1013.27 | 19.995 | 1013.52 | 0.25 |
This table ignores the difference in behavior between air and an ideal gas (this difference is called fugacity).
To test whether it is in fact possible to measure changes in volume using a piston, I used a pressure sensor on a breakout board from Sparkfun (BMP085) and an Arduino Duemilanove. You also need a sketch to read the pressure sensor, of which there are many online. I just read the serial information using the IDE, since I wanted information about the current pressure and wasn't worried about the UI. You can get a sketch here: http://interactive-matter.eu/blog/2009/12/05/arduino-barometric-pressure-sensor-bmp085/
The apparatus was built as follows:
I used an Arizona Iced Tea container (96 ounces) and drilled 4 small holes into the cap, fed some
jumper wires through and then glued them in place. Also there is a larger hole for tubing that is
used to house the piston that adjusts the volume of the container.
The pressure sensor in place in the cap, which I then screwed back onto the jug.
This is a length of aluminum rod wrapped with Teflon tape. The rod plunges into the tubing to adjust
the effective volume of the container. The volume is the container itself plus the tubing up to the
plunger, so if the plunger moves in or out the volume changes.
The complete test apparatus with the serial port connected to my laptop. I ran several tests with different
volumes of water in the container.
The results in Pascal were:
Empty container:
From the results above, this approach works. My readings fluctuated, but I could reliably determine the approximate volume of fluid in the container. The largest source of errors when I was testing was water that wasn't equilibrated to room temperature. When using room temperature water, the readings were very consistent.
Computer vision
Artificial intelligence
Effecting the physical world