Water level sensor w/ nichrome wire no, now capacitive

Grumpy_Mike:

I'm not aware of anything you can buy,

Try:-
http://uk.farnell.com/capacitive

Those are capacitive proximity switches, not liquid level sensors. OTOH there are some liquid level sensors at http://uk.farnell.com/level - but all the ones I looked at are for sensing whether the liquid is above or below a certain level, not for measuring the level.

Wow, thanks dc42 :slight_smile:

I'm gonna lurk around ebay and hopefully grab some aluminium tube or copper pipe for the outer section (S) in your drawing, and find some thin-ish rod (2-3mm diameter) and coat it with some kind of paint for (R) as you said.

I think the hardest part will be keeping the middle rod in the middle of the tube, as I can't use a washer or anything in the middle of the tube (it would stop the water running up the tube). I'm thinking that it'll be held at the top by a rubber grommet with small holes drilled in it, effectively slowing the filling and emptying of the sensor smoothing out the readings slightly.

The water will be nasty canal water (any large bits will be filtered by the pumps) so there will be gunk in it (read: not just water). I guess I'll have to calibrate the sensors on the day they are to be used.

Thanks again guys, I'll post a tutorial if I get this working :slight_smile:

TenderLoins:
I think the hardest part will be keeping the middle rod in the middle of the tube, as I can't use a washer or anything in the middle of the tube (it would stop the water running up the tube). I'm thinking that it'll be held at the top by a rubber grommet with small holes drilled in it, effectively slowing the filling and emptying of the sensor smoothing out the readings slightly.

You could use plastic washers in the middle of the tube and drill holes in them (or just cut the corners out) to let the water through. Or you could drill holes in the outer tube, or even have a slot running along its length. If the water is conductive enough, you might get away with replacing the outer tube by a second, un-insulated rod parallel to the first.

However you do it, I suggest making it removable so you can clean it if it gets clogged up or algae growing on it. I recall that the British navy used to copper-bottom its ships to prevent stuff growing on them, so a copper tube sounds like a good idea.

Excellent ideas.

Just to clarify your drawing, I found this on Wiki:

I'll google around for more information on it and how to use it.

Sounds like a really interesting project, twenty questions;

  • How deep do you intend to go ?

  • Will you be pressurising the compartment containing the electronics or will it be sealed it so that it remains at 1 atmosphere?

  • How many balast tanks are there?

  • You want to measure the level at both ends of the tank, does this mean the tanks are normally horizontal then, as the ROV dives,
    they tilt so the water level in one end becomes shallow and the other deep?

  • What is the maximum dive angle?

  • Is what you are really interested in the volume of water in the tank?

  • Will the ROV be autonomous and how will you communicate with it?

I got sufficiently interested in this that I decided to try it out. I made the sensor by wrapping about 20 turns of insulated wire end-to-end over a piece of stripboard, loosely. I connected the copper strips together to form the ground electrode. This isn't ideal because it allows water to cling between the wire and the stripboard.

My 555 circuit used the sensor as timing capacitor (pins 2/6 to ground), a 100k resistor between pins 2/6 and 7, and a 1M resistor between pin 7 and Vcc. I connected the output pin 3 of the 555 to pin 2 of my Arduino Uno so that I could attach interrupt 0 to it.

Here is the sketch I used:

volatile unsigned long count;

void setup()
{
  pinMode(2, INPUT);
  attachInterrupt(0, isr, RISING);
  Serial.begin(9600);
}

void isr()
{
  ++count;
}

void loop()
{
  noInterrupts();
  count = 0;
  interrupts();
  delay(1000);
  noInterrupts();
  unsigned long freq = count;
  interrupts();
  Serial.print(freq);
  Serial.write(' ');  
  float interval = 1000.0/(float)freq;
  Serial.print(interval, 4);
  Serial.write(' ');  
  float level = (interval - 0.1200)/(0.9025 - 0.1200);
  Serial.println(level);
}

The first value sent to the serial port is the frequency in Hz, the second is the interval in ms, and the third is the water level. The figures 0.1200 and 0.9025 in the calculation are the intervals I recorded with the sensor out of the water (but still a bit wet) and fully immersed, respectively.

It works! The level displayed goes from 0.0 when the sensor is out of the water to 1.0 when fully immersed, linearly as far as I can tell. The only snag is that with the sensor out of the water, the reading can be a little higher than 0.0 or slightly negative, depending on how much water is clinging between the wires and the board at the bottom of the sensor. When building your sensor, I suggest making sure that the wires or insulated rod are separated from other things (particularly the ground electrode), to prevent water clinging to them. Using water-repellent insulation (PTFE?) might also help.

