Capacitive water tank level determination

This forum is for posts that might be considered off-topic but that may be useful or interesting to members. Examples include posts about electronics or programming in general, other microcontrollers or interesting devices, useful websites, etc.
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

Capacitive water tank level determination

Post by twesthoff »

Did any of the experiments result in a larger capacitance?  10pf is very small...

On 8/21/2011 11:14 AM, General wrote:
spamiam wrote: ... Will RFI be an issue?

It might be. I won't be surprised if I see interference from VHF transmissions (this will be implemented on the boat; the VHF antenna is about 10 feet from either tank, and can radiate ~20Watts). It might be necessary to put a few small RF chokes in series with the electrode connections; we'll see.

My first stab at reading the capacitance will be simple, a '555 astable oscillator, placed right at the electrodes. Although 10pf is below the graph on the datasheet, 10pf (~empty) and 1meg extrapolates to ~50kHz; 100pf (~full) and 1meg should be ~5kHz. Measuring the period (or counting pulses in a fixed period and inverting) should produce a value that closely corresponds to depth.

GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

Yup, it is small but, so far, it appears to be stable. If the converting electronics are co-located, I don't think that's a problem.
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

I built a simple circuit on a piece of perfboard about an inch square and tested it with 11pF and 107pF capacitances and two 470k timing resistances.

A TLC555, a very-low-current version of the LM555 yields a ~121.3uS period (8.25kHz) with 107pF, and ~26.1uS (38.4kHz) with 11pF caps connected to the electrode terminals. With no cap and just stray capacitance, the circuit produces ~13.2uS (~75.4kHz) as built. Clearly, the near-empty period values won't be linear.

A liquid test tomorrow.
Attachments
DSCN1552a.JPG
DSCN1552a.JPG (78.8 KiB) Viewed 9462 times
TankLevel.GIF
(11.13 KiB) Downloaded 858 times
Tom
stevech
Posts: 715
Joined: 22 February 2006, 20:56 PM

Post by stevech »

temperature affects?
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

stevech wrote:... temperature?
The 555 is essentially immune to temperature changes; the stray-capacitance period was unchanged by a heat gun. The small disk caps, though, which won't be part of the final device, are very temperature sensitive. Heating a 100pF cap decreased the period about 10% quickly.
Tom
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

Capacitive water tank level determination

Post by twesthoff »

Curious to find out test results with hot and cold water, and fresh and salt water.

On 8/26/2011 8:56 AM, General wrote:
stevech wrote: ... temperature?

The 555 is essentially immune to temperature changes; the stray-capacitance period was unchanged by a heat gun. The small disk caps, though, which won't be part of the final device, are very temperature sensitive. Heating a 100pF cap decreased the period about 10% quickly.
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Re: Capacitive water tank level determination

Post by GTBecker »

twesthoff wrote:... hot and cold water, and fresh and salt water...
On the bench, I found that the '555 oscillation period doubled to ~26.2uS from the empty-terminal state when I put a ~12pF cap across them. That suggests that the empty-terminal stray capacitance in this circuit as built is ~12pF and corresponds to a period of ~13.2uS. To correct the capacitance measurement, then, it is necessary to subtract 13.2uS from the resulting period.

I tried a number of standard values that I had in the junk box (which I measured in a multimeter - of unknown accuracy - and used that value in the data below); the corrected results are satisfying:


[MeasuredC (standard) = period - correction = corrected (error)]

Empty-terminal ("0pF") uncorrected period = ~13.2uS

215pF (220) = 226.1 - 13.2 = 212.9uS (0.9% error)
152pF (150) = 165.4 - 13.2 = 152.2uS (-0.1%)
96pF (100) = 111.3 - 13.2 = 98.1uS (-2.1%)
46pF (47) = 61.2 - 13.2 = 48uS (-4.4%)
31pF (33) = 46.3 - 13.2 = 33.1uS (-6.7%)
22pF (22) = 36.1 - 13.2 = 22.9uS (-4.1%)
12pF (12) = 26.0 - 13.2 = 12.8uS (-6.7%)

These results are close enough for the purpose and are, I think, surprisingly accurate considering that these are small capacitance values.

I put 2"-wide tape on a new five-gallon bucket, this time in a wide V; this both allowed a little more tape to be applied and brought the connection points close together at the bottom for easy connection with clipleads.

The dry oscillation period was 24.6uS representing the correction for other values. Adding one gallon of tap water brought the period to 50.14uS; two, three and four gallons resulted in periods of 73.78, 95.72 and 115.15uS, respectively. Due to the construction of the bucket, the tape couldn't be applied to the top and ended just above the four-gallon depth, so I couldn't measure to five gallons. As above, correcting the periods by subtracting the dry value from each results in 0, 25.54, 49.18, 71.12 and 90.55uS for zero through four gallons. If four gallons is considered full, those values correspond to 0, 28%, 54%, 79% and 100%.

The bucket is not cylindrical; it is 9" ID at the bottom and 11.25" ID at the top. Consequently, the top gallon of water is less deep than the bottom gallon and therefore exposes less electrode tape area - if my math is correct, ~14% less area for the top (fifth) gallon, ~11% less for the fourth and so on. I suspect that explains the lesser change to the higher depths - which can be corrected exactly.

I added a great deal of common salt to the four gallons, bringing the TDS (dissolved solids and conductivity) from ~398ppm to >2000ppm, the maximum my tester can display; that is quite salty-tasting. There was no change in the resulting period. I cannot conveniently test with hot water but I don't see why that would change the results.

Quantifying these periods is easy to do in code and selecting, measuring and displaying several tanks is trivial. ZBasic is next.
Attachments
DSCN1553a.JPG
DSCN1553a.JPG (69.03 KiB) Viewed 9444 times
DSCN1554a.JPG
DSCN1554a.JPG (84.89 KiB) Viewed 9444 times
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

The code is off to a good start.

Code: Select all

	Option Strict On
	Option Language ZBasic 
	Option PortC "PPPPPPPP"

	Public Const Clock as single = 1.0 / 14.7456e6
	Public Const PinTank1 As Byte = 12		'ZX-24
	Public Const PinLED1 As Byte = 25
	Public Const PinLED2 As Byte = 26

	Public Const LED_On As Byte = 0
	Public Const LED_Off As Byte = 1

	Dim DisplayTaskStack(1 To 100) As Byte

	Dim Tank1Periods(1 to 2) as UnsignedInteger
	dim Tank1Period as single
	dim Tank1EmptyPeriod as single
	dim Tank1FullPeriod as single
	dim Tank1Level as single
	
Sub Main()
	Tank1EmptyPeriod = 24.5e-6
	Tank1FullPeriod = 90.5e-6
	
	CallTask DisplayTask, DisplayTaskStack	'start reporting results
	Do
		Call InputCaptureEx(PinTank1, Tank1Periods, UBound(Tank1Periods), 1)
		Tank1Period = Tank1Period + ((csng(Tank1Periods(1)) + csng(Tank1Periods(2))) * Clock - Tank1Period) * 0.01
		Tank1Level = (Tank1Period - Tank1EmptyPeriod) / Tank1FullPeriod * 100.0
	Loop
	
End Sub

Sub DisplayTask()
	do
		Call Putpin(PinLED1, LED_On)
		console.writeline("Tank 1 Period: " & fmt(1e6 * Tank1Period, 1) & "uS, " _
						& fmt(Tank1Level, 0) & "% ")
		Call Putpin(PinLED1, LED_Off)
		sleep(0.1)
	loop
End Sub
With a gallon of water (using the empty and full values of the bench test above), the console output is:

Code: Select all

Tank 1 Period: 49.6uS, 28% 
Tank 1 Period: 49.4uS, 28% 
Tank 1 Period: 49.6uS, 28% 
Attachments
DSCN1564a.JPG
DSCN1564a.JPG (69.88 KiB) Viewed 9403 times
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

Although I intend to have code calibrate one of the tanks (which is a complex irregular shape) by sampling values as the tank fills at a constant rate, the case of the simple bucket is actually an interesting non-obvious problem. The other tank is rectangular in the horizontal plane and wedged (a triangular section in the vertical plane) on the bottom, and is easier for code to solve.

A volume of water in a bucket is a conic section, a special one, called a frustum, I have learned - an inverted frustum since the conic base (the water surface) is at the top. Determining the volume from the slant height (essentially what the capacitance measures) is not a trivial problem.

