Pages: 1 [2] 3 4   Go Down
Author Topic: Water level sensor w/ nichrome wire no, now capacitive  (Read 11134 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
   
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* 2011-09-08_16-29-15_453.jpg (473.3 KB, 1296x968 - viewed 208 times.)
« Last Edit: October 12, 2012, 04:16:18 pm by dc42 » Logged

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.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31541
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

United Kingdom
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

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

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 smiley

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 smiley

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

United Kingdom
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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 smiley

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

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.

United Kingdom
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
« Last Edit: September 09, 2011, 07:27:13 am by dc42 » Logged

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.

United Kingdom
Offline Offline
Tesla Member
***
Karma: 220
Posts: 6587
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

United Kingdom
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: September 09, 2011, 08:17:38 am by TenderLoins » Logged

United Kingdom
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Gah, I just bought another Mega instead, much easier smiley (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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: September 09, 2011, 01:30:23 pm by trancen » Logged

Pages: 1 [2] 3 4   Go Up
Jump to: