0

For an application with UART that I am working on, it is very easy to swap wires. Generally speaking, I have 4 wires: TX and RX for UART, and the 2 supply wires (VIN = 230V AC and GND). What is the best way to avoid any possible error, even if very unlikely, to prevent any damage to my hardware? Diodes? MOSFETS? More elegant and efficient ideas?

Assuming, for example, I connect VIN to TX, does it make sense to somehow limit the voltage to 5V, since my TX and RX lines are square-wave sequences of 5V? If so, how?

Idea 2: Would it make sense to block the AC voltage on TX, RX and GND lines?

Edit: connectors cannot be replaced with polarized ones. Edit2: the greatest risk is to unintentionally supply RX, TX or GND with 230 V AC (VIN).

mdir28
  • 1
  • 1
  • 5
    Make your wires unswappable and use a polarized connector. – DKNguyen Dec 05 '22 at 15:18
  • I forgot to mention that this is not an option, unfortunately. – mdir28 Dec 05 '22 at 15:21
  • 2
    Then provide more details. – DKNguyen Dec 05 '22 at 15:22
  • The solution must be found on the PCB, adding new components because the ones I currently have are not replaceable. I am sorry for the low level of detail I have provided. I currently have a complex board and a UART interface with these 4 wires. Imagine the latter simply as a box connected to TX,RX,VIN and GND and I can act only here, adding a "protection circuit" in between. – mdir28 Dec 05 '22 at 15:30
  • Color code supply red and ground black? As for mixing up tx and rx, it's the curse of UART development. Doesn't matter how much thought you put into it, "Murphy's Law" will always screw something up. – Lundin Dec 05 '22 at 15:36
  • 6
    So you have an unpolarized connector with mains and uart connections and you are looking for how to protect the uart. No offense, but this seems like an accident waiting to happen. – StainlessSteelRat Dec 05 '22 at 16:02
  • some type of a crowbar circuit may work ... is your device actually legal for commercial use? – jsotola Dec 05 '22 at 16:19
  • Yes...My device will be released to the market at some point. – mdir28 Dec 05 '22 at 16:29
  • how are you connecting the wires now? ... please add a picture of the connector – jsotola Dec 05 '22 at 16:44
  • 4
    There might be safety reasons why your device can be banned if you have an unpolarized plug with both mains and low voltage. Seriously, redesign it already. You don't want and endless stream of people complaining about blown up devices or electrocuted installers. – Justme Dec 05 '22 at 16:46
  • 2
    I see you edited to say your power lines aren't a low DC voltage, but are in fact 230VAC. No, just no. Redesign. If you can add things to the PCB then you can split the terminal block or whatever connector you are using into two so the high voltage is separated. Is your PCB even properly laid out for the HV and LV to begin with? I have my doubts about that. – DKNguyen Dec 06 '22 at 15:27
  • No way a regulaory agency will aprove 230V + UART on an unpolarized connector. Nature will always invent a better quality idiot when you attempt to make something idiot proof. We can't design for that, but you are not even trying. – StainlessSteelRat Dec 06 '22 at 18:01

2 Answers2

4

This really needs to be put in an answer and not be buried in comments.

Your design, as described, is a law suit waiting to happen. I doubt it would pass a safety standard review.

You are describing a single connector carrying UART TX and RX, plus 230V AC mains hot and neutral.

First of all, a UART needs three wires: TX, RX and common. I have to assume you are using mains neutral as UART common. This is a disaster. Your country mains plugs better be polarized and even if it is, you never know when an outlet might be wired backwards. Connect UART common to 230 V AC will destroy your box and whatever is connected to the UART, was well as potentially electrocuting the user!

Even if you could guarantee the mains connection, the mains neutral can easily rise a few volts above ground potential if you have a heavy load on the circuit.

You also need to worry about creepage. You need to space the mains voltage far enough away from low voltage circuits (as well as between hot and neutral) to avoid arcing, especially if the PCB gets dirty. If you open up a small brand-name (not Chinese crap) AC to low voltage regulator, such as a mains-to-USB phone power supply, You will see that they have actually cut slots in the PCB to increase the effective distance between mains voltage and low voltage.

This is all ignoring your original question about avoiding accidentally connections mains hot to a UART terminal.

Please do yourself a big favor and redesign to use standard connectors. You probably want to put your mains voltage into a IEC C8 or C14 connector so a standard power cord can be used. For the UART, particularly is using RS232 signaling, a D Sub 9 pin connector is standard although people also use RJ11 and RJ45 connectors.

DoxyLover
  • 7,876
  • 1
  • 18
  • 24
  • 1
    Dunno what market OP is designing for, but in the EU we're not even allowed to run mains and signal cables together (and that's with 3-4 layers of insulation separating the conductors). Putting both into a single connector is _absolutely not going to fly_, such a product is going to be pulled from the market the moment it appears on the shelves. I suspect at least the US takes a similarly dim view of similarly _creative_ solutions. – TooTea Dec 06 '22 at 07:45
2

The greatest risk is to unintentionally supply RX, TX or GND with 230 V AC (VIN)

I'm not qualified to answer but perhaps have the RX and TX lines isolated by the normally open (N.O.) connections of a relay rated for a control voltage of 230 V AC supplied from the VIN pin. Relay rated for 230 V control side and contacts

The switching side also needs to be 230 V AC rated to safely isolate the fault condition you describe.

Having 230V AC on the same PCB as TTL-level UART signals usually means lots of creepage and isolation countermeasures AFAIK. Slots, spacing, MOVs, high rupture capacity fuses capable of breaking high currents etc?

AFAIK there's no way to guard against VIN GND reversal because you don't have a distinct protective earth separate from neutral. So your whole device would have to be double insulated to EU/US standards.

RedGrittyBrick
  • 14,602
  • 5
  • 37
  • 77