Go Down

### Topic: Water level sensor w/ nichrome wire no, now capacitive (Read 31438 times)previous topic - next topic

#15
##### Sep 08, 2011, 04:36 pm
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?

#### dc42

#16
##### Sep 08, 2011, 06:18 pmLast Edit: Oct 12, 2012, 11:16 pm by dc42 Reason: 1
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:

Code: [Select]
`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.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### Grumpy_Mike

#17
##### Sep 08, 2011, 06:22 pm
Quote
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.

#### dc42

#18
##### Sep 08, 2011, 06:24 pm

Quote
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.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### dc42

#19
##### Sep 08, 2011, 06:49 pm
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.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### TenderLoins

#20
##### Sep 09, 2011, 09:11 am

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

- 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

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

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

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.

#### TenderLoins

#21
##### Sep 09, 2011, 10:17 am
Here is a terrible Paint image of what it will (hopefully) end up looking like:

#### dc42

#22
##### Sep 09, 2011, 10:21 am

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

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

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

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.

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.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### TenderLoins

#23
##### Sep 09, 2011, 01:32 pm

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

#### dc42

#24
##### Sep 09, 2011, 02:24 pmLast Edit: Sep 09, 2011, 02:27 pm by dc42 Reason: 1
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).
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### dc42

#25
##### Sep 09, 2011, 02:31 pm
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.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### TenderLoins

#26
##### Sep 09, 2011, 03:15 pmLast Edit: Sep 09, 2011, 03:17 pm by TenderLoins Reason: 1
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.

#### TenderLoins

#27
##### Sep 09, 2011, 07:15 pm
Gah, I just bought another Mega instead, much easier (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.

#### trancen

#28
##### Sep 09, 2011, 07:18 pm
Here are somethings I have found, I was trying to work on such a project awhile back.

http://www.instructables.com/id/Building-a-Capacitive-Liquid-Sensor/

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"
http://www.newprovidencemarine.com/product_sensor.html

#### trancen

#29
##### Sep 09, 2011, 07:35 pmLast Edit: Sep 09, 2011, 08:30 pm by trancen Reason: 1
Something I just happent to come across now,