Google led me to this, an interesting (if you enjoy math) expression that starts with a trick answer: http://mathcentral.uregina.ca/QQ/databa ... yati1.html
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

OK, Tom, I filled the bucket with "cold" water (a misnomer in Florida at 84.1F) and then with hot water (140F, as hot as is convenient). No significant change.
Tom
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

Capacitive water tank level determination

Post by twesthoff »

Thanks for the test.  I am trying to figure out what physical property is causing the capacitance change.  Most dielectrics are temperature dependent, so it must not be changing the dielectric properties.  So my other assumption was that the water was acting as a third plate with the two tape strips.  That may be true, but then I would expect fresh vs salt water to make a significant change and you said it didn't change it much. 

Did you ever try making the foil strips wider or using two sets of them in parallel?  If so what did that do?
I think you said that increasing the spacing between the strips didn't change it much when you made them a "V".  I'm really curious about what is making the capacitance change...
Tom W.

On 8/28/2011 10:04 PM, General wrote:
OK, Tom, I filled the bucket with "cold" water (a misnomer in Florida at 84.1F) and then with hot water (140F, as hot as is convenient). No significant change.

Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Re: Capacitive water tank level determination

Post by GTBecker »

twesthoff wrote:Did you ever try making the foil strips wider...?
Reviewing my posts above will refresh your memory.

I also just now adhered a wet sheet of paper towel, as I did earlier, on the inside of the bucket over the area of the external electrode tape, about half of the tape area. The code reported 71.9uS and 55%, about what it would if the water was that deep.

I heated the tape and the plastic under it with a heat gun to too-hot-to-touch - fortunately still below plastic damage. There was no change in the indicated period.

I believe the effective capacitor is obvious, two metallic tape "plates" separated by plastic and a body of water, effectively two caps in series interconnected by a conductive liquid. That the tape surfaces are parallel or co-planar or anything in between is irrelevant since the body of water, through the plastic walls, is always adjacent to the tape. Only deionized water or another non-conductive liquid like gasoline or clean oil might change this behavior. The water conductivity is vastly greater than the plastic conductivity, so it connects the two plates well. The dielectric is the plastic wall of the bucket.

I don't know why it appears to not be temperature-sensitive, at least at temperatures I've produced. Perhaps the material is worthy of further testing - like cutting out a large area, flattening and sandwiching it between foil or metal sheets - but that's beyond this project. It might also be that the plastic will behave differently at higher-frequency RF instead of audio/VLF.
Tom
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

Someone on a boating forum just posted a link to a commercial capacitive tank monitor. https://tankedge.com/products.html

That system also uses 2" aluminum tape on each exterior tank wall, connected to a small package that's connected to a display via three leads - surely power, ground and signal.
Tom
spamiam
Posts: 739
Joined: 13 November 2005, 6:39 AM

Post by spamiam »

[quote="GTBecker"]Someone on a boating forum just posted a link to a commercial capacitive tank monitor. https://tankedge.com/products.htmlquote]

Clearly you have had a great idea. I bet your custom hardware will work just about as well as the commercial stuff, and probably is easier to set up for an irregular tank shape.

I wonder if there is a limit to the tank size before noise/stray capacitance overwhelms the measurement signal?

-Tony
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

Post by GTBecker »

I am about to tape the actual tanks I want to measure. The freshwater, irregularly-shaped tank, while I expect difficult to get at, shouldn't change depth while in motion much on the surface I intend to use.

The waste water tank, however, is long and shallow, and is oriented lengthwise along the keel line. Under different attitudes (the boat bowrise will be somewhere between zero and 10 degrees, typically three to five degrees on plane while cruising) the water at any single point on the side of the tank will change significantly.

To reduce false level readings, I could measure the depth at both ends and average them - or, I'm thinking, tape the tank's entire length in a V, expecting that, as the stern end gets deeper the bow end gets shallower, so the effective area should be more constant than just one end measurement. Pythagoras will play a part as the tank is tipped (forming a triangle of side area) but the indication doesn't need to be precise, just adequate to avoid overloading.

Maybe that's over-thought, though. Maybe just measuring the mid-length depth will suffice.
Tom
Post Reply