Designin a capacitive sensor for heterogeneous liquid level - Page 1
Forum section: electronics / projects

author: kuon
author_rank: Regular Contributor
timestamp: April 02, 2021, 12:47:03 pm
content: I am designing a liquid level sensor using capacitive sensing.The usual approach is to use 2 electrodes spanning the entire height of the sensor, and use the linear capacitive-level relation.This approach is described well here:https://www.analog.com/en/analog-dialogue/articles/liquid-level-sensing-using-cdcs.htmlNow, in my application, I have to measure the height of an heterogeneous that have varying capacitance and non-linear relation between capacitance and level.My approach is to use a segmented sensor.Simple schema below:I have built a PCB using this layout, and I get some results, but the sensitivity is not exactly ideal. I have ±0.05pf when the water is present or not (per sensor pad). It is a bit low.I'd like to get something more sensitive.The height I am measuring is 20cm, and the max width of my sensor area is 23mm per column. I have two boards, one per column. The liquid is floating (the whole system is battery powered).I am using 8 AD7746 per sensor board, each AD7746 is connected to 4 electrodes (2 channels) for a total of 32 channels.I have tried multi channel "button" sensors which don't require a separate excitation electrode (the blue ones in my drawing above), and with one big ground pour around the electrodes, I get a bit better sensitivity, but they don't work well for floating electrodes and they constantly auto-offset themselves (this helps detect touch when there is water on the sensor for example).Anyway, the AD7746 works, they are a bit expensive, but this is not really an issue, as this is a medical product where the cost can be handled.Now, my actual question is: is there a way to improve sensitivity by shaping the electrodes differently? There is 3mm of plastics between the liquid and the PCB.Below is one idea I had:Another one:Both are "per sensor" designs, so there would be multiple of those.I read a lot of different application notes of different sensors, and they all say something different regarding shapes, gap (between CINx and EXCx), electrode surface, presence of GND pour on the other side of the PCB....I'm a bit lost as there is no easy way to do the math (well, none that I found). And I couldn't find a way to simulate this.

author: PMA
author_rank: Contributor
timestamp: April 02, 2021, 01:02:31 pm
content: Use copper tape for protytyping and just brute force it? I did similar POC once and didn't find any exact guidelines for designs (which doesn't mean that there isn't any, just not easily available).

author: Marco
author_rank: Super Contributor
timestamp: April 02, 2021, 08:13:20 pm
content: An interdigitated sensor (the first idea) is the standard approach.Why so many ADCs? Just buffer each section and then use analogue switches.

