Ultrasound liquid level sensor

Discussion in 'The Projects Forum' started by geoffers, Nov 3, 2012.

  1. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi all,
    I'm after a bit of advise on a fairly unique (I think!) problem. I'm in the middle of trying to make a feeder for small calves, the calves are identified by a rfid tag in their ear, I want to let them have a litre of milk every 6 or so hours. The milk needs to be warm really so I've made a 'warmer' using plastic waste pipe (38mm id) inside 6" waste pipe which forms a water jacket around the small waste pipe, the water is heated and when small pipe is filled with milk, the milk gets warmed. I need to know how much milk each calf has drunk so it needs to be meterd in and out. My first thought was to use a load cell and wiegh the whole thing, I've used load cells before so have a circuit ready designed. However load cells are quite expensive (£120 ish for a good one) I got a cheap half bridge cell from sparkfun, found two resistors of the right value and a INA122 but it doesn't seem accurate enough for my purpose? A ultrasound tranducer is my next thought, does anyone know if a transducer will work in a tube? As I said before its 38mm id, and 80cm long, will ultrasound work or will it bounce off the walls of the tube? The milk will be pumped in so a pressure sensor in the bottom wouldn't work for filling and it needs to be easy to clean! I'm using a 18f2523 as the brain so have a/d, serial comm and I2C avalible and work like to use the minimum number of I/O as I also have soleniods and a pump to control. Hope thats not to rambling?
    Cheers Geoff
     
  2. crutschow

    Expert

    Mar 14, 2008
    13,028
    3,237
    I don't quite understand how you want to measure this. :confused: If the milk is pumped in under pressure how do you determine how much is consumed by the calf? Isn't the tube always full?
     
  3. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Sorry, I might not have been clear enough, the tube holds 1 litre, when a calve starts to feed I want it to have 1 litre maximum. If it decides half way through it wants to stop, I want to be able to record how much its had, so if it comes back again it can have the rest and more importantly it can be flagged up if it doesn't have its full amount (first sign of a sick calf is a drop in intake) When its left I want the tube to fill to 1 litre again. More than one calf will have access to the feeder. I cant have much more than that warm at one time as it soon goes off!
    Thanks Geoff
     
  4. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    You'll need a narrow beam transducer. Sound will hit the walls but will take a longer reflection path than the direct path to the transducer so that in itself won't be a problem. Any ridges or edges in the sound path WILL so make the inside smooth.

    Expect lots of secondary echos in the tube after the first reflection and space the pings out enough to let them die out. After 3-5 trips back and forth, the signal should be attenuated enough to not be an issue.

    For reliable echo ranging, ping many times and average the result. Your firmware should have an idea what a good range is and throw out any out of range ones. For example, you could miss the first echo but pick up a secondary one making the range 2X all of a sudden. Throw that one out.

    Ranging liquids that can slosh around can generate null reflections if the wave crest to trough distance is an odd multiple of the sound wavelength in the air. That's why many pings/range reading will be necessary. Picking an appropriate sound frequency can help here.

    Note that the speed of sound in air is very temperature sensitive. You should calibrate the ranging for the expected temperature and consider temperature compensating it.
     
    geoffers likes this.
  5. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,998
    745
  6. crutschow

    Expert

    Mar 14, 2008
    13,028
    3,237
    I like the liquid flow sensor such as Dodgydave suggested.

    A couple other ideas:

    Use a clear pipe or tube and an IR sensor(s).

    Connect the pipe with flexible hoses and weigh it.
     
  7. panic mode

    Senior Member

    Oct 10, 2011
    1,321
    304
    i am also in favour of a flow meter. if you still want to detect presence of milk inside a tube, you could also use capacitive proxy sensor. then tube does not need to be transparent.
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,447
    3,363
    Whoa! or should I say moo? This sounds like an udderly fascinating but intricate project.
    What happens if we overfeed or underfeed and kill your calf, or feed the wrong calf? Are we liable for giving you bad advice? Do you sue us all and milk us dry?
     
  9. Dodgydave

    Distinguished Member

    Jun 22, 2012
    4,998
    745
    No pull the "Udder one".....lol
     
  10. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi all,
    Thanks for all the input, I'm thinking the ultrasound maybe the way to go? I had a look at the flow meter on protopic after I posted, they seem a reasonable price? I can see a couple of problems though, firstly when a calf feeds its not a constant flow, more a series of pulses would this affect the flow meter accuracy? The other problem is the milk we feed calves is un homogenised I fear the vanes might get coated in fat fairly quickly? (I might be wrong on both points so please correct me if I am!).
    As I posted to start with my first idea was to weigh the whole unit, however I think I would need a expensive load cell to get enough accuracy? The cheap one I've got isn't quite stable enough. The capacitive level sensor is interesting, does anyone know off a cheap off the shelf item? Just a random thought, would co-ax cable work if it was sealed on the end? I've allready made my warmer so clear tube would mean remaking it and also the IR sensors would be immeresed in water. The tube is smooth inside so the ultrasound should work, the water jacket keeps a constant temp and as you said I know the min and max distance it could be. Mr chips?? Cheers that made me laugh, more water with it maybe?!:)
    Thanks again for all your ideas, any more thoughts welcome!
    Cheers Geoff
     
  11. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Ps, Mr chips, don't frett about killing or feeding the wrong calf, their all rfid tagged, I've soleniods to stop the milk!!
     
  12. MrChips

    Moderator

    Oct 2, 2009
    12,447
    3,363
    No bull, that is what I meant with the RFID tag. So we read the tag incorrectly and deny the calf milk or the udder way around, we give the milk to the wrong calf.
     
  13. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Good lord they get worse:)! I've been messing about with the rfid stuff for quite some time, the tags have 16bits of crc check in them, I've yet to have a missread, thats not to say it couldn't happen! Regarding the liquid level, I've just been farting about with some speaker wire and my tube, as the tube fills the capacitance changes from 100pF to 130pF, this maybe to basic but could I use a 555 timer in astable mode and measure the frequency change on a pin of my pic? I've yet to do the sums? Seems to good to be true so I guess it is...........
    Thanks Geoff
     
  14. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    You might try a capacitive level sensor like these. (I don't know anything about this particular manufacturer but the link is representative of what's out there).

    Awhile back on the forum someone posted a liquid level tape sensor.

    Both of these are in contact with the milk so there may be some cleaning challenges.

    If you are pumping with a peristaltic pump you can meter the quantity dispensed by counting the pump revs required to fill the tube to a simple fixed sensor and refill it after the animal leaves.

    EDIT: saw you are thinking capacitive as well while I was typing.. Wondering if the TMR1 oscillator on the PIC would work for this.. Its good to 50KHz any you get a built in CCP.
     
    Last edited: Nov 4, 2012
    geoffers likes this.
  15. MrChips

    Moderator

    Oct 2, 2009
    12,447
    3,363
    You're on to something there. Perfectly doable.
     
  16. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Hi all,
    Thanks for your input and cow related puns! I've just done some rough sums and would like to know what you think. I have my pic running at 4mhz, this means if I use tmr0 with no prescale I have a timer at 1x10-6s.

    If I use it as a 16 bit timer, I would like a pulse of roughly 1000 or 1x10-3s

    The data I have for a astable 555 says the low pulse is=0.693xr2xc1,
    Rearranging that gives me r2=t/(0.693xc1) (I hope?!).

    With c1 at around 100pF this means to get a low pulse of 1x10-3s I need r2 at 14.34Mohms, seems alot to me, will the 555 be stable at that high a resistance? May seem like a basic question but I don't have much experiance with 555's other than flashing a LED!
    Cheers Geoff
     
  17. crutschow

    Expert

    Mar 14, 2008
    13,028
    3,237
    Perhaps you could eliminate the 555 and just connect a resistor to V+ with the other end to the capacitor, and with the capacitor-resistor junction going to one of the PIC I/O pins. If you first drive the I/O low and then command in to an input state you can measure how long it takes to reach the logic high voltage. The time it takes would be determined by the value of the resistor and capacitor.

    14MΩ is high for a 555 and likely would be marginal for the PIC input (which does has a high impedance MOSFET input). I would go with no more than a few megaohms. This should still give you sufficient resolution for your purposes.
     
  18. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Thanks, thats a interesting idea, I had wondered if I could use the onboard comparitor to do a similar thing? I thought I would then need another i/o to discharge it. Thats a nice simple way of doing it though, I think I shall try that. I'll let you know how I get on.
    Cheers Geoff
     
  19. MrChips

    Moderator

    Oct 2, 2009
    12,447
    3,363
    I think the capacitor idea is worth trying. I have done this on a micro but I do not use decay time or a comparator. Instead I use the RC combo on an I/O pin and create a code loop to make the RC and pin oscillate. Then I count the number of cycles in a given time period.

    That is, I measure frequency instead of RC time constant.

    If you want to measure straight frequency on a counter input pin on a MCU, you could create an RC oscillator using CMOS gates.
     
  20. geoffers

    Thread Starter Active Member

    Oct 25, 2010
    239
    6
    Thanks, I take it you mean configre the pin as a output to drive it low, then as a input to see when the capacitor has charged, and so on but increment a file every time it cycles. For a given period then check the file to see what the frequency is? I can see advantages in either method, checking the frequency would give me a average and prevent any 'false' readings having too much effect. However as the capacitance increaces as the tube fills it seems simpler to start a timer when the i/o pin is changed to a input and read it when the input is set. Time would increase with capacitace so I would have less coding to do to get a understandable(usefull!) reading, but then if I want to average it over a few reading I lose that advantage?! Any thoughts?
    Thanks again Geoff
     
Loading...