It works!

For the moment, there is still the problem that the electrodes have DC across them and so will tend to generate electrolysis which will affect the capacitance. So in about a month it will probably not work or at best need recalibrating or cleaning.

Grumpy_Mike:

It works!

For the moment, there is still the problem that the electrodes have DC across them and so will tend to generate electrolysis which will affect the capacitance. So in about a month it will probably not work or at best need recalibrating or cleaning.

The non-ground electrode is insulated from the water, therefore there is no DC current and no electrolysis.

I tried dumping a load of salt in the water to see if the conductivity of the water had any effect. It didn't. Then I tried using hot water. This had a very marked effect: the 'level' now reads 1.42 when the sensor is fully immersed! Somehow the capacitance is increased when the sensor is hot. So the sensor needs to be temperature-compensated, unless you can build one that is it less sensitive to temperature.

radman:
Sounds like a really interesting project, twenty questions;

  • How deep do you intend to go ?

  • Will you be pressurising the compartment containing the electronics or will it be sealed it so that it remains at 1 atmosphere?

  • How many balast tanks are there?

  • You want to measure the level at both ends of the tank, does this mean the tanks are normally horizontal then, as the ROV dives,
    they tilt so the water level in one end becomes shallow and the other deep?

  • What is the maximum dive angle?

  • Is what you are really interested in the volume of water in the tank?

  • Will the ROV be autonomous and how will you communicate with it?

Just woke up, so excuse any typos :slight_smile:

  • I guess about 10m at best, that will be the length of the snorkel anyway. The snorkel will carry the network cable, and a tube for air which the bilge pumps will use to empty the ballast tanks (plus a rope if everything goes wrong :))
  • The center section where the electronics will go will basically be an up-turned tray (made out of clear, 10mm acrylic), and then sealed on the bottom.The bottom access panel, if it fell off or similar the water wouldn't just rush in as an air bubble is trapped.
  • There will be two 1m long 110mm diameter drain pipe ballast tanks on either side of this contraption. There will be baffle plates and other trickery to keep them filling equally.
  • The idea is for this thing not to tilt. It should just go up-down, rotate left and right and go forward/backward. The two sensors per tank are to give a reading if it is tilting.
  • There isn't one, see above.
  • The size of the tank is arbitrary, I just need to know when its full/empty and the amount of water at each end.
  • The ROV will have a MEGA sat in there with an ethernet shield on the top. It will be fed with a network cable, that's had half of its wires redirected to carry S-Video from the camera at the front of this thing. The battery will be in the ROV itself. On the surface, another box splits the network cable to a S-Video port and then standard RJ45 to a PC. Using a wireless USB dongle, I can connect a Xbox controller to it, and use OSC to send commands. Its kinda cool :slight_smile:

I know there are MUCH easier ways of going up and down in water than ballast tanks, but this is an experiment and a bit of fun. I didn't want to just follow tutorials on the internet on how to make an ROV, but try a different way.

DC42, thanks for your testing. I'll get some 555 sent immediately and do some testing myself :slight_smile:

In regards to electrolysis, this needs to last a month or so, with about 48 hours in the water, so it shouldn't be a problem. Cheers for letting me know though :slight_smile:

The temperature will probably be an issue as the water at the surface will be warmer than even 2 meters down. I'll have to do some testing.

Here is a terrible Paint image of what it will (hopefully) end up looking like:

TenderLoins:
DC42, thanks for your testing. I'll get some 555 sent immediately and do some testing myself :slight_smile:

Don't forget to get the CMOS version - they are more stable with the large values of timing resistor used in this setup. You can get dual 555s (often called 556s).

TenderLoins:
In regards to electrolysis, this needs to last a month or so, with about 48 hours in the water, so it shouldn't be a problem. Cheers for letting me know though :slight_smile:

Like I said, there won't be any electrolysis because there is no DC flow between the electrodes unless you have a hole in the insulation - btw even a small hole will stop the timer working.

TenderLoins:
The temperature will probably be an issue as the water at the surface will be warmer than even 2 meters down. I'll have to do some testing.

I think that the PVC that forms the insulation in my quick and dirty sensor isn't the ideal material to use over a range of temperatures, and you will be able to find something better.

dc42:
void loop()
{
noInterrupts();
count = 0;
interrupts();
delay(1000);
noInterrupts();
unsigned long freq = count;
** interrupts();**
Serial.print(freq);
Serial.write(' ');
float interval = 1000.0/(float)freq;
Serial.print(interval, 4);
Serial.write(' ');
float level = (interval - 0.1200)/(0.9025 - 0.1200);
Serial.println(level);
}

