How to measure the amount of liquid water in a thin tube (like a syringe) - Page 1
Forum section: electronics / projects

author: drcubes
author_rank: Newbie
timestamp: June 18, 2020, 02:47:35 am
content: I'm trying to accurately measure the amount of liquid sugar water in a narrow tube. To give some background I am a biologist studying energetics and biomechanics in hummingbirds. In the past we have measured the amount of nectar a hummingbird drinks by filming a clear tube such as a syringe body or pipette with a camera and later reviewing the footage of hummingbirds drinking and recording where the meniscus of the fluid is on the tube (the tubes need the gradation markings).However, you might see how this is very time consuming as we get hundreds of "flower" visits per day and video analysis is a very tedious process. I am relatively proficient electrical engineer in that I have worked on many robotics projects and work (I was a mechanical engineer before switching to biology) but I am struggling to find good solutions to measuring the amount of liquid in the tubes. The goal is to accurately measure the amount of nectar (sugar water) drank per drinking session of a hummingbird to the nearest .01 milliliter but I'll take what I can get. A big plus would be if it would be a fast enough measurement that I could use the same sensing device as feedback for automatically refilling the tube with a peristaltic pump.Some current and past tests and approaches I have made:- IR led and IR transistor linear array along the length of the tube. The idea being that due to either the slightly different level of transparency of sugar water compared to air (and its snell index) that more IR light would pass through the air than the water and I would get a changing value as the nectar was drank (or filled back up). The results were lackluster as there was an extremely minimal change in reading the analog values of the transistors. I also tried a method where I shined IR light into the tube at different angles and had a single transistor at the back end (picture included) of the tube to measure the total IR light change, and although I got changing results the values were sinusoidal as the liquid was removed or added (not noise but actual values) and measurements were still not consistent enough.IR Device- Capacitive sensing: I wrapped a single layer of aluminum foil around the syringe body and soldered a wire to the aluminum. I then used the 2 pin capacitive touch sensor measurement method to measure the change in capacitance as the fluid level changes in the tube. This method has a lot of promise and I am still working with it but there are some major flaws. The values do change significantly enough to measure come changes but the baseline value jumps a lot. I realize I could keep re-zeroing the measurement through the day or so as the baseline changes but I worry about non-linear changes in the signal as well the difficulty of recalibrating where fluid level is in the tube compared to the measurement value. I have yet to try the built in 1 wire capacitive sensing method that some of my boards provide but I am working on this now.Capacitive Device- Linear CCD and line laser: I am waiting on my linear CCD (TCD1304DG CCD Linear Image Sensor) to arrive in the mail but I am attempting to shine the line laser through the clear tube with nectar (sugar water) in it and place the ccd on the opposite side so that I can measure the intensity of light going in to the other side. This is similar to some fancy devices already on the market that are currently way out of my research budget such as some of the Keyence laser edge sensor and through beam sensors. I have no results yet for this but I can update this post when those come in. Any suggestions on this method are welcome.- Digital scale: I have done very little on this front so far but I have a beam-shaped load cell with strain gauges on it and a strain gauge amplifier. No tests with this but my primary concerns are that the gauge will not have high enough resolution to detect the amount of liquid change from a single feeding. ( < 1 gram change per feeding event)In all I am looking for any suggestions for methods of measuring fluid in a narrow tube with accuracy, repeatability, and relatively quickly (although speed is the least important of the 3) and although my budget is not small I am not looking at big priced sensor products (soft cost cap of $200 just for sensor components).I am using some standard microcontroller boards such as the Adafruit ItsyBitsy M0 and an assortment of ESP32 dev boards for now but open to suggestions.

author: hendorog
author_rank: Super Contributor
timestamp: June 18, 2020, 03:08:07 am
content: Pressure sensor might work if the syringe is large enough diameter.The other option I can think of is an ultrasonic level sensor.Edit: Instead of a complex sensor to measure the amount consumed, perhaps you could use a single sensor of some sort to determine the fill point - and then calculate the volume dispensed from the pump cycles?

