### Author Topic: understanding zener and high side switching  (Read 1211 times)

0 Members and 1 Guest are viewing this topic.

#### hsn93

• Regular Contributor
• Posts: 86
• Country:
##### understanding zener and high side switching
« on: December 13, 2018, 03:02:40 pm »
hello,

im design circuit for industrial application i want to have water detection sensor and planning to have electrodes (SS) with distance of 20mm or so...

the water is tap water so it would be "around 2K ohm"

so i dont want to put 24v to the electrodes if the water exist for long time as this will give electrolysis the water ... so i want to switch the sensor off and on ..

my circuit is like following i would like to see what you guys think and if someone have an advice i appreciate that
• oh (D2) is 3v3 zener but couldnt find it in LTSPICE
• (Rload) is water exist .
• (Rload) would be open circuit if water doesnt exist
• do you think my high side switching is good? 10K for R1 is good?(why)?

#### hsn93

• Regular Contributor
• Posts: 86
• Country:
##### Re: understanding zener and high side switching
« Reply #1 on: December 18, 2018, 08:55:46 am »
hello,

to make more sense of the subject title and to really understand what im designing here is my understanding (i know i go to details but i like to understand  ):

when Vpulse (V1) = 0V:

Q1 will be around 5M ohm or something "in worst case"? it has leakage current.
10uA leakage at VCE = 50v -> 5M ohm

so the 10k (R1) will not have a lot of voltage drop (less than 0.7V i guess) "if it had more than 0.7V, D1 will conduct in the loop and shunt it?"
hence, P-MOS VGS < thresh hold = off

when Vpulse = 3.3V:
Q1 will have saturation 1V. (assume)
R2 (5K) will have drop of ~18V "assuming Zener will have 11v drop" (V=IR -> I= 3.6mA)
D1 will have drop of ~11V (is that right?)
R1 (10K) will have (11V also) hence (I=1.1mA)

which means the zener will have 3.6mA - 1.1mA = 2.5mA.

I'm ignoring the dynamic resistance (to simplify)?

now, to my understanding R1 (10K) is defining how fast the P-MOS will switch off.

Gate is 32nC is worst case?
to turn off mosfet it will be as following:

which means to turn off the mosfet it will take around (in worst case):
5*R*C = 5*10K*32nC = 1.6mSec ?

are my assumptions correct?

« Last Edit: December 18, 2018, 09:07:42 am by hsn93 »

#### nick_d

• Regular Contributor
• Posts: 120
##### Re: understanding zener and high side switching
« Reply #2 on: December 18, 2018, 09:25:24 am »
Yes, your circuit looks like it would work and your calculations are broadly correct, although I didn't understand why you changed 32.2nC from the datasheet to 32nF in your diagram. It's better to use the gate capacitance for this calculation. A figure that I use for rough estimates is 1nF, it will be less for a signal-level MOSFET and more for a power MOSFET. In this particular case, referring to a Rohm datasheet on Digikey:
See the line "Input Capacitance, Ciss, Typ. 2700 pF, VDS = -10V", so your gate capacitance is about 2.7nF, the RC time constant is then 10k * 2.7n = 27us for the turn-off and I guess 3.33k * 2.7n = 9.0us for the turn-on (because 10k in parallel with 5k is 3.33k). Since it will be affected by threshold voltage and drive voltage and all sorts of things, this is only an estimate, but it's certainly good to within an order of magnitude.

By the way, it would be simpler to use a PNP bipolar transistor for the high side drive and a FET to pull the base of the PNP down. This would eliminate most resistors and the zener. Also, I didn't understand the 1N750 section. What are we sensing exactly? Could we use an op-amp for the sensor, or a simple resistive divider to get the sensed voltage down to an appropriate scale so that the 2.5V threshold of the MCU detects it?

cheers, Nick

The following users thanked this post: hsn93

#### Zero999

