Protection against short on gpio? - Page 1
Forum section: electronics / beginners

author: thephantom1492
author_rank: Contributor
timestamp: May 08, 2025, 08:36:59 pm
content: Hi there,I have a circuit that I want to protect against a direct short to 24V/gnd.It is a 500kbps serial data out of a STM32F103 microcontroller.Currently the gpio for Rx and Tx are directly exposed to the world, and a miswiring or wiring short result in magic smoke release.I need to protect both ends. Problem is, the other side have a very limited board space (maybe 8x8mm) and can't be enlarged.There is about 1M of wires between both circuits, with 4 wires linking them: GND, 24V, 3.3v Rx, 3.3v Tx.It do not needs to stay 3.3V. I considered a rs232 tranceiver, but what I found is too big.Also, I will make them assembled by jlcpcb, so parts should be available there.What can I use?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 09, 2025, 07:52:06 am
content: Quote from: thephantom1492 on May 08, 2025, 08:36:59 pmThat is a quite serious design flaw. Microcontroller pins are simply not designed to be exposed to the outside world, and also not designed to drive a meter of off-board wire. Older generations (5V) uC's tend to have quite robust I/O and survive short circuits (to their own power supply or GND), but when the die shrinks started happening with newer revisions 20+ years ago, those old chips also became less robust.I guess that single gate logic chips, combined with a series resistor may be a good start for an upgrade. A capacitor over the series resistor can help with improving the rates of the flanks. Even a resistor as low as 20 Ohms already helps, but higher values provide better protection, but also slow down the flanks.Shorts to +24V are more problematic. No logic family is designed for that. You can add a few diodes (or a zener) to clamp the signal line, and then add an PPTC to protect the diodes from excessive current.

author: PGPG
author_rank: Frequent Contributor
timestamp: May 09, 2025, 09:42:10 am
content: Quote from: thephantom1492 on May 08, 2025, 08:36:59 pmIt have to be 500kbps or it just happened to be 500kbps?The simplest (and not taking much space) way to have robust i/o is to use OC signalling.Since 90s I am using BC847 50V transistors in SOT323.Configured as 5mA current source it can withstand even continuous short to 24V.I have never analysed the max speed I can reach with OC as for communication I use RS485.

author: thephantom1492
author_rank: Contributor
timestamp: May 09, 2025, 12:33:14 pm
content: Quote from: PGPG on May 09, 2025, 09:42:10 amBoth. Actually just made the math, and due to the modulation it is the equivalent of 614.4kbps.

author: Psi
author_rank: Super Contributor
timestamp: May 09, 2025, 12:44:46 pm
content: Clamping diodes and a series resistor to prevent the diodes from overheating. (Or a polyfuse that will trip before the diodes overheat.)You can use the protection diodes inside the MCU in some cases but you need a pretty large resistor and that reduces drive strength/speed to something that usually makes it useless.

author: wraper
author_rank: Unknown
timestamp: May 09, 2025, 12:49:38 pm
content: Quote from: Psi on May 09, 2025, 12:44:46 pmExcept you will fry MCU by overvolting it through VDD anyway. Protection diodes only work as long as there is where to sink that current without overvolting anything.

author: Psi
author_rank: Super Contributor
timestamp: May 09, 2025, 12:50:57 pm
content: True, edited.

author: CountChocula
author_rank: Unknown
timestamp: May 09, 2025, 12:55:19 pm
content: Can you put a 1k resistor in front of the pin on each end, and add a reverse-biased ~3.5V zener diode in between the resistor and the GPIO pin to shunt the current to ground when the voltage exceeds 3.3V? You might be able to get away with a higher resistor, but assuming 100pF of loop capacitance, 1k is probably not going to interfere with your transmission speed.

author: thephantom1492
author_rank: Contributor
timestamp: May 09, 2025, 12:58:03 pm
content: Quote from: wraper on May 09, 2025, 12:49:38 pmThat is one issue with lots of solutions out there. Most just redirect the energy to the rails. Some have a way too high TVS. Others are just too big for the board space I have, with doubtfull effectiveness as they market it for ESD only.

author: thephantom1492
author_rank: Contributor
timestamp: May 09, 2025, 01:23:15 pm
content: Quote from: CountChocula on May 09, 2025, 12:55:19 pmI'm worried about the noise, I need to protect both ends, so it would be 2k, with 1M of cable between both...

author: tszaboo
author_rank: Super Contributor
timestamp: May 09, 2025, 01:31:18 pm
content: Quote from: wraper on May 09, 2025, 12:49:38 pmTrue, my suggestion is that VCC clamp diodes are used together with appropriately sized zeners on the rails. But probably better use TVS diodes that clamp to the GND. It's difficult to give one generic answer as we don't know if it needs ESD protection, surge protection, protection against wiring issues or it needs to fulfill a specific standard.

author: thephantom1492
author_rank: Contributor
timestamp: May 09, 2025, 02:15:04 pm
content: Trying to protect against wiring damage and miswiring.

author: DavidAlfa
author_rank: Super Contributor
timestamp: May 09, 2025, 02:28:48 pm
content: What about zeners/TVS diodes and PTC fuses?They can be found in very small packages.

author: thephantom1492
author_rank: Contributor
timestamp: May 09, 2025, 03:03:32 pm
content: Quote from: DavidAlfa on May 09, 2025, 02:28:48 pmThat may be what I'll use, with a series resistor. I was hopping to find a better solution.

author: ifrythings
author_rank: Contributor
timestamp: May 09, 2025, 08:40:40 pm
content: How about using CAN transceivers? They are heavy protected usually up to 42v or more.

author: thephantom1492
author_rank: Contributor
timestamp: May 10, 2025, 01:43:06 am
content: Quote from: ifrythings on May 09, 2025, 08:40:40 pmthat would require a change in hardware and software, no?edit: looked at some, they have a max of 6V on the CAN side, with zener or tvs on the CAN, which mean a 24V short would kill it.

author: ledtester
author_rank: Super Contributor
timestamp: May 10, 2025, 04:15:00 am
content: Quote from: thephantom1492 on May 08, 2025, 08:36:59 pmI realize it would be nice to put the protection on the PCB but if there is 1M of cabling between the devices you could also put it at one end of the cable assembly.

author: thephantom1492
author_rank: Contributor
timestamp: May 10, 2025, 04:17:26 am
content: Quote from: ledtester on May 10, 2025, 04:15:00 amThat is sadly not possible, there is a risk of cabling damage leading to the fault.I am considering some tranceivers of some sort that might work, but space is problematic. A max232 would have probably worked, but way too big.

author: ifrythings
author_rank: Contributor
timestamp: May 10, 2025, 12:14:27 pm
content: Quote from: thephantom1492 on May 10, 2025, 01:43:06 amYou don’t have to use the CAN protocol to use these, only thing you have to watch out for is the minimum speed so you don’t activate the TXD dominant time out.Not sure where you read 6v max but for example the TJA1042 supports up to -58v to +58v on the CANH & CANL pins and -27v to +27v between CANH & CANL pins.

author: thephantom1492
author_rank: Contributor
timestamp: May 10, 2025, 09:34:51 pm
content: Quote from: ifrythings on May 10, 2025, 12:14:27 pmOh nice one! Not sure if I can use it however, I do not have 5V on the board, only 3.3, and no space for a 5V reg, of course...Do you know of a 3.3V only one?I'll see if I can modify things to work on 5V instead of 3.3...

author: ifrythings
author_rank: Contributor
timestamp: May 11, 2025, 01:34:24 am
content: Something like the TCAN3414DDFR should work, it’s new and fairly cheap and even comes in the small 8 pin vson package if you’re able to solder those on. Only thing you really have to add is the decoupling cap and a 120ohm resistor.

author: David Hess
author_rank: Super Contributor
timestamp: May 11, 2025, 02:46:51 am
content: Quote from: thephantom1492 on May 08, 2025, 08:36:59 pmGood ...QuoteGood ...QuoteBad ...The method I would normally recommend is not going to fit inside that area. Cannot just use an open collector driver with resistor pull-up because it would not survive a 24 volt short without foldback current limiting, or some other complexity. There should be a fault protected driver and receiver, similar to RS-232, which could be used, but I could not find it.Ok, here is something that will work within your space constraints.Small high resistance *depletion* mode MOSFETslike the LND150K1-G will current limit at 1 to 3 milliamps with their gate shorted to their source. One in series with its source and gate connected to each pin, and the drain becoming the output or input connection, will protect against say a +60 volt short with 50% derating.A higher current part could be used by adding some resistance in series with the source to tailor the current limiting. A JFET could also be used.