author: DaJMasta
author_rank: Super Contributor
timestamp: June 18, 2020, 03:31:06 am
content: Since it's sugar water.... could you use a food safe dye and then do it optically? You'd have to make sure dye was also safe for the birds, but I assume one of the commonly available ones would probably work well.I'm wondering if you could get crafty with this.... maybe use a chiller and look at the liquid level height with a thermal camera (works fine with just evaporative cooling in a normal glass, but could be challenging with a small enclosed tube).Maybe even by weight? Hang the tube on a sensitive scale, fill it, wait for a drink, measure again for the difference, refill. You'd probably need some very high integration times (or DSP filtering) to null out error from wind or whatnot, but it could be probably be made to work. It helps in this case that they don't land to feed! And if load cells aren't an option for sensitivity (nor force sensitive resistors or pressure sensors and a pneumatic suspension or something), you could also just for for a simple balance and a way to measure the deflection angle. A good balance scale can be very sensitive and repeatable.Maybe you can get your peristaltic pump to introduce periodic bubbles - say one every 10th of a mL - and then just monitor the flow of the bubbles (though I don't know if this would deter feeding at all). You'd probably have to go out of your way to keep the feeding tube level as well, which could be problematic.

author: phil from seattle
author_rank: Super Contributor
timestamp: June 18, 2020, 03:50:58 am
content: how wide is the tube? perhaps you could use ultrasonics to measure the level though noise would be a big issue.I know that in my feeder, there are bubbles as they draw down the nectar. You could detect the bubbles. Though it takes multiple feedings to generate one bubble.Or, you could measure the pressure in the tube. As they feed it will drop until it pulls some air into it. There is probably a model that relates pressure drop to amount of nectar taken.Still in all these, the changes are so small that you'll be fighting noise.

author: wilfred
author_rank: Super Contributor
timestamp: June 18, 2020, 04:07:37 am
content: How important is it to know with such precision how much each bird consumes each visit to the feed point?Could you achieve your aims with a count of feed sessions and divide that into the total fluid consumed and work with the average. I am assuming a humming bird just takes what each flower has to offer until it is percieved easier to move to the next flower. ie the quantity consumed is a function of nectar available and not the nectar the bird requires. But then I'm not studying the feeding habits of Hummingbirds.It might be easier to count feeds and just measure fluid consumed from the resevoir once per day. You'd have to find another way to ensure "nectar" is always available though. That may be a simpler problem.Admittedly without complete understanding of your aims I am thinking of an approach where you deliver nectar via capilliary action to the feed point and control the resevoir level to control the flow to the feed point. Do you just have to present a droplet at the feed point? It might be easier to sense the formation of the droplet. Or maybe drop a bead into the resevoir to raise the fluid level the same amount as the drop the bird just consumed and hence force another droplet to form.I'm just trying to turn the problem around to achieve what I think might be easier to solve and more reliable and cheaper. But I also don't know what you're ultimate aims are.

author: drcubes
author_rank: Newbie
timestamp: June 18, 2020, 04:20:08 am
content: Quote from: phil from seattle on June 18, 2020, 03:50:58 amThe inner diameter of the tube is 4.36 mm in diameter so it is rather narrow. I have only used the HC-SR04 as far as ultrasonic sensors go so either I would have to have the bird directly drink from the reservoir by changing how the bird accesses the nectar.As far as a pressure sensor goes, how would you locate the sensor itself? Maybe similar to where I put the IR transistor for the 90 degree IR method. However, would the fluid in the "feed" line that passes through the peristaltic pump affect the pressure of the system? I'm not sure what to expect the pressure readings to be since the walls of the vessel are very narrow and the surface tension at the air/nectar boundary is likely significant.

author: drcubes
author_rank: Newbie
timestamp: June 18, 2020, 04:23:21 am
content: Quote from: hendorog on June 18, 2020, 03:08:07 am

author: drcubes
author_rank: Newbie
timestamp: June 18, 2020, 04:28:38 am
content: Quote from: wilfred on June 18, 2020, 04:07:37 amI like the idea for getting the average nectar amount drank by averaging based on visits and total drank per day. Although I eventually want to get accurate measurements for specific feeds (so I can understand feeding amount across the day) getting the average value per day could workexceptthat I would need to at least know the average drank per dayper individual.

author: Berni
author_rank: Super Contributor
timestamp: June 18, 2020, 05:06:57 am
content: Is it possible to make the setup as small as possible put it on a weight scale?Weighing things is the easiest way to accurately find the amount of stuff you have without needing special setups for handling things like fluids of a certain viscosity range, its even more handy for gas.So if you can make your setup weigh < 100g then you could set the whole thing onto a precise milligram scale. To get readings from it you can either buy a expensive scale that comes with a computer interface port, or get a cheep scale and hack it in some way attaching your own electronics (Sometimes you can tap into the data lines to the precision ADC chip)

author: David Hess
author_rank: Super Contributor
timestamp: June 18, 2020, 05:18:15 am
content: Quote from: drcubes on June 18, 2020, 02:47:35 amCapacitive sensing should work but you might need to guard the outside from stray electrostatic effects.QuoteMuch less than 1 gram resolution is not a problem with load cells. In practice a resolution and accuracy of 1 part in 4000 (12 bits) is easy and 1 part in 40,000 (16 bits) is feasible. The load cells used to measure things like diamonds will also detect the weight of a fingerprint.Quote from: hendorog on June 18, 2020, 03:08:07 amA differential pressure sensor suitable for an inch of water or less should work. I checked the specifications on one and the accuracy over time and temperature is sufficient.

author: Harm314
author_rank: Newbie
timestamp: June 18, 2020, 05:52:11 am
content: Given that you currently use video monitoring, I would suggest using automated analysis of the footage with computer vision, e.g. using OpenCV. This has the advantage that you already have a testset of data, and that verification of the automated measurement results is straightforward. The suggestion to add food colorant will likely help to make measuring the level easier.Going forward, you could set up a camera in time lapse or event triggered (bird detected) mode, taking a snapshot before and after a bird visits the setup. I have used a raspberry pi with a camera for a vaguely similar goal (automated readout of a non-electronic counter). For your purpose, compression or averaging of the image along the width of the tube allows to minimize data without losing resolution.With a camera solution the size of the setup will need to be large enough to minimize parallax effects, depending on the length of the tube, the camera, and the lens used. If you can use an enclosure around the whole measurement part, then optimizing the light source, optics, and camera together to give good contrast of the meniscus should be straightforward.

author: phil from seattle
author_rank: Super Contributor
timestamp: June 18, 2020, 06:12:17 am
content: The feeders I am familiar with are closed end, inverted tubes. The opening at the bottom sits in a shallow pan with the rim maybe 1/4" higher then the bottom of the tube. The tube is filled with nectar and inverted. As the hummers lick the nectar, it lowers the level in the pan. As this happens the pressure in the tube decreases. At some point the level of the pan gets low enough, a bubble of air enters and a small amount of nectar escapes into the pan and the the cycle repeats.So the idea is that the pressure of the air in the top of the tube drops as the birds feed and then rapidly increases when a "bubble" event happens. I don't know if the differential is significant enough to measure easily but if possible it you would be able to track pressure drops as a function of feeding. You would need to correlate the pressure drop to amount of nectar removed. It is also probably a function of how much head space you have in the tube so calibration is tricky.

author: nfmax
author_rank: Super Contributor
timestamp: June 18, 2020, 08:59:41 am
content: If you can make the tube out of metal, mounted with its axis vertical, then it should be possible to use the cylindrical air space above the meniscus as the frequency-determining element of a microwave oscillator. Even tiny changes in frequency, caused by lowering of the meniscus as sugar solution is withdrawn from the feeder, should be measurable with a decent microwave frequency counter. You can use a coax cable to feed the signal back from the feeder to the counter, inside your lab.If you take this approach it may be worthwhile making the tube larger, which will reduce the resonant frequency somewhat so as to lower the cable losses and/or cost.

author: SilverSolder
author_rank: Super Contributor
timestamp: June 18, 2020, 02:35:13 pm
content: Quote from: drcubes on June 18, 2020, 02:47:35 amI would say this might be one of the more promising ideas. I have a cheap Chinese scale in the lab that measures to 0.01g that I would definitely trust to 0.1g accuracy. It is definitely a viable method of measuring sub - 1g quantities of H2O.You could buy one of those and hack it, or re-use its parts to build your own... it will likely be cheaper than trying to buy the parts separately!E.g.https://www.amazon.com/MVZAWINO-Precision-Portable-Electronic-Stainless/dp/B07CL1HD8K/

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 18, 2020, 04:09:04 pm
content: cheap jeweller's scalecan measure 0.01g, you can reuse the hardware into your ADC/digital FW to tune to your specific need or you can even further reduce the resolution to like 1mg using lever mechanism, how much resolution do you need? i have one of this jeweller's scale and the reading changes significantly with just slight of air blow or breath, so you have to put it inside a chamber or still air to get stable/repeatable reading.

author: ogden
author_rank: Super Contributor
timestamp: June 18, 2020, 04:25:01 pm
content: Introduce some small intermediate reservoir with level sensor, then use miniature (peristaltic?) pump to fill it.

author: jogri
author_rank: Frequent Contributor
timestamp: June 18, 2020, 04:55:09 pm
content: Use a low power laser to shine through the pipette with a photodiode on the other side. Water and air will let the light pass, but the meniscus will mess with the reflection->drop in intensity right when the laser is at the same level as the meniscus. Take a peristaltic pump with a servo motor (you can scavenge an old HPLC instruments, they have accurate peristaltic pumps) and then just measure how many rotations of the servo motor/pump it takes to fill the pipette up after each hummingbird. Then just calculate the amount of liquid from the degrees of rotation it took.Edit: I tested the laser/meniscus approach with 8mm test tubes, works like a treat (so it should also work with your 4mm ones, even with a crappy laser diode).

author: TheMG
author_rank: Frequent Contributor
timestamp: June 18, 2020, 05:57:03 pm
content: Another alternative would be a TDR (time domain reflectometer) level sensor. I don't know if any of the commercially made units would be small or accurate enough for your use case but with some effort it would be possible to roll your own.

author: drcubes
author_rank: Newbie
timestamp: June 18, 2020, 06:11:27 pm
content: Quote from: jogri on June 18, 2020, 04:55:09 pmThat's good to hear that it worked for you! Can I ask, what kind of photodiode did you use? And what power and wavelength of laser did you use?

author: jogri
author_rank: Frequent Contributor
timestamp: June 18, 2020, 06:59:37 pm
content: Quote from: drcubes on June 18, 2020, 06:11:27 pmSorry to disappoint you, but it was just a quick-and-dirty proof of concept. I moved a test tube filled with water in front of a laser pointer... The laser is right at the meniscus in the picture, as you can see the intensity drops quite a bit at this point.

author: ahbushnell
author_rank: Frequent Contributor
timestamp: June 18, 2020, 07:11:22 pm
content: Metalize the outside of the tube that is a dielectric. Then measure the capacitance between the liquid and the metal.Andy

author: ahbushnell
author_rank: Frequent Contributor
timestamp: June 18, 2020, 07:16:48 pm
content: Quote from: ahbushnell on June 18, 2020, 07:11:22 pmhttps://www.te.com/commerce/DocumentDelivery/DDEController?Action=srchrtrv&DocNm=HPC052&DocType=DS&DocLang=EnglishThey measure capacitance in this relative humidity sensor using an oscillator that changes with capacitance.

author: bson
author_rank: Unknown
timestamp: June 19, 2020, 02:03:08 am
content: You could fill a small glass pipe with a column a water and drop a small float on top, then use a camera to record the position of the float. If you set the camera to take an image every few minutes you have a record of its position over the day. Extracting the position of the float from an image shouldn't be difficult. Maybe calibrate for solution expansion with temperature.

author: pickle9000
author_rank: Super Contributor
timestamp: June 19, 2020, 02:54:14 am
content: Use a peristaltic pump to maintain a level in the tube. The level sensor could be whatever you want. The pump would do the measurement. I'm not sure about how the birds would feel about the pump maintaining the level but the pump would need to be mounted far enough away to keep the noise down but it would allow the accuracy you are looking for.

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 19, 2020, 03:51:40 am
content: or you can connect the tube to adjacent large tank reservoir (both open air system) tube's height is adjusted accordingly to get the level to the tip, and then it will take many humming birds to reduce the level slightly. needs no electrical parts.

author: SilverSolder
author_rank: Super Contributor
timestamp: June 19, 2020, 03:58:30 am
content: Quote from: Mechatrommer on June 19, 2020, 03:51:40 amThis is a good one. And you put a scale under the bigger tank, to weigh it, and thereby keep track of consumption.

author: pickle9000
author_rank: Super Contributor
timestamp: June 19, 2020, 05:17:50 am
content: To expand on using a peristaltic pump to measure. You could detect the beak entering the flower with a sensor. Still have a high limit (full flower) when the beak is gone fill the tube (flower) up with the pump. A stepper driven pump or one with an encoder should be accurate enough. This would also allow a more natural fill routine (meaning the flower could be emptied as a natural one would and no motor noise while drinking).

author: Mechatrommer
author_rank: Super Contributor
timestamp: June 19, 2020, 05:51:38 am
content: Quote from: phil from seattle on June 18, 2020, 06:12:17 amthe description sounds familiar with printer CISS tank system. i once thought there is no issue (ie constant tank pressure) i usually reset the level on the "pan side" to zero by flipping them to the side, escaping most air in the resevoir side pulling back all liquid on the pan side, and then later i sometime noticed the level on the pan side (open air side) raised by itsef even if i dont use them for printing. one day therubber cap on resevoir sidetube connection (a bit loose and diyed) burst to the air, it was in storage mode where i put both rubber caps on both sides, when i came back home inks splattered everywhere in the room. so it got me thinking what the hell has happened. so i concluded its the room temp fluctuating. when i reset and cap the tank, it was on cooler night, and then on hotter mid day, pressure developed (air/gas/liquid expanded) in the tank and got bursted.so.. i'm guessing with this setup, and the pan is only few mm height, on hotter temp, the tank will push the nectar out and spilling the pan side, when cooled, it sucks more air zeroing the pan, on hot again, spill the nectar again until they all empty even without a bird licking it. so temp must be controlled as well, or give enough height (or volume) on the pan side to compensate for temp fluctuation.

author: SilverSolder
author_rank: Super Contributor
timestamp: June 19, 2020, 01:29:56 pm
content: Quote from: Mechatrommer on June 19, 2020, 05:51:38 amYou also have atmospheric pressure variations that could have an effect.