• Super Contributor
• Posts: 13039
• Country:
• 0999
##### Re: understanding zener and high side switching
« Reply #3 on: December 18, 2018, 09:47:54 am »
Why not simply use 3.3V for the water detection electrodes?

If you're that worried about corrosion, then use AC, rather than DC. Make one electrode 0V and send a square-wave to the other one, via a capacitor and high value resistor. Monitor the voltage on the electrode and if the square-wave falls to 0V, that means it's detected water.

The following users thanked this post: hsn93

#### spec

• Frequent Contributor
• Posts: 833
• Country:
• MALE
##### Re: understanding zener and high side switching
« Reply #4 on: December 18, 2018, 10:54:05 am »
Hi hsn93

You haven't asked this, but I seem to remember that stainless steel as a resistive water level sensor has problems and other materials are more appropriate.

There are a number of ways to detect water level, but the best compromise, in my opinion, is to use insulated terminals and capacitive sensing. If you are interested in this approach we can discuss- the circuitry is well proven, simple, and low cost.

The following users thanked this post: Zero999, hsn93

#### Zero999

• Super Contributor
• Posts: 13039
• Country:
• 0999
##### Re: understanding zener and high side switching
« Reply #5 on: December 18, 2018, 11:37:29 am »
I agree: capacitive sensing is an excellent solution.

The terminals can be on an internal PCB layer or on the top, coated with a thick conformal coating. It forms a capacitor who's value increases in the presence of water. The capacitor's impedance can be measured using a constant voltage and frequency AC signal source, resulting in an amplitude modulated signal, or the capacitor can be part of an oscillator, in which it will produce a frequency modulated signal.

There are specially ICs available for this application, see the link below:
https://www.analog.com/en/analog-dialogue/articles/liquid-level-sensing-using-cdcs.html

There are other non-contact solutions such as sonar and radar, but they're more tricky to implement, although there are ready made proximity sensors available, at a cost.

#### hsn93

• Regular Contributor
• Posts: 86
• Country:
##### Re: understanding zener and high side switching
« Reply #6 on: December 18, 2018, 11:57:31 am »
hello, nick thanks for the reply
Quote
Yes, your circuit looks like it would work and your calculations are broadly correct, although I didn't understand why you changed 32.2nC from the datasheet to 32nF in your diagram.
oh well, i read it in my mind as (n Capacitance) instead of (coulombs) hence i replaced it with Farads.

i saw that input capacitance (Ciss) but didnt know what is it exactly .. is it for gate is it just some gate in some where that i dont know.. i tend to ignore these parameters if i dont know what they stand for.

Quote
and I guess 3.33k * 2.7n = 9.0us for the turn-on (because 10k in parallel with 5k is 3.33k). Since it will be affected by threshold voltage and drive voltage and all sorts of things, this is only an estimate, but it's certainly good to within an order of magnitude.

hmm. i dont know why consider the parallel when the Zener exist? (in my mind i just assume it will be like the following):
gate is capacitor charged at (~30V)
and (zener + 10k will just act like 19V voltage supply) (most switching from here)
the (5k resistor) is just activating the Zener effect?

anyway i though its little complicated so didnt bother about it. but would like to know and understand it ( )

Quote
By the way, it would be simpler to use a PNP bipolar transistor for the high side drive and a FET to pull the base of the PNP down. This would eliminate most resistors and the zener. Also, I didn't understand the 1N750 section. What are we sensing exactly? Could we use an op-amp for the sensor, or a simple resistive divider to get the sensed voltage down to an appropriate scale so that the 2.5V threshold of the MCU detects it?

you mean to get rid off the (max vgs +-) of the fet?
hmm yeah you have a point i only put pmos because i use it somewhere else in the circuit and wanted to reduce the BOM unique parts.

the 1N750 is just 3v3 protection zener diode.
actually yes, i could use R7 as 2.5K and it will be correct divider ..
(15k + ~3k water) = 18K
2.5/21 * 24 =  2.9V.