author: Renate
author_rank: Super Contributor
timestamp: April 02, 2021, 11:29:47 pm
content: I've been running for a few years now with such a thing.It's 12 bands of 3/4" x 2-1/2" copper tape.I get about 5-6 pF difference out of that.I use an MPR121 chip to monitor 12 points.(Apparently, that's going (gone?) obsolete?)I looked at an Azoteq chip, even got an eval kit but the design/registers is wacky.Here's a graph. (I ought to throw some filtering in, but, hey, this is mobile.)

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 03, 2021, 12:22:55 am
content: Can you explain, in what way your substance is heterogeneous?And explain how does your sensor arrangement solve this issue?Tim

author: phil from seattle
author_rank: Super Contributor
timestamp: April 03, 2021, 05:02:38 pm
content: Won't you get higher sensitivity (ie higher capacitance) by using parallel plates for the capacitors and the liquid being in between (as pictured in the article you linked)? Having both sides of the sensor being co-planar on a PCB means that you are getting the capacitance only (mainly?) from the edges of the sensor "plates". You don't say what the liquid is but you could use a nonreactive material (stainless steel or gold plated) for the capacitor plates. I'm not sure a segmented sensor buys you anything as there will be discontinuities due to the gaps. As to geometry of the sensors, your serpentine design gives you a non-linear response to different liquid depths. Or perhaps I misunderstand what you are trying to do.I think the issue is not sensitivity but noise immunity. The lower the C per unit of depth, the more noise will be your limiting factor. Increasing the C per unit of depth will decrease the impact of noise. You can also use averaging techniques though that has limitations, too.If you have to use a PCB and planar sensor plates (er, traces), I would just make multiple sensor columns to increase the capacitance. I would experiment with making cutouts between the sensor traces to increase the amount of liquid between them.The article also shows a reference sensor that is always immersed. That allows you to calibrate your sensor - worth having, especially when you do not necessarily know the actual liquid being measured. This does increase the minimum measurable depth, of course.When I was experimenting with this, I used a timer to measure the RC time constant with the sensor providing the C. It was pretty cheap - I used two pins of a microcontroller. For better accuracy I would use a high speed timer, comparator and precision V ref. But there are lot of ways to measure the capacitance.

author: kuon
author_rank: Regular Contributor
timestamp: April 03, 2021, 05:21:57 pm
content: Quote from: Marco on April 02, 2021, 08:13:20 pmThat's an interesting idea, I didn't think of it, I'm not sure what you mean by buffer though.

author: Marco
author_rank: Super Contributor
timestamp: April 03, 2021, 07:28:23 pm
content: An analogue switch has significant capacitance to the off state inputs, given the small capacitances in question maybe a little too much. Especially if the excitation signal is a voltage signal applied to all the EXCx at the same time (crosstalk).With buffers you could do something like excite all the EXCx with a squarewave voltage, have PCB capacitors on the CINx side as a capacitive divider to ground, run internal traces with guards on all sides from those dividers to opamp buffers, use those opamp buffers to drive said guards.The beauty of those CDCs is that they can mostly ignore parasitic capacitance to ground, but when you're homebrewing not so much.

author: kuon
author_rank: Regular Contributor
timestamp: April 04, 2021, 12:23:35 am
content: Quote from: T3sl4co1l on April 03, 2021, 12:22:55 amThe liquid can contain lumps that will precipitate and lipids that will float. Using a segmented sensor provides multiples "on/off" switches.For example, if I have 10 sensors, and the height of the container is 10cm, I have 1cm resolution.Also, I can improve the resolution by looking at sensor N-1 and using that to interpolate the value of sensor N.When empty, all sensors are zeroed.Now, if I have 5pf,6pf,7pf,3pf,0pf,0pf I can approximate the level at 3/7 of sensor 4.

author: kuon
author_rank: Regular Contributor
timestamp: April 04, 2021, 12:30:29 am
content: Quote from: Marco on April 03, 2021, 07:28:23 pmWell, I just multiplied the ADC with an I2C multiplexer, and I turn them on in sequence. Multiplexing on the analog side is certainly cheaper and might be more elegant, but it is way harder to design properly.

author: kuon
author_rank: Regular Contributor
timestamp: April 04, 2021, 12:33:04 am
content: I don't have a choice on how I design the sensor. The container is consumable that is changed for each measure, the container is fixed on a mount and the sensors are on the "wall" of this mount. That's why I can only use coplanar topology.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 04, 2021, 01:31:30 am
content: Quote from: kuon on April 04, 2021, 12:23:35 amSo, the interdigitated version would be mainly to get enough coverage to average over the lumps?Whereas the tiles are not all linked together, but treated as individual sensors? Ah, so you can have a given sensitivity threshold, and count up the total above that threshold? (Interpolation of course won't give a linear result, not in general -- but presumably it's still better than counting whole tiles, so worth doing. Downside, it need not be monotonic, as the level is filled up and different capacity/r resistivity muck moves around the electrodes?)How about a ground plane between tiles, to better shield them from each other? That might help with locality and reducing interference between tiles. Interference can also be solved by grounding all inactive tiles, while testing each individual. This will require N x GPIOs to do it the "CapTouch" way, or N x SPDT analog switches to ground the inactive ones while selecting the active one for test (perhaps using a decoder chip, to save on GPIOs). I feel like analog switches should be alright, but if they aren't well matched after all, you'll have to do some sort of manufacturing calibration to establish that first. It shouldn't vary much in operation, as long as the measurement unit, connector and sensor geometry are all well defined (stick-on film and foil?).Sounds like some unseemly mix of biomatter, I guess... I can't say I envy the application?Tim

author: Marco
author_rank: Super Contributor
timestamp: April 04, 2021, 02:06:13 am
content: Quote from: kuon on April 04, 2021, 12:33:04 amI didn't catch this at first ... the sensor doesn't get dipped in the liquid then?I thought traces from CINx had to go all the way up the board and you needed to deal with all their parasitic capacitance, that's why I mentioned the guarding. I guess you're simple putting all the ICs on the back of the board then? Still more elegant with a buffer per CINx followed by an analogue switch though.

author: kuon
author_rank: Regular Contributor
timestamp: April 04, 2021, 10:05:47 am
content: Quote from: T3sl4co1l on April 04, 2021, 01:31:30 amTo clarify, the interdigitated version would be something like this:Where all sensors are individuals.The ICs are on the other side of the PCB, so the trace between the ADC and the sensors electrode is like 2cm.Also, the switch made me think: I could also have one large excitation electrode poured over the full height and analog switch only the CINx.The ADC have a Cap compensation up to 17pf, so I can do factory calibration.Do you have any recommendation of analogue switch? I found the ADG728 which seems appropriate. And I should be able to compensate it's capacitance with the ADC.Also, my ADC is AD7746, not AD7796, I mixed the part number in my original post.

author: Renate
author_rank: Super Contributor
timestamp: April 04, 2021, 12:24:39 pm
content: Ireallydon't want to know what this is all about, but...I presume that this thing is filling up in a disposable container that gets disposed?Reusable or something emptying out is more complicated because of stuff sticking to the walls.If the unit is small, acceptance test for any technology here should be to tilt the unit and make sure tht the reading goes back down afterwards.What's wrong with the single capacitive plates (12) like in my setup?I presume that the main point is to tell the operator when to change the container?Making sure that the sensor has good physical to the removable container could be tricky.Since you're dealing (yes?) with fresh, clean containers, how about optical detection?

author: kuon
author_rank: Regular Contributor
timestamp: April 04, 2021, 01:42:35 pm
content: Quote from: Renate on April 04, 2021, 12:24:39 pmThe container is disposable, but usually emptied every few hours. It is reused for a few days.I need to know the level variation every minute with about 5mm accuracy.The container is also weighted constantly and the capacitive reading is here as double/redundant measure.Because of NDA I cannot go into more details, but the liquid is composed of different body fluids.Under some circustances, the liquid can be clear.

author: Marco
author_rank: Super Contributor
timestamp: April 04, 2021, 04:19:47 pm
content: Quote from: kuon on April 04, 2021, 10:05:47 amYou might want to ask Analog about multiplexing the input ... there is some unintuitive magic in that IC which might get botched with an analogue switch.That's why I suggested using the capacitive sensor with a second small capacitor as a divider and opamp buffering the output of the divider. Then you have a nice low impedance voltage signal, which won't be affected by an analogue switch and which you can use with a bog standard ADC ... which the AD7746 is not.

author: kuon
author_rank: Regular Contributor
timestamp: April 04, 2021, 05:46:15 pm
content: Quote from: Marco on April 04, 2021, 04:19:47 pmAaah, I get the idea. But I don't know if I can design such a circuit properly. I am a programmer and I got a good grasp of digital circuits, but I'm scared by analog circuits. That's why I just multiplied the ADC.

author: 2N3055
author_rank: Super Contributor
timestamp: April 04, 2021, 07:23:44 pm
content: Acoustic sensor?

author: kuon
author_rank: Regular Contributor
timestamp: April 04, 2021, 07:36:26 pm
content: I thought of using some acoustic sensors, but I thought the capacitive approach would work.I still think it can work, but I need to design my sensor properly.

author: kuon
author_rank: Regular Contributor
timestamp: April 08, 2021, 03:22:19 am
content: I asked analog, and they said I could make it work with an ADG1208 (8 channels per ADC channel). So I am going to try this. Having 1 ADC makes it possible to have one large EXC pour around the sensors. I'll let you know how it goes.