author: Zero999
author_rank: Super Contributor
timestamp: May 11, 2025, 01:56:39 pm
content: It depends on what the maximum acceptable current is?A J-FET can be used to limit the current from the 24V supply.

author: PGPG
author_rank: Frequent Contributor
timestamp: May 11, 2025, 02:47:46 pm
content: Quote from: David Hess on May 11, 2025, 02:46:51 amOf course foldback current limiting would be better, but I believe there are situations when OC with pull-up can survive 24V short without foldback.Typical OC I met use 4k7 to 5V pull-up. So about 1mA. If the same pull-up is on the other side transistor have to drive 2mA.If you drive base with resistor divider giving about 1V and use 62 ohm in emitter you get about 5mA current source. Loaded with 2mA you have about 120mV drop at emitter resistor plus may be 100mV at saturated transistor so you output something like 0.25V what should be correctly recognized as 0 state.Now shorted to 24V you have 24*5=120mW power dissipation in transistor. Assuming 50% signal fill you have 60mW average in transistor.I am using such solution since 30 years but with intention to survive 12V short (or surge pulse limited to 25V by 18V transil). I have 33 ohm in emitter and use little higher than 1V base voltage but of course not for 500kbps signalling.

author: David Hess
author_rank: Super Contributor
timestamp: May 11, 2025, 06:49:05 pm
content: Quote from: PGPG on May 11, 2025, 02:47:46 pmThe problem I found was that a passive circuit with a high enough impedance to limit the current to a safe level was too high to allow 500 kHz operation. There are active circuits which could be used, but they would require too much space unless part of an integrated driver which I did not find.There are active low impedance protection circuits which would allow very high speeds, but they also take too much space.Quote from: Zero999 on May 11, 2025, 01:56:39 pmI started with the lowest current limiting depletion mode FET of 1 to 3 milliamps and declared victory. The current can be lowered further with a resistance in series with the source, but this means taking more space for the resistor.A current higher than 3 milliamps should be safe, but at some point a higher power FET is required, and schottky diodes have to be added to route the fault current into the positive supply of the microcontroller, which again takes more space.I would prefer a different circuit, but given the space constraints, I would go with the depletion mode FET protection circuit. Depletion mode MOSFETs have an advantage here over JFETs because they are available with much higher power and voltage ratings, but either could work.

author: thephantom1492
author_rank: Contributor
timestamp: May 12, 2025, 03:18:56 pm
content: I will go with a CAN tranceiver.Is there an advantage on 3.3V vs 5V for CAN communication? Is 5V more noise immune?

author: ifrythings
author_rank: Contributor
timestamp: May 12, 2025, 04:26:42 pm
content: No real difference between the voltages, most automotive modules run on 5v so a lot of the CAN chips are built for that voltage spec.One thing I forgot about is you can’t send and receive at the same time, this may or may not be an issues depending on how your application is setup.

author: Zero999
author_rank: Super Contributor
timestamp: May 12, 2025, 09:40:25 pm
content: Another option is a small incandescent lamp. A 24V 20mA lamp should adequately limit the current and glow nicely, if it's connected to 24V.

author: langwadt
author_rank: Super Contributor
timestamp: May 12, 2025, 09:46:18 pm
content: Quote from: ifrythings on May 12, 2025, 04:26:42 pm3.3V works and there are 3.3V CAN transceivers, but afair you need 5V to be fully compliant with the CAN standard

author: thephantom1492
author_rank: Contributor
timestamp: May 12, 2025, 11:15:29 pm
content: Quote from: langwadt on May 12, 2025, 09:46:18 pmI've been able to find a way to make space for the CAN tranceiver on both sides! On one side it can work on 3.3 or 5V, I found a CAN tranceiver that work at 5V. On the other side, I found a way to run 3.3 and 5V to the tranceiver, so I will be able to use that!While it won't be compilant due to the protocol, it will carry plain 115200 serial no issue. Max speed is 8M on those chip, min is 9.6k, so I'm all good. And I believe 5V CAN will be also more noise tolerant at the same time.