#### nick_d

• Regular Contributor
• Posts: 120
##### Re: understanding zener and high side switching
« Reply #7 on: December 18, 2018, 12:09:41 pm »
If you want to sense the resistance of something, a good way is to charge a capacitor through it and see how long it takes to charge. Therefore I suggest to use 2 pins of your MCU. One for each side of the sensing probe. Configure one as an output and the other as an input. Ideally make the output a timer PWM pin and the input a timer input capture pin. Put a capacitor from the input to ground. Then as another (high-ranking) poster suggested, output a square wave. Measure the phase delay of the square wave coming back (treat as infinite if no square wave comes back).
cheers, Nick

The following users thanked this post: hsn93

#### Zero999

• Super Contributor
• Posts: 13039
• Country:
• 0999
##### Re: understanding zener and high side switching
« Reply #8 on: December 18, 2018, 12:30:52 pm »
hsn93,
This is overcomplicated. I don't see why there's a requirement for 24V. Just connect one of the electrodes to an output on the MCU, via a resistor. A small capacitor to filter out any noise is also a good idea.

The values of R1 and C1 are experimental.

If you want to sense the resistance of something, a good way is to charge a capacitor through it and see how long it takes to charge. Therefore I suggest to use 2 pins of your MCU. One for each side of the sensing probe. Configure one as an output and the other as an input. Ideally make the output a timer PWM pin and the input a timer input capture pin. Put a capacitor from the input to ground. Then as another (high-ranking) poster suggested, output a square wave. Measure the phase delay of the square wave coming back (treat as infinite if no square wave comes back).
cheers, Nick
It can be done with one MCU pin, toggled from high to charge capacitor, to input with a high impedance, when the voltage on the capacitor is monitored. When the electrodes are dry, the capacitor should be charged for a long time, only discharging slowly via internal leakage and the MCU input. When electrodes are wet, the capacitor will discharge fairly quickly, through the water.
« Last Edit: December 18, 2018, 12:51:28 pm by Hero999 »

#### Ian.M

• Super Contributor
• Posts: 8013
##### Re: understanding zener and high side switching
« Reply #9 on: December 18, 2018, 01:16:32 pm »
To prevent electrolytic corrosion, neither electrode may have a DC path to ground, so both must be isolated by a transformer or capacitors, or the whole sensing circuit must be galvanically isolated, and use balanced AC excitation.

Even if DC bias is time or current limited, it *will* cause electrolytic corrosion of the electrodes.  The only question is: how much?  If the electrode surface area is large enough and the average current low enough, you probably be able to get sufficient electrode life to be practical.

However there is another problem with stainless electrodes - pitting aka: crevice corrosion, as it has two different electrode potentials depending on whether or not its surface chromium oxide layer is present.  In an aerobic environment, the chromium oxide layer maintains itself and protects the iron component of the alloy from rusting.  In an anerobic environment, the chromium oxide layer becomes depleted then the iron is free to rust.  It only takes a little inter-granular corrosion due to electrolytic action (e.g. due to DC bias or dissimilar metals with an electrical connection, immersed anywhere in the system) , providing a microscopic pit or crevice, a bit of lime scale obscuring the pit and some trace organics to tip the balance towards an anerobic environment at which point the stainless eats itself, forming an electrochemical cell between the anodic crevice and the cathodic exposed surface, preferentially eroding the metal in the pit or crevice.   I've personally seen a stainless pump shaft eroded by crevice corrosion that over the course of one winter without use, lost a chunk of metal about the size of a large split pea from under a lip seal leaving a sharp edged  pit , leading to immediate failure in the spring the first time the shaft moved.

You'll probably get away with DC bias if the electrodes are rarely immersed, and are mounted protruding downwards from a very smooth surfaced PTFE or HDPE plate, with no supports or other parts touching the electrodes except at their mounting plate so biofilm buildup between the electrodes is limited.  Ideally the mounting plate should *NEVER* be immersed.

