Author Topic: Help with AC ground question  (Read 1529 times)

0 Members and 1 Guest are viewing this topic.

Offline lmagalhaesTopic starter

  • Contributor
  • Posts: 43
  • Country: pt
Help with AC ground question
« on: July 17, 2019, 08:10:35 am »
Hi there,

I've been working mostly with low voltage stuff, microcontrollers and the like, but now at my new job, I've been asked to design a circuit that needs to switch the hot AC wires. I'm fairly confident in that, but came across something that confused me a bit and want to make sure I'm not doing something stupid.

The system in question has a boiler with auto-level detection and the way it detects the water level is by using some probes. Those probes are connected to the boiler chassis, which is connected to AC ground (earth). So, to detect the water, you need to detect when the probe is shorted to the boiler chassis via AC ground. My first instinct was to connect it to a microcontroller pin with a pull-up and when the pin goes low, you know that water has reached that probe. However, for that to work, AC ground needs to be connected to the circuit ground. Since I don't have experience with AC, I ask if this is fine, if it should be protected with something, if it will cause some ground loops or if I'm doing it all wrong.

Thanks in advance,

Luís
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4694
  • Country: au
  • Question Everything... Except This Statement
Re: Help with AC ground question
« Reply #1 on: July 17, 2019, 08:51:51 am »
I would recommend an optocoupler for your detection, a string of resistors (higher voltage rating) to limit to e.g. 0.5mA to activate the optocoupler and detect it with your micro never touching mains

If you can you should prevent your circuit from being in direct contact with mains where possible, try and use relays and optocouplers to keep things seperate,

You use multiple resistors in series for mains as each has a certain voltage it will breakdown at, so by using say 4 that are each rated at 250V, you can have 1 fail and never have any major issues.

 

Offline lmagalhaesTopic starter

  • Contributor
  • Posts: 43
  • Country: pt
Re: Help with AC ground question
« Reply #2 on: July 17, 2019, 08:59:43 am »
The digital part of the circuit is being supplied with a transformer and full bridge rectifier, so it's not in direct contact with the mains. Also, the AC switching is being done with TRIACs and optocouplers, as you've said, and it's working well.

The problem is with the water detection inside the boiler. Since the probe is floating until water reaches it and, when it does, it shorts to AC ground, how could I use the resistors and optocoupler for the detection ? Are you suggesting to have a resistor divider from the phase and then, when water hits the probe, it will short to AC ground? If not then I didn't understand
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12986
Re: Help with AC ground question
« Reply #3 on: July 17, 2019, 09:40:08 am »
Its a bad idea to put DC on the probes as, unless they are made of platinum or other highly corrosion resistant precious metal, thecurrent flow when immersed will cause electrolytic corrosion of the positive electrode.  You *MAY* get away with it if the probes are very small with respect to the ground electrode and you bias them negative so the ground electrode is the one that corrodes.

Its preferable to energise the probes with  low voltage AC, as on the negative going half cycle, metal ions tend to get redeposited close to where they were liberated from the metal surface on the previous positive going half cycle vastly slowing the effective corrosion rate.

Its possible to use a MCU PWM module to generate a squarewave probe excitation signal, boost it with something like a MOSFET driver then capacitively couple it to each probe so there is no net DC current.   For detection the signal can also be capacitively coupled to a charge pump to get a DC level to indicate whether or not the probe is immersed.  Whether you then take that direct to a digital input pin with a schmitt characteristic, use a comparator or use an ADC input pin depends on how fault tolerant you want it to be.  Direct to a digital input means you will have to compromise on sensor drive levels etc. to get reliable discrimination between immersed/non-immersed, and any sensor problems wont be noticed until they cause a false indication.  Using a comparator you get free choice of threshold, and thus drive level.   Using an ADC input, you can monitor the sensor 'health' and if the steady state signal level gets too close to your chosen threshold, you can alert the operator that sensor maintenance is required, *before* it actually fails.

Its a lot easier if your MCU board 0V can be coupled to AC ground at the boiler chassis.    If your overall system design calls for the MCU board to be mounted remotely this may not be possible, and that may require differential amplifiers for the probe signals to cancel out any noise or other difference between chassis ground and MCU 0V  and maybe even transformer coupling for the excitation signal.
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4694
  • Country: au
  • Question Everything... Except This Statement
Re: Help with AC ground question
« Reply #4 on: July 17, 2019, 10:34:17 am »
Your thoughts are correct, Live - A few voltage rated resistors spaced accordingly - optocoupler - probe

Then the micro is just monitoring the other side of the optocoupler for when it shorts you will see pulses
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6947
  • Country: pl
Re: Help with AC ground question
« Reply #5 on: July 17, 2019, 04:52:18 pm »
I'm not familiar with mains safety rules, but that seems just weird to me.

I presume the boiler has separate neutral and protective earth connections and its chassis and water sensors are tied to PE.

Connecting to PE some circuit board powered by an isolated transformer and optoisolated from TRIACs seems fine to me, that's what every PC computer and lots of audio/video gear does. It surely can be made safely (nobody gets electrocuted by TVs and computers) and legally (those things are being sold).

OTOH, driving a sensor connected to PE with pullup resistors to mains? Not sure what's good about it. Also, it's another little contribution to mains leakage; power up enough of those boilers and you trip the RCD. Not very power efficient either. :-//

Oh, and another nitpick
Live - A few voltage rated resistors spaced accordingly - optocoupler - probe
Add an antiparallel diode to the optocoupler or make sure its reverse voltage rating exceeds mains peak and any transients you want to survive :P
« Last Edit: July 17, 2019, 05:26:43 pm by magic »
 

Offline lmagalhaesTopic starter

  • Contributor
  • Posts: 43
  • Country: pt
Re: Help with AC ground question
« Reply #6 on: July 23, 2019, 11:25:18 am »
The boiler itself only has the chassis connected to earth. The probe used here is something like this:



So the middle part is where you tighten it up to the chassis, doing a connection to earth. The middle rod can go up and down to define the water level you want to measure. This rod is floating if not touching the water, that's why I wanted to have a weak pull-up to VCC. When water reaches it, it shorts (hopefully) with the chassis of the boiler. This is why I wanted to have the digital ground and the earth at the same potential or coupled in some way.

What you guys are suggesting is that instead of driving DC, it should have an AC voltage due to corrosion ? But still, how about the earth connection ? Is it safe to have a wire going from earth to digital ground? I guess not, but want to make sure
 

Offline cs.dk

  • Supporter
  • ****
  • Posts: 642
  • Country: dk
Re: Help with AC ground question
« Reply #7 on: July 23, 2019, 05:44:45 pm »
You can buy those level switches as isolated units. They are two wired, sometimes with plastic threads (maybe not good for a boiler), but you get the point.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12986
Re: Help with AC ground question
« Reply #8 on: July 23, 2019, 06:28:07 pm »
Its possible to AC couple the probe to prevent electrolytic corrosion, while still using a simple pullup if you pulse the pullup voltage. i.e. only turn it on briefly when you need to check the sensor.  LTspice sim attached.

As Magic points out its quite usual to ground the 0V rail of a microcontroller or computer.  Its normally perfectly safe to do so, but we cant tell you if the rest of your design which we haven't seen may make it unsafe, or if there are any special electrical regulations applicable to boilers in your jurisdiction that might effectively prohibit grounding the MCU 0V rail
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6947
  • Country: pl
Re: Help with AC ground question
« Reply #9 on: July 23, 2019, 09:47:46 pm »
The one case where grounding is prohibited that I know of are so-called SELV circuits. These use double/reinforced insulation from mains so that they cannot reasonably become shorted to mains themselves and additionally they aren't earthed, so that they cannot become a ground return path for some unfortunate user who ends up touching a SELV circuit and some other, high voltage circuit at the same time.

SELV is supposedly required in some circumstances. No idea where and when.

A grounded boiler certainly isn't SELV itself, because it's grounded ;)

However, if the logic board has some connections to the external world, it is theoretically possible that some users would want to plug it into SELV circuits. In such case, your device should not provide ground connection to the logic board, even if the whole chassis is grounded, because that would compromise the external SELV circuit.

I have seen one high power machine in earthed metal chassis, whose control board was internally isolated from earth and all earth-referenced electronics and it was advertised as compatible with SELV circuits. If somebody pays you for SELV compatibility, grounding is out of question. But you would probably already know, and your boiler likely doesn't have any electronic interfaces in the first place.

Other than that, most devices you own at home with three prong plugs have all their digital boards grounded to Earth. And they work fine and still haven't killed you if you are reading this :P

All of the above assumes that the boiler is grounded to protective earth. If it's grounded to neutral, that's a horrible thing in itself and you really shouldn't be doing it. And it will be banned it most of the world the moment anyone finds out.

Also, another thing about using mains voltage to sense that sensor: I'm no expert on regulations, but I wonder if it is even legal to do so? Shouldn't all current from mains be returned to neutral rather than PE?
« Last Edit: July 23, 2019, 09:54:36 pm by magic »
 

Offline lmagalhaesTopic starter

  • Contributor
  • Posts: 43
  • Country: pt
Re: Help with AC ground question
« Reply #10 on: July 24, 2019, 08:19:10 am »
The mains is only used to supply power to some transformers, after which have full bridge rectifiers and a large cap. The live is switched on and off with the TRIACS and, per regulation, you can't even have a plug to connect to the wall (by our laws), since you could flip the live and the neutral with european plugs. So the logic board doesn't have any other connection to the mains, even the live is only switched on and off.

About the boiler itself, it is connected to earth (or protective ground). The heater element is connected to live and neutral. Hopefully that doesn't mess with the whole system here and it shouldn't, honestly. If it did, it would trip the breaker right? So, in theory, this should all *just* work.