As far as I understand, you turn off interupts whilst you're setting the variables back to 0, turn them on for a second (delay(1000)), switch them off. This 1 second snapshot will be the number of pulses per second, or Hz. I don't understand why you turn the interupts back on after getting your freq variable? Is there a purpose? Seems like it is adding to a counter that is just about to be wiped to 0.

I've also got the issue of this taking 1 second every loop. As I'm streaming OSC commands to change direction, fill tanks etc, the 1 second delay every loop is going to make that unworkable. I'll need 4 interupt inputs, which means I'll have to use the Mega and use a UNO with the Ethernet board controlling the motors and using Wire or similar to communicate with the Mega. Ugh.

Or, as I've just thought, I use the UNO and its one interupt to cycle through the 4 sensors by connecting the 4 OUT's of the 555's to 4 transistors and route each OUT when its needed. Or indeed, use both its inputs and have it take 2 seconds to read all four sensors. Hmmm. If the Mega then just asks the UNO for the current state of the reading, which wouldn't change until another reading, I would have a fairly quick reading method.

I purchased some CMOS 555's as you described and I'll have a little play with them this weekend if they arrive tomorrow (fingers-crossed).

The reason for disabling interrupts when reading/writing the counter is that reading and updating a 32-bit variable is not an atomic operation on an 8-bit processor.

When disabling interrupts, they should be left disabled for the minimum time. It's not only the interrupt we are using that gets disables, but also the one that does the timekeeping. If we don't re-enable interrupts, the delay() call won't work.

Re using only 1 interrupt, I suggest multiplexing the 4 outputs from the 555 timers into 1 input pin, and reading the levels one at a time. You will need 2 output pins to control the multiplexer, so 3 pins in all. A multiplexer such as the 4051, 4512 or 4539 should do (the 4051 is actually an analog multiplexer but will work with digital signals).

It just occurred to me that you could try using an analog multiplexer such as the 4051 to connect the 4 sensors to a single 555 timer circuit - although this means you'll have to run the sensitive sensor wires back to a common point, rather than locate the each timer circuit close to its sensor.

Just because I have the transistors and its easier for me to understand, wouldn't this work:

The 555 chips are just the output of the chip, I haven't wired it up. I've also been a bit fast and loose with how to use a breadboard, but hey.

In my understanding, the above circuit would read the first two 555's if pin 3 was HIGH, and the second 2 if pin 2 was HIGH.

Is this correct?

EDIT: Thanks for explaining why to leave the interupts on, makes sense now.

Gah, I just bought another Mega instead, much easier :slight_smile: (only £20 off ebay, brand new). No multiplexer or trickery, plus I'll have quicker results from my sensors.

I was doing some tests between my UNO and current Mega, and the Wire library allows me to communicate between the two perfectly.

My UNO is acting a little odd though, I have a 12v regulator of a SLA 12v battery. It gives me a nice solid 12v output, and when both the Mega and UNO are plugged in, both with the barebone sketch installed, the 5v regulator of the UNO gets HOT, even with a little RAM heatsink on the top, while the Mega sits there all nice and cool.

The UNO also seems to have dodgy analog in ports, I think I've damaged them some how. Either way, the UNO will now be my development board (where if I accidentally shoot 50A through it, I've learnt a lesson without losing something critical).

I've started compiling pictures of my build process. I'm using TV coxial cable, which has a solid 1mm copper core, with a honeycomb plastic cover, and braided copper over the top with a nice thick insulation layer. I've stripped the braiding off for about 110mm (the length of the probe) and hot-glue gunned the end so its a sealed unit. Then this will be slipped inside a 10mm copper pipe, with a cut along the length (so its not a full circle anymore). The middle coax section will be held in the center with rubber gommets that I've ordered. My only worries are that the coax honeycomb is too thick for good readings. Gotta wait till my 555's and the other bits and pieces arrive before I'm sure.

Here are somethings I have found, I was trying to work on such a project awhile back.

Does anyone have a idea what sensor this is with the 5 wires?
http://www.newprovidencemarine.com/PDF/Sensor_Foil.PDF

See "Non-Contact Level Sensors"

Something I just happent to come across now,

http://www.zbasic.net/forum/about1562.html?pc_tzo=-14400&pc_d=20110909&pc_t=48525

Perfect for us Arduino folk.
http://soulysolar.mudventions.com/?p=681

Hmmm. Good links, thanks for that.

My problem is that the tank itself is also submerged, and I'm not sure how that will affect the readings. I'll give them a go if dc42's idea doesn't pan out.