The following users thanked this post: hsn93

#### Ian.M

• Super Contributor
• Posts: 8013
##### Re: understanding zener and high side switching
« Reply #10 on: December 18, 2018, 02:03:28 pm »
Here's a LTspice sim of a rearrangement of the squarewave sensor drive idea to eliminate DC bias at the electrodes.   A practical implementation could use a MCU with a PWM ouput and an analog comparator input, or for a standalone implementation, a dual comparator, one half as the 50% duty cycle squarewave oscillator, and the other as the threshold detector on the charge pump output.

The following users thanked this post: hsn93

#### hsn93

• Regular Contributor
• Posts: 86
• Country:
##### Re: understanding zener and high side switching
« Reply #11 on: December 18, 2018, 02:10:30 pm »
Why not simply use 3.3V for the water detection electrodes?

If you're that worried about corrosion, then use AC, rather than DC. Make one electrode 0V and send a square-wave to the other one, via a capacitor and high value resistor. Monitor the voltage on the electrode and if the square-wave falls to 0V, that means it's detected water.

hsn93,
This is overcomplicated. I don't see why there's a requirement for 24V. Just connect one of the electrodes to an output on the MCU, via a resistor. A small capacitor to filter out any noise is also a good idea.

The values of R1 and C1 are experimental.

If you want to sense the resistance of something, a good way is to charge a capacitor through it and see how long it takes to charge. Therefore I suggest to use 2 pins of your MCU. One for each side of the sensing probe. Configure one as an output and the other as an input. Ideally make the output a timer PWM pin and the input a timer input capture pin. Put a capacitor from the input to ground. Then as another (high-ranking) poster suggested, output a square wave. Measure the phase delay of the square wave coming back (treat as infinite if no square wave comes back).
cheers, Nick
It can be done with one MCU pin, toggled from high to charge capacitor, to input with a high impedance, when the voltage on the capacitor is monitored. When the electrodes are dry, the capacitor should be charged for a long time, only discharging slowly via internal leakage and the MCU input. When electrodes are wet, the capacitor will discharge fairly quickly, through the water.

hello Hero999, thank you.. i think its good idea to measure with two pins, once im sure there is water i can pull both pins to ground eliminating the potentional between electrodes. having water to the sensor is abnormal and when it happens it will need intervention from service. thats why i dont need to measure the water all the time and can do it once every 5 minute and then pull two pins to ground.
the thing is that im always afraid to expose mcu pins to outside board thats why i was putting the 24V with a high resistance on series.
but i guess its safe? i will just put 3v3 zener on both pins to ground and should be ok (i assume  ).

BTW, that link from analog devices doesn't work but i will search for it from the keywords. thanks.

Hi hsn93

You haven't asked this, but I seem to remember that stainless steel as a resistive water level sensor has problems and other materials are more appropriate.

There are a number of ways to detect water level, but the best compromise, in my opinion, is to use insulated terminals and capacitive sensing. If you are interested in this approach we can discuss- the circuitry is well proven, simple, and low cost.

hello, I'm always interested to learn, what are the other materials. the thing is that this sensor is going to be for abnormal situation so i thought a cheap way to do it (im not expert). so would that simple circuitry be simple for me also..

To prevent electrolytic corrosion, neither electrode may have a DC path to ground, so both must be isolated by a transformer or capacitors, or the whole sensing circuit must be galvanically isolated, and use balanced AC excitation.

Even if DC bias is time or current limited, it *will* cause electrolytic corrosion of the electrodes.  The only question is: how much?  If the electrode surface area is large enough and the average current low enough, you probably be able to get sufficient electrode life to be practical.

