Results 1 to 10 of 10

Thread: Touch input used as liquid level sensor

  1. #1
    Member
    Join Date
    Dec 2010
    Location
    usa: west of the mississippi
    Posts
    91

    Default Touch input used as liquid level sensor

    Howdy PicAxe community! Thanks for helping a newcomer with several problems. Here's a little payback that may be useful to someone.

    I've used a 18M2 as a liquid level sensor for a water tank. I posted this in Snippets because it isn't a complete solution, and it was only tested on a plastic gallon jug.

    I cut out two aluminum foil strips, 25mm wide and the same length as the height of a plastic jug. They were taped to the outside of the jug, about six mm apart. One foil was connected to 0V of the test board, and one foil was connected to input C.2 of the PicAxe. Port B had each of it's eight pins connected to an LED in series with a 330 ohm resistor that was, in turn, connected to the +5 supply.
    So, in summary, the only connections to the 18M2, besides the needed power supply, ground, and programming serial port connections, were a foil sensor on the jug, and eight LEDs. Quite simple.

    Here's the code:

    Code:
    ;                              USE TOUCH CONTROL FOR LIQUID LEVEL SENSING
    symbol maxrd = w1					;tank full reading
    symbol minrd = w2					;tank empty reading
    symbol del = w3						;range from empty to full
    symbol level = w0					;current sensor reading
    symbol test = w4					;reading for each 1/8 tank
    symbol cntr = b12					;counter for loop
    
    main:
    
    ; This portion requires tank to be full or tipped to cover sensor strips
    let dirsb = 255						;set all port B pins for output
    let pinsb = 255						;set all port B pins high to turn off LEDs
    pause 5000							;pause to allow getting tank to full condition
    touch16 [%00010001], c.2, maxrd		;get a reading at tank full condition
    low b.0								;blink that the reading has been taken
    pause 1000
    high b.0
    ;This portion requires tank to be empty or tipped to uncover sensor strips
    pause 5000							;pause to allow getting tank to empty condition
    touch16 [%00010001], c.2, minrd		;get a reading at tank empty condition
    low b.0								;blink that the reading has been taken
    pause 1000
    high b.0
    del = maxrd - minrd / 8				;calculate difference in eighths of tank capacity
    
    ;Now in the working part of the program
    lupe:
    touch16 [%00010001], c.2, level		;get current reading
    
    
    for cntr = b.0 to b.7				;light up leds to creat bar graph of current level
    	test = cntr * del + minrd		;this test level for each 1/8 of a tank assumes linear
    									;relationship of level and depth of fluid.  For some
    									;odd tank shapes, a different relationship could be 
    									;found
    	if level > test then low cntr	;if level is higher than a 1/8 tank increment, turn on led
    	else high cntr
    	endif
    next cntr
    
    goto lupe							;loop back to take a new reading
    end
    The first part of the routine is used to get the reading for a full jug. In my testing, I had the jug half full, and would tip it towards or away from the sensor foils to simulate a full jug, empty jug, or anywhere in between. So when the program starts, you have five seconds to tip the jug to indicate full, then another five seconds to tip the jub to empty. After that it starts lighting diodes to indicate the current level. Seems to work okay, but there are obvious improvements that could be made.

    I tweaked the setup of the touch command a little, but did not do extensive experimenting to see where it worked best. The whole setup is very sensitive to how wires are run, whether or not the computer is connected to the serial port, and what I was touching. In a real application, much of this would be fixed, but you will definitely need to calibrate after all is settled. EEPROM would be the place to store the calibration settings, but I didn't bother because this was just an academic exercise. (It's nice being retired)

    I think that for tanks that are not of linear proportions, it might be possible to shape the tin foil strips to account for needing more capacitance or less, but this is another area that I did not explore. It might be easier to leave the electrodes linear, and experimentally obtain constants that could be tested against a current reading.

    Have fun picaxing,
    tom

  2. #2
    Senior Member
    Join Date
    Feb 2010
    Location
    Don't Mess With My Texas!
    Posts
    882

    Default

    This is intriguing research. Nice job!

    I may someday transfer your work towards a large tank problem that I have. However, it's quite difficult to tip a 500 gallon tank to get the level changes you were able to work with.

    I would be really interested in calibration procedures that tended to null out 'interfering' capacitance without having to use the liquid level to set level points. I can't see a way to do it that makes any sense, though.

    Perhaps this is really just wishing?

  3. #3
    Member
    Join Date
    Dec 2010
    Location
    usa: west of the mississippi
    Posts
    91

    Default

    I don't see how you could calibrate without doing some testing. I guess one way would be to run the tank low, then apply the strips to the tank, and use debug to watch the variable used to capture the output as you refill the tank.

    Since the geometry of the sensor strips, the wires leading to them, and the presence or absence of the serial cable all contribute, I'd think that having an lcd display on board so that you could see the results without having the computer hooked up would be best. My routine only does a two point calibration that assumes the tank volume is a linear function of depth. For the more or less square tank I experimented with, this is a reasonable assumption. A round, horizontal tank would be a whole different beast. If you had the luxury of time, you could probably linearize the results with goofy shaped plates, but I think a multipoint scheme with data taken while filling or emptying would be the most accurate.

    I don't have time for another few months, but later I want to try this on the plastic fuel cells in an aircraft. If I learn anything useful, I'll post further. Meanwhile, if more discussion results, I'll be happy to try to contribute.

    tom

  4. #4
    Moderator
    Join Date
    Mar 2008
    Location
    Western Australia
    Posts
    11,065

    Default

    Great research Tom

    Another field where such liquid level detection is often sought is the potable water and grey water/sullage tanks on recreational vehicles such as caravans and motor homes.

    Often these are relatively shallow - maybe only 200mm deep - but considerable area with the length dimension often 15 or more times the depth
    Last edited by westaust55; 15-01-2011 at 23:53.
    westaust55

    Hey Hamlet, 2B OR NOT 2B = $FF

  5. #5
    Member
    Join Date
    Dec 2010
    Location
    usa: west of the mississippi
    Posts
    91

    Default

    Quote Originally Posted by westaust55 View Post
    Great research Tom

    Another field where such liquid level detection is often sought isgrey water/sullage tanks on recreational vehicles such as caravans and motor homes.
    That's definitely a place where I would place high value on 'non-contact'!
    tom

  6. #6
    New Member
    Join Date
    Dec 2011
    Location
    United States
    Posts
    22

    Default

    I'm Curious about whether the "Touch Control" could be used to measure Relative Humidity with the HS1101 R.H. Sensor??? Just a thought?

  7. #7
    Moderator
    Join Date
    Jan 1970
    Location
    Middle England
    Posts
    5,954
    Blog Entries
    1

    Default

    @rkj
    Welcome to the Forum.

    It might be safer to re-register under a neutral name.

    Your present Forum name may
    invite the Spambots.

    One of the moderators can then delete
    your post above.

    e

  8. #8
    Member
    Join Date
    Dec 2010
    Location
    usa: west of the mississippi
    Posts
    91

    Default

    Quote Originally Posted by rkjohnsonsr@gmail.com View Post
    I'm Curious about whether the "Touch Control" could be used to measure Relative Humidity with the HS1101 R.H. Sensor??? Just a thought?
    That's a great idea! I forgot that many humidity sensors are capacitive in nature. I bet they could be used, perhaps with some time spent on the tuning parameters. Unfortunately, humidity is a tough one to simulate. In the case of my application, liquid level, I could just tip the tank to cover or uncover the sensor elements to simulate the level changing. I'm not sure what to do for humidity, except to note that the normal daily relative humidity changes with temperature, so it is lowest in the warmest part of the day, and reaches a maximum at the lowest temperature time of the day. Instead of getting a cycle in a few seconds, from low to high, you would only get a once per day excursion.

    Best luck with your investigation. Be sure to share what you find.

    tom

  9. #9

    Default

    I used touch sensing module inside pic16f707 to measure capacitance of very different values. Even as small as few fF (yes it is femtofarad ) it is one superb piece of hardware
    i wrote about it in this topic :
    http://www.picaxeforum.co.uk/showthr...7-touch-button!
    and at the bottom of post i even gave link where you can download complete source code with detailed explanation of its operation
    good luck

  10. #10

    Default

    hmmm...are you searching the whole forum for old touch-related threads and posting this same stuff on every one? I think that might get a bit boring....

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •