Safety issues when sensing AC voltage  - Page 1
Forum section: electronics / projects

author: yelstor
author_rank: Contributor
timestamp: November 04, 2023, 04:42:15 pm
content: Hello guys,I was asked to upgrade an AVR (AC voltage regulator) because it is using a very old freescale microcontroler wich is hard to find out, besides more expensive.This AVR is very cheap, to make it affordable, so I have been told, new design can not go further than 10% above of the current production price.The way it senses the AC voltage is attached. It is basically and half wave rectifier and resistor divider, then the signal go to the ADC pin. Here, Neutral and micro controller GND are connected. I know, for safety it is better to have microcontroler gnd isolated from mains, but in this case I see no problem because people is not going handle the circuit. The pcb is going inside a box. Right? I am asking you guys because maybe I am forgetting something, that can affect either safety or perfomance.I can sacrifice performance on a cheap design but not safety.It is good to mention this design has worked like that for years and so far nobody has died.Thanks guys.

author: TimFox
author_rank: Super Contributor
timestamp: November 04, 2023, 04:52:01 pm
content: Can you add an inexpensive 60 Hz transformer before the rectifier input, to isolate line neutral from ADC ground?A quick search at Mouser shows this serieshttps://www.mouser.com/datasheet/2/410/F56_020-781680.pdffrom Triad at about $8.00 USD in singles, with a range of secondary voltages available, at about 1.1 VA power.I'm sure the cheap sites have similar parts. These have full safety ratings.

author: yelstor
author_rank: Contributor
timestamp: November 04, 2023, 05:02:06 pm
content: Thanks for the answer.Unfortunatelly, 8USD is quite a lot for this producto. Telling them the price is going up 8 dollars they are going to go crazy. Unless I give them a very good argument . I would like to have a good example in wich situation the current way voltage is being sensed can be consider as a life threat

author: djacobow
author_rank: Super Contributor
timestamp: November 04, 2023, 05:26:15 pm
content: It helps to understand the application. Are you selling these? Where are they in the product? Can we see a photo of the existing board? Was the old board UL or otherwise certified? Do you understand the safety considerations: creepage, fusing, appliance enclosure classes, etc?If you know what you are doing, a circuit like the one you drew can be fine, but it's a big if.

author: zapta
author_rank: Super Contributor
timestamp: November 04, 2023, 05:39:56 pm
content: >> If you know what you are doing, a circuit like the one you drew can be fine, but it's a big if.Are there special safety considerations also on the component selection? E.g. the 300K resistor?

author: TimFox
author_rank: Super Contributor
timestamp: November 04, 2023, 05:54:38 pm
content: Quote from: yelstor on November 04, 2023, 05:02:06 pmThat's the price in singles: I'm sure you can find a similar transformer much cheaper, since it does not require heavy iron for low-power applications.

author: floobydust
author_rank: Super Contributor
timestamp: November 04, 2023, 06:00:59 pm
content: You can't take an old product and toss it at modern safety standards.There is a big difference nowadays.If you "touch" this old design, the safety responsibility is on you, the engineer.Regardless of a cheap, lazy company that wants to make it work with "only little changes" - I would be looking at a redesign of the board, you are changing the MCU anyways. Or tell them you won't touch this old product without redesigning it including safety. It might cost a few dollars more, or not.VACF line would have a fuse, D3 and R5 must be able to withstand mains transient overvoltages, as well as have the required PCB spacings.Example is 300V Cat. II is 2.5kV so how will you ensure those parts can take it? It is likely why the MCU input gets damaged. Several MELF's to make up R5 is what is usually done.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 04, 2023, 06:15:02 pm
content: Adding random isolation layers for no reason does no increase safety (*), so ignore all advice about magical transformers.(*) if you don't understand where the dangers are, reducing them to smaller area is not that helpful, because the risk is still there; for example, if you isolate thepowerbut forget to isolate the voltage measurementsignaland then assume "the power side is safe because it's isolated", you have a classical example offalse sense of security.Without isolation, the circuitryin wholeis simply like any mains wiring, with the related creepage, clearance distances and IP ratings to user accessible parts. Possibly warning notes if that is deemed beneficial to avoid false assumptions.Isolation is needed when you have tointerfacewith SELV / human touchable stuff, but not all electronics need this; LED lightbulbs and simple AVRs (voltage regulators, not the microcontroller brand) are perfect examples. LED lightbulb does not have interfacing at all, and a simple AVR usually just a potentiometer where you can use a plastic shaft (similar to master/slave switches, which also are non-isolated and use plastic shaft potentiometers for adjustment).If you are making a product, reading the relevant standards (to your legislation) is a pretty good idea, so that you will know more exactly what kind of distances, casing and markings are needed for a compliant product.

author: yelstor
author_rank: Contributor
timestamp: November 04, 2023, 11:18:53 pm
content: Quote from: djacobow on November 04, 2023, 05:26:15 pmYes, those AVRs are being sold here in my country for around 20 years. It is used for home apliances such TV, pc, refrigerator etc.There is a national certification this product every year gets wich is based on the standard IEC 60686:1980 (yes, very old standard). Anyways, the only thing I found on this standard about safety was Fusing and earthing. The current product has thermal magnetic breaker for over current, and of course the earth is connected to the chasis. So far I know that standard does not requiere to open up the chasis and check clearances or something like that.Unfortunatelly I do not have now one of these AVRs but inside the box there is only a big autotransformer and the board wich controls some ralys adding or resting depending on the input voltage.The board is held by a plastic bracket, allowing some clearence between the board and the chasis.I can only think in 2 situations where someone can get shocked. If they use the avr without the cover, they could touch the board accidentaly and get shocked. The other one is, for some reason the live wire touches the cover and then user touches the cover. In these 2 situation, I can not blame the product because it is very clear the product must operate with the cover on. In the second example, here it is mandatory to have a diferential circuit breaker, so this one must go off in case some current is going to the earth.I have came up an idea, and is using the autotransformer, give few turns and use this one as my isolated voltage sensor. The problem with this is I would be sensing the input voltage instead the output.

author: yelstor
author_rank: Contributor
timestamp: November 04, 2023, 11:30:29 pm
content: I totally agree with you, more safety the better, but we can not have everything. If we want the safest product with a really good performance, that is not going to be cheap. In this particulary case I think on people safety, but not in the circuit itself safety. If there is a trasient that damage the microcontroller pin, people should understand that they have not bought the best product out there, they have bought the cheapest. You get what you pay for I guess

author: floobydust
author_rank: Super Contributor
timestamp: November 05, 2023, 01:15:57 am
content: Do you want "safety" or not?It's not always electrocution, there can be fire hazard as well. If the old 1980 design has no circuit breaker, for example.

author: coromonadalix
author_rank: Super Contributor
timestamp: November 05, 2023, 01:52:22 am
content: well if the safety is not a priorityi would not help in that case, and saying you want the cost down and get over safety is a NOand some people here will be reluctant to help because you want or may pass a blind eye over this, and nobody here want to assume repercussions or accidentshow much is safety, how much is it worth ...if your "clients" can not understand that DROP THEM even if you're saying it was fine before, the design and considerations are changing ...

author: bdunham7
author_rank: Super Contributor
timestamp: November 05, 2023, 03:23:38 am
content: Quote from: yelstor on November 04, 2023, 04:42:15 pmI think as long as your resistor R5 is an appropriate type I don't see any issue. It should have a high-voltage rating, I've linked a datasheet for a series I would use--they're as little as 5 cents in bulk. Having control circuitry floating at mains potential is actually not so uncommon and as long as the circuit board is appropriately spaced and isolated, I think it's fine. I don't know what specific regulations you have to meet and I'm no expert in that area, so perhaps there is more to think about. I don't think anyone can give you an actual answer here in that regard without a diagram and description of the entire product. One issue I would look at is to make sure that the input impedance of the ADC pin on your replacement device is sufficiently high, since this circuit only provides a few hundred microamperes. Also, D3 should be a 1N4007 or similar if it isn't already (cheap, good) and I don't see why D4 is needed. If you are going SMD, then you'll need to look up different parts but the same idea applies.https://www.vishay.com/docs/30260/hvr2537.pdf

author: CaptDon
author_rank: Super Contributor
timestamp: November 05, 2023, 02:39:16 pm
content: I'm curious about how the 'regulator' portion works? Is it an SCR / Triac control similar to a dimmer or is it more like a mechanically driven variac?Perhaps a tap changing autotransformer? Circuits being referenced to neutral could be o.k. but can you be certain there is no possibility of the unit being mis-wired if it gets moved to another location on the factory floor? Are the any external connections to the MCU like a data link or voltage monitor output connected to an external computer for instance that would get blown to smitherines in the event neutral and hot got swapped? Your name is on the final re-design in the event someone gets killed!!

author: soldar
author_rank: Super Contributor
timestamp: November 05, 2023, 11:02:00 pm
content: This is what optoisolators are for.

author: miket6000
author_rank: Contributor
timestamp: November 06, 2023, 01:51:51 am
content: Assuming the AVR is properly designed there is nothing inheritly unsafe with the digital electronics being mains referenced, it's done in appliance design all the time. If course the assumption is that suitable creepage and clearances are meet and that the design is either double isolated (class II) or in an earthed enclosure (class I).As a hardware (and / or SW) developer you will need to be very careful about programming and developing the controls.The questions you're asking on a public forum do seem to suggest you don't have the skills to be developing something like this for public use, especially since you don't seem to be aware of the compliance requirements and are suggesting there will be no detailed 3rd party compliance checks.I would be very careful, if you do make a mistake it's ultimately you who could be responsible for an accident.

author: yelstor
author_rank: Contributor
timestamp: November 07, 2023, 01:20:59 pm
content: Thanks guys for your help.Here I atach the schematic of the product that is actually being used. My job is to change only the box that controls taps.I am going to check out high voltage resistor and ADC impendance. I am still looking for one microcontroller, but I think I am going to go with STM32C0(very good price for 32bits).

author: wraper
author_rank: Unknown
timestamp: November 07, 2023, 01:32:36 pm
content: As Siwastaja said adding layers of "safety theater" does not improve actual safety. If circuit is totally isolated from human, adding random isolation only increases cost but has no beneficial impact on actual safety whatsoever.

author: wraper
author_rank: Unknown
timestamp: November 07, 2023, 01:36:59 pm
content: Quote from: coromonadalix on November 05, 2023, 01:52:22 amSuggesting adding random transformers is not helpful at all. Those who suggested transformer did not even ask if MCU is powered from isolated source to begin with, which I really doubt.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 07, 2023, 02:25:08 pm
content: It's simply that some people can't resist the temptation of hitting the "reply" button and writesomething, even when they don't understand the question and have nothing to contribute. These people could be easily replaced by ChatGPT. For some reason, magic keyword of "safety" triggers all sort of zero-information "but think about the children" rationalizations. People whose mind work like this are a significant safety risk because they always fall for false sense of security, every time. They also mask real discussion which could be had about real safety, which, in this case, would be about enclosure design, plastic flammability ratings, impact testing, IP ratings, clearances and creepages. Adding a transformer does not change the fact that the damn circuit still operates on mains and therefore these safety aspects cannot be avoided.

author: wraper
author_rank: Unknown
timestamp: November 07, 2023, 03:19:26 pm
content: BTW I suggest to get rid of R7 potentiometer and do digital calibration instead.

author: floobydust
author_rank: Super Contributor
timestamp: November 07, 2023, 06:40:54 pm
content: The MOV clamps spikes to a lower voltage, check the part's rating because that gives you some slack with spacings and the HV resistor requirements. I never see just one resistor used for voltage sense on 240VAC systems - it's typically 2-3 parts in series, MELF preferred.The relays used for tap changing will arc a lot so the EMI will be high level, your board will need some extra design I would say.

author: yelstor
author_rank: Contributor
timestamp: November 07, 2023, 07:43:20 pm
content: Thanks guys. You all have really helped me a lot. I did not want to add more "safety" when is not really needed.I think the idea of dividing 120V resistor in more in series is really good. I am going to apply it.I am going to follow up mechanical design to give a good clearence between the chasis and board.Cheers

author: wraper
author_rank: Unknown
timestamp: November 07, 2023, 08:35:09 pm
content: Quantity of resistors in series needed depends on their voltage rating. Overall larger resistors have higher voltage raring but you need to check the datasheets as it can vary quite a bit between different series and there are special high voltage series too. There is nothing wrong with single resistor if it's a part with appropriate ratings.EDIT: if you suspect this design may be assembled with random resistor series in future, of course it's better to just put multiple of them so it will be fine regardless of part used.

author: yelstor
author_rank: Contributor
timestamp: November 07, 2023, 09:04:25 pm
content: unfortunatelly I dont know where are they sourcing this resistor. thats why I think its better to go safe and add multiple series resistor do divide the voltage. Space it's not a problem on this design. besides I know they are preatty mean and as soon I leave the project working, they are going to start looking where to save some cents.

author: Marco
author_rank: Super Contributor
timestamp: November 07, 2023, 11:27:50 pm
content: Is there a standard warning label for circuit boards to indicate any part of the circuit is likely to be live?

author: Terry Bites
author_rank: Super Contributor
timestamp: November 10, 2023, 02:28:48 pm
content: Something like thisYou can bias up the attenuated AC to keep it in range for your ADC.Most resistors are rated for a max of 250V so you need a string to protect against a short. A series cap limits the current in the chain if all else fails.A Zener, a MOV, a fuse and a Class X cap will protect you from most nastys.Always check for a single fault condition that will either kill you or your hardware.

author: wraper
author_rank: Unknown
timestamp: November 10, 2023, 04:19:40 pm
content: Quote from: Terry Bites on November 10, 2023, 02:28:48 pmYou don't want to place a zener diode directly on the signal though as it will affect the measurement due to leakage current below breakdown voltage or at least it should have quite a bit of headroom above actual voltage. 3.3V zener is certainly not suitable for 2.5V signal if you look into datasheet. 10n Cx is completely counterproductive here, what it will do the best is screwing up waveform and passing fast transients right through. 20mA fuse has no meaningful function too.

author: David Hess
author_rank: Super Contributor
timestamp: November 11, 2023, 02:36:33 am
content: There is nothing wrong with the circuit or idea if it is implemented properly.Quote from: zapta on November 04, 2023, 05:39:56 pmThe series dropping resistor should be a high voltage and fusible type. Better would be to use two resistors in series so one failing would not cause excessive current.

author: wraper
author_rank: Unknown
timestamp: November 11, 2023, 09:08:58 am
content: Quote from: David Hess on November 11, 2023, 02:36:33 amWrong, there is no current possible that would ever trip fusible resistor. Although resistors extremely rarely (like almost never) fail with some resistance reduction, they never fail short. Not to say fusible resistors do not even exist with such resistance values to begin with.

author: Siwastaja
author_rank: Super Contributor
timestamp: November 11, 2023, 11:56:05 am
content: Quote from: wraper on November 11, 2023, 09:08:58 amThis. Fusible resistors are used when small resistance values are needed for current limiting (e.g. cheap-than-NTC-ass inrush limiting); they basically combine resistance and fuse in one package, fuse part of which sucks compared to a real fuse, but is just barely acceptable and offers lowest price and smallest size.OP simply needs to decide between a high voltage rated part, or putting more easily second-sourceable standard parts in series. Enough of them, assuming worst-case voltage rating, which for resistors (ignoring the absolute smallest packages) is 200V. Sometimes designers specify a physically larger part, by specifying higher power rating than they actually need (and getting larger body as a side effect), because they are often rated to 300V or even more, in which case two in series would (probably, maybe) suffice.But legislation is different everywhere and so is grid quality, and if your TRIAC or whatever dies anyway after some peak voltage, it makes little sense to make the resistor divider better than that. Lightning strikes cause overvoltage spikes on countryside, which may be or may not be a huge problem.

author: PCB.Wiz
author_rank: Super Contributor
timestamp: November 12, 2023, 02:35:25 am
content: Quote from: yelstor on November 04, 2023, 04:42:15 pmYup, if everything is 'hot' there is no need to isolate mains sense.This is measuring the voltage, you do notneedto be as low as 330k, which is 160mW at 230V.You did not mention SMD, but with new designs in SMD, it is common to use resistors in series to spread the voltage, and heat. Surge rated parts are better.For replacement MCU, almost any small 8b (or better) MCU with enough pins, can managemeasure mains and wiggle outputsdecisions.