However there is another problem with stainless electrodes - pitting aka: crevice corrosion, as it has two different electrode potentials depending on whether or not its surface chromium oxide layer is present.  In an aerobic environment, the chromium oxide layer maintains itself and protects the iron component of the alloy from rusting.  In an anerobic environment, the chromium oxide layer becomes depleted then the iron is free to rust.  It only takes a little inter-granular corrosion due to electrolytic action (e.g. due to DC bias or dissimilar metals with an electrical connection, immersed anywhere in the system) , providing a microscopic pit or crevice, a bit of lime scale obscuring the pit and some trace organics to tip the balance towards an anerobic environment at which point the stainless eats itself, forming an electrochemical cell between the anodic crevice and the cathodic exposed surface, preferentially eroding the metal in the pit or crevice.   I've personally seen a stainless pump shaft eroded by crevice corrosion that over the course of one winter without use, lost a chunk of metal about the size of a large split pea from under a lip seal leaving a sharp edged  pit , leading to immediate failure in the spring the first time the shaft moved.

You'll probably get away with DC bias if the electrodes are rarely immersed, and are mounted protruding downwards from a very smooth surfaced PTFE or HDPE plate, with no supports or other parts touching the electrodes except at their mounting plate so biofilm buildup between the electrodes is limited.  Ideally the mounting plate should *NEVER* be immersed.

very informative thank you. I'm having the sensor rarely immersed. but once it is. (i don't know how much it will stay immersed) since this needs intervention from service team. so what if i put both outputs to ground once the water is detected. (yes its planned to have the two electrodes between PTFE in distance of 20mm).. although I'm weak at chemical and corrosion but I've seen way before so i thought i will need some plastic that will not be affected by waste water.

Here's a LTspice sim of a rearrangement of the squarewave sensor drive idea to eliminate DC bias at the electrodes.   A practical implementation could use a MCU with a PWM ouput and an analog comparator input, or for a standalone implementation, a dual comparator, one half as the 50% duty cycle squarewave oscillator, and the other as the threshold detector on the charge pump output.

thank you i will look and study. capacitors dc coupling was always a question mark for me im not good with analog. so i have to study that effect of c1 and c2 and imagine what will happen (basics but im newbie)..
a question, having c1 and c2 with high Voltage rating will be protected input, outputs (with zeners after them)?  (galvanic isolated) ?
================================================

hello everybody thanks for your valued replies it teach me a lot.

from different comments i get that:
-capacitive sensing is more correct way to do it.
-water conductive method is not very good because of corrosion. (to use AC is ok)

-my application has (vibration and waste water feces / or tab water).
-having water to the electrodes is abnormal situation in my application.
-thats why i though to remove the potential difference by having HI-Z on the output of one electrodes (once i detect the water). (do i still need to have AC?)

« Last Edit: December 18, 2018, 02:33:06 pm by hsn93 »

#### Ian.M

• Super Contributor
• Posts: 8013
##### Re: understanding zener and high side switching
« Reply #12 on: December 18, 2018, 02:38:17 pm »
You cant get much *worse* than 'black' water (i.e. sewage) for corrosion.   The odds of stainless sensing electrodes surviving in the head-space of a black water tank aren't very good - its almost guaranteed to be anerobic, with 100% humidity and condensation, and there is  high probability of corrosive gasses and biofilm buildup, leading to corrosion of even unpowered stainless electrodes.

How I'd tackle that woud be with a relatively large diameter HDPE dip tube, from the tank top down to a few inch below the required detection level, capped off above the tank top.  The cap would have a Goretex vent separating it from a sealed sensing chamber with a differential pressure sensor (to ambient) and an air inlet from a small electric air pump.   Every five minutes, run the air pump briefly until the chamber pressure plateaus, then stop the pump and monitor the pressure.   If it rapidly decays back to ambient, the dip tube isn't immersed.   When immersed, the pressure it decays to depends on the depth the end of the tube is immersed to.  Set a suitable detention threshold for the final level you need.    Clogging of the dip tube, Goretex vent or main tank vent will show up as anomalous excessive pressure.
« Last Edit: December 18, 2018, 02:40:56 pm by Ian.M »

The following users thanked this post: hsn93

#### Zero999

• Super Contributor
• Posts: 13039
• Country:
• 0999
##### Re: understanding zener and high side switching
« Reply #13 on: December 18, 2018, 03:15:26 pm »
hello Hero999, thank you.. i think its good idea to measure with two pins, once im sure there is water i can pull both pins to ground eliminating the potentional between electrodes. having water to the sensor is abnormal and when it happens it will need intervention from service. thats why i dont need to measure the water all the time and can do it once every 5 minute and then pull two pins to ground.
the thing is that im always afraid to expose mcu pins to outside board thats why i was putting the 24V with a high resistance on series.
but i guess its safe? i will just put 3v3 zener on both pins to ground and should be ok (i assume  ).

BTW, that link from analog devices doesn't work but i will search for it from the keywords. thanks.
Another resistor can be added in series with the input to protect it against high voltages.

By the way, there will be a time delay between seeing the voltage on the capacitor and the output going high, as it will take time for the capacitor to charge, so the code needs to account for this.

I don't know why the link didn't work. It works for me. Could it be the firewall? It's not the forum corrupting the link, as I've tested it again. Try Googling for "Liquid Level Sensing Using Capacitive-to-Digital Converters"
« Last Edit: December 18, 2018, 03:17:41 pm by Hero999 »

The following users thanked this post: hsn93

#### hsn93

• Regular Contributor
• Posts: 86
• Country:
##### Re: understanding zener and high side switching
« Reply #14 on: December 19, 2018, 06:01:51 am »
hello, everybody,

thank you for your replies i will have to study capacitive sensing in details.

although my application is for sanitation vacuum system and the sensing here is for detecting the Bowl water level if it gets full then its a failure mode
the sensor is attached to the bowl and the system is exposed to extreme vibration.
im using optical sensor but thats for leakage under the bowl. for this one i needed somthing cheap "it can be replacable as a spare part" so i was considering water conductivity.

i didnt care a lot about electrodes as i know this is a situation that shouldnt occure in normal mode (its a failure of the system for some reason).
but i wanted to shutdown the electrodes potential while i was using 24V.

after seeing the replies from different experts i can see that its ok to use the electrodes for my application (increase the distance maybe 40mm if the vibration is extreme but i dont think so as it will be mounted on some height and water shouldnt reach to it.)

thank you all for your kind replies. any further information is welcomed im going to study them.

#### Ian.M

• Super Contributor
• Posts: 8013
##### Re: understanding zener and high side switching
« Reply #15 on: December 19, 2018, 01:56:09 pm »
Hmm, that sounds like a vacuum flush toilet on a vehicle, (maybe a large fast motorboat), and you want blocked bowl detection *BEFORE* it overflows.

A capacitive liquid level switch with a PTFE or other water repelling face on the sensor, installed through the bowl wall,   located so the flush water rinses gross contamination off it is probably the best option, at least from a reliability and minimal maintenance point of view.  You should be able to buy a suitable sensor with relay or logic output off the shelf.
If the bowl is non-conductive, a sensor on the outside of it with enough sensing plate area may be able to work through the bowl wall.

I had considered a pressure sensor on a port on the waste pipe, monitoring the pressure profile during the flush and comparing it to one recorded from a normal flush but IMHO that could be a maintenance nightmare even if its protected by a rubber diaphragm, and also there would be a lot of software development and testing required.

Your original idea of  a conductivity sensor with stainless probes is probably workable, but its going to be difficult  to locate the probes low enough in the bowl to have enough room left to handle the flush water volume of one normal flush + slop from vehicle motion, assuming the worst case situation when the blockage leaves the bowl level just below the sensor.

The following users thanked this post: hsn93

#### hsn93

• Regular Contributor
• Posts: 86
• Country:
##### Re: understanding zener and high side switching
« Reply #16 on: December 27, 2018, 03:01:35 pm »
hello Hero999, thank you.. i think its good idea to measure with two pins, once im sure there is water i can pull both pins to ground eliminating the potentional between electrodes. having water to the sensor is abnormal and when it happens it will need intervention from service. thats why i dont need to measure the water all the time and can do it once every 5 minute and then pull two pins to ground.
the thing is that im always afraid to expose mcu pins to outside board thats why i was putting the 24V with a high resistance on series.
but i guess its safe? i will just put 3v3 zener on both pins to ground and should be ok (i assume  ).

BTW, that link from analog devices doesn't work but i will search for it from the keywords. thanks.
Another resistor can be added in series with the input to protect it against high voltages.

By the way, there will be a time delay between seeing the voltage on the capacitor and the output going high, as it will take time for the capacitor to charge, so the code needs to account for this.

I don't know why the link didn't work. It works for me. Could it be the firewall? It's not the forum corrupting the link, as I've tested it again. Try Googling for "Liquid Level Sensing Using Capacitive-to-Digital Converters"

hi, to protect MCU we place 1M resistor. what happen if someone plugged 24V to the input? (limit current to 24uA is that all to protect mcu pin?)

im thinking to have voltage follower here op amps have better input impedance than mcu? if its not smart idea, why its not?
how about 3v3 zener after R2?

the link worked. i think it was analog website problem.

#### coppercone2

• Super Contributor
• Posts: 3283
• Country:
• 💎
##### Re: understanding zener and high side switching
« Reply #17 on: December 27, 2018, 04:26:59 pm »
complicated post

for very clean water, with resistivity of 100k-18M, can you get away with the small bias current from a opamp connected directly or should you still use a coupling transformer?

when you say galvanic isolation, what DC leakage is permitted?
« Last Edit: December 27, 2018, 04:28:36 pm by coppercone2 »

#### Zero999

• Super Contributor
• Posts: 13039
• Country:
• 0999
##### Re: understanding zener and high side switching
« Reply #18 on: December 27, 2018, 05:50:58 pm »
hello Hero999, thank you.. i think its good idea to measure with two pins, once im sure there is water i can pull both pins to ground eliminating the potentional between electrodes. having water to the sensor is abnormal and when it happens it will need intervention from service. thats why i dont need to measure the water all the time and can do it once every 5 minute and then pull two pins to ground.
the thing is that im always afraid to expose mcu pins to outside board thats why i was putting the 24V with a high resistance on series.
but i guess its safe? i will just put 3v3 zener on both pins to ground and should be ok (i assume  ).

BTW, that link from analog devices doesn't work but i will search for it from the keywords. thanks.
Another resistor can be added in series with the input to protect it against high voltages.

By the way, there will be a time delay between seeing the voltage on the capacitor and the output going high, as it will take time for the capacitor to charge, so the code needs to account for this.

I don't know why the link didn't work. It works for me. Could it be the firewall? It's not the forum corrupting the link, as I've tested it again. Try Googling for "Liquid Level Sensing Using Capacitive-to-Digital Converters"

hi, to protect MCU we place 1M resistor. what happen if someone plugged 24V to the input? (limit current to 24uA is that all to protect mcu pin?)

im thinking to have voltage follower here op amps have better input impedance than mcu? if its not smart idea, why its not?
how about 3v3 zener after R2?

the link worked. i think it was analog website problem.
24µA is not going to damage the MCU input pin.

I doubt a 3V3 zener would make any difference.

MCUs already have a very high input impedance, but an op-amp is not a bad idea. It depends on what you want to do. Will you be using an ADC input? Does the MCU have Schmitt trigger inputs?

A Schmitt trigger input is a good idea to, as some MCU inputs behave unpredictably when given invalid logic levels.

Using an ADC input would make it more flexible as the threshold can be programmed, but there should be a low AC impedance path to 0V, so the sample and hold capacitor can be charged/discharged, otherwise the reading can be affected given such a high source impedance: 10nF between the input and 0V would alleviate the problem. Refer to the papers linked below:
https://www.st.com/content/ccc/resource/technical/document/application_note/9d/56/66/74/4e/97/48/93/CD00004444.pdf/files/CD00004444.pdf/jcr:content/translations/en.CD00004444.pdf
http://www.ti.com/lit/an/spna061/spna061.pdf
« Last Edit: December 27, 2018, 05:52:41 pm by Zero999 »

#### Ian.M

• Super Contributor
• Posts: 8013
##### Re: understanding zener and high side switching
« Reply #19 on: December 27, 2018, 06:34:40 pm »
To prevent electrolytic corrosion ... <snip complicated post>

for very clean water, with resistivity of 100k-18M, can you get away with the small bias current from a opamp connected directly or should you still use a coupling transformer?

when you say galvanic isolation, what DC leakage is permitted?
It all comes down to how much metal you can tolerate loosing over the max. expected life of the sensor.

Assuming the electrodes don't normally corrode on their own with no current flowing:
Multiply the DC leakage, bias or sensing current by the life in seconds to get total charge.  Divide by the Faraday constant and further divide by the oxidation state of the metal's commonest stable soluble ion, to get the number of moles of metal atoms lost.   Multiply by the atomic mass to get grammes of metal lost from the anode.   You can then calculate the volume of metal lost from its density, and if you make some assumptions e.g. that the worst pitting wont be deeper than ten times the average loss of surface (not valid for stainless steel under anerobic conditions or for metals like aluminum that normally form an insulating highly adherent oxide film),  you can estimate the thickness that will be lost from the surface over the electrode life.  It wont apply unless the electrode geometry is such that the distance between the electrodes across their length and width is constant, and the electrodes are fully immersed.  If they are only partially immersed or the edges are significantly closer together than the rest of their surface, the immersed part or the closer part of the anode will be preferentially eroded.
« Last Edit: December 27, 2018, 06:36:31 pm by Ian.M »

#### coppercone2

• Super Contributor
• Posts: 3283
• Country:
• 💎
##### Re: understanding zener and high side switching
« Reply #20 on: December 27, 2018, 07:35:27 pm »
if their weird shaped can you use multi variable calculus in a predicable way to figure it out with gradient fields?  like say for one made of rods.

idk how to say this, can you break it up into a bunch of small plates that don't effect each other (real small so flatness can be approximated small) or does it lead to some kind of nonlinearity (sacrificial behavior)? like the presence of the closer areas means the further areas won't be erroded as expected by distance.
« Last Edit: December 27, 2018, 07:41:04 pm by coppercone2 »

#### Ian.M

• Super Contributor
• Posts: 8013
##### Re: understanding zener and high side switching
« Reply #21 on: December 27, 2018, 08:58:07 pm »
The mass of metal eroded from the anode by the transfer of a known charge is going to be pretty reliable, but from there on the distribution of the erosion across the  electrode surface is pretty much a wild-assed guess.   e.g if a biofilm forms on the insulator supporting two partially or occasionally immersed rod electrodes, and stays wet due to ambient conditions, it may have a low enough resistance that the anode erodes at the root and drops off long before its immersed surface is significantly eroded.

In theory, in a electrolyte of uniform conductivity,  the electric field at any point in the electrolyte can be calculated solely from the geometry and applied voltage, then the current density for any small area on an electrode's surface can be solved for.  However the maths is extremely intractable except for simple geometries like long concentric cylinders or parallel plates that are large compared to their separation.
Also, in the real world, ionic mobility and surface polarisation will be  significant and the electrolyte is  rarely uniform due to temperature gradients and local concentration differences.
« Last Edit: December 27, 2018, 09:00:40 pm by Ian.M »

Smf