For a safety precaution, maybe having an isolated 5V converter and an optocoupler to receive the probe level isn't that bad of an idea.. If, for some reason, it couples to live or neutral, it only damages that part of the circuit and not the 5V rail it's associated with and the microcontroller directly.

EDIT: using an isolated DC-DC converter, I can have a separate ground to turn on the LEDs of of the optocoupler and only have this virtual ground connected to earth right ? That way, I don't have to make the whole digital gnd as earth, which will decrease the chances of it going BOOM on my face.
« Last Edit: July 24, 2019, 09:47:39 am by lmagalhaes »
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6947
  • Country: pl
Re: Help with AC ground question
« Reply #11 on: July 24, 2019, 09:28:00 am »
The heater could be a problem if its insulation breaks down and sends mains current through water to protective earth. Then the water sensor may see several volts on it before circuit breaker trips and perhaps damage the control board or put hazardous voltage on user accessible parts. I guess you're right and it should be isolated.

For power supply, besides integrated switchers, I have seen tiny transformers with a few mA of current capacity and dimensions like 30x20x20mm. This could be an option too and it gives AC output for free.

Finally, there is the option of simply taking current from mains as somebody suggested, but I don't know if it's legal and it still requires some decent resistors to withstand all mains transients and prevent failures.

Alternatively, ground the PCB and sense the probe trough a capacitor, as suggested by Ian.M. It's not grounding the PCB which causes danger, but connecting it to a wire submerged in water. Perhaps a suitably rated safety capacitor (Y class?) between the board and the sensor would be enough, plus generous safety clearances and a transil to protect the MCU from capacitively coupled crap in the event water goes live. But I have no idea about those things, better ask somebody familiar with regulations in your area.
« Last Edit: July 24, 2019, 09:39:43 am by magic »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12986
Re: Help with AC ground question
« Reply #12 on: July 24, 2019, 10:05:48 am »
A water heater element in the E.U. almost certainly has a grounded metal sheath so the probability of a significant leakage current to the sensing electrode is negligible.   If the heating element fails in a way that puts current into the water (which is virtually impossible: the sheath would have to corrode through completely at both ends before the water penetrating the insulation caused the element to short to the sheath and fuse + requires the supply to it not to be RCD protected), does it really matter if the control board fails as well as long as it doesn't cause a safety hazard?

However if you needed to mitigate that a heavy duty bidirectional TVS diode could be put from the sensor signal to ground to clamp any line frequency voltage on the sensor to something the MCU board can withstand, possibly with a fuse between it and the sensor in case salt contamination (e.g. from a water softener) increases conductivity far beyond what would normally be expected.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8354
  • Country: fi
Re: Help with AC ground question
« Reply #13 on: July 24, 2019, 10:49:07 am »
Threads like this tend to end up in a total trainwreck full of misconceptions.

I would request only the following proper terms are used:
PE: protective earth
L: Live
N: Neutral

Both L&N are considered "hot" or dangerous wires. To simplify, think both of them as "L". This is because many countries use them interchangebly by using nonpolarized plugs. Even the countries where the plugs are polarized, it's a common mistake to mix them up. So N is often L.

PE is connected literally everywhere and never mixed up with L. (Whenever it is mixed up, it's a very rare and serious crime, worth reporting to the police as an attempted manslaughter, either on purpose, or by negligence.)

I have come to the conclusion that having word "ground" in the same sentence as "mains" and "safety" discredits the whole sentence. This is a major source of confusion. What is ground?

Many power supplies just internally connect the output minus to the PE. This means, your microcontroller ground reference may already be connected to PE. If not, doing that causes absolutely no harm whatsoever. It's just on the same potential than all the pipework and most device metal cases are already.

The microcontroller circuit actually becomes completely irrelevant. The safety of the heating element is important regardless of the microcontroller circuit and its grounding. If you use the microcontroller to turn the heater on/off, then this subpart of the circuit must be dealt with properly, but it wasn't the OP's question.

Apart from possible corrosion issues, there is nothing wrong in what you suggest. I don't see how an optocoupler does anything in that circuit (except improve ESD performance). You would still need to reference it to the same PE, and still power the detection (optocoupler input) from something referenced to PE.
« Last Edit: July 24, 2019, 10:56:14 am by Siwastaja »
 
The following users thanked this post: Zucca

Online magic

  • Super Contributor
  • ***
  • Posts: 6947
  • Country: pl
Re: Help with AC ground question
« Reply #14 on: July 24, 2019, 11:20:20 am »
Many power supplies just internally connect the output minus to the PE. This means, your microcontroller ground reference may already be connected to PE. If not, doing that causes absolutely no harm whatsoever.
I mostly agree except for this paragraph. There are installations where grounding is not desired. Don't ask me, but I know that they exist (search SELV). OP's probably isn't one of them, though.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf