Author Topic: Protection against short on gpio?  (Read 2847 times)

0 Members and 1 Guest are viewing this topic.

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Protection against short on gpio?
« on: May 08, 2025, 08:36:59 pm »
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?
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 4671
  • Country: nl
Re: Protection against short on gpio?
« Reply #1 on: May 09, 2025, 07:52:06 am »
Currently the gpio for Rx and Tx are directly exposed to the world,

That 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.
« Last Edit: May 09, 2025, 07:54:59 am by Doctorandus_P »
 
The following users thanked this post: neillnz

Offline PGPG

  • Frequent Contributor
  • **
  • Posts: 908
  • Country: pl
Re: Protection against short on gpio?
« Reply #2 on: May 09, 2025, 09:42:10 am »
It is a 500kbps serial data out of a STM32F103 microcontroller.

It 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.
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #3 on: May 09, 2025, 12:33:14 pm »
It have to be 500kbps or it just happened to be 500kbps?

Both. Actually just made the math, and due to the modulation it is the equivalent of 614.4kbps.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 11412
  • Country: nz
Re: Protection against short on gpio?
« Reply #4 on: May 09, 2025, 12:44:46 pm »
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.
« Last Edit: May 09, 2025, 12:54:49 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Online wraper

  • Supporter
  • ****
  • Posts: 18891
  • Country: lv
Re: Protection against short on gpio?
« Reply #5 on: May 09, 2025, 12:49:38 pm »
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 but you need a pretty large resistor that reduces drive strength/speed.
Assuming a pin can source/sink 30mA.   24V on pin + 3.3V = 27.3V      27.3V/0.03A = more than 910 ohms in series.
Except 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.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 11412
  • Country: nz
Re: Protection against short on gpio?
« Reply #6 on: May 09, 2025, 12:50:57 pm »
True, edited.
« Last Edit: May 09, 2025, 12:57:06 pm by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline CountChocula

  • Supporter
  • ****
  • Posts: 209
  • Country: ca
  • I break things—sometimes on purpose.
Re: Protection against short on gpio?
« Reply #7 on: May 09, 2025, 12:55:19 pm »
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.
Lab is where your DMM is.
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #8 on: May 09, 2025, 12:58:03 pm »
Except 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.

That 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.
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #9 on: May 09, 2025, 01:23:15 pm »
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.

I'm worried about the noise, I need to protect both ends, so it would be 2k, with 1M of cable between both...
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 9232
  • Country: nl
  • Current job: ATEX product design
Re: Protection against short on gpio?
« Reply #10 on: May 09, 2025, 01:31:18 pm »
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 but you need a pretty large resistor that reduces drive strength/speed.
Assuming a pin can source/sink 30mA.   24V on pin + 3.3V = 27.3V      27.3V/0.03A = more than 910 ohms in series.
Except 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.
True, 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.
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #11 on: May 09, 2025, 02:15:04 pm »
Trying to protect against wiring damage and miswiring.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 6820
  • Country: es
Re: Protection against short on gpio?
« Reply #12 on: May 09, 2025, 02:28:48 pm »
What about zeners/TVS diodes and PTC fuses?
They can be found in very small packages.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #13 on: May 09, 2025, 03:03:32 pm »
What about zeners/TVS diodes and PTC fuses?
They can be found in very small packages.

That may be what I'll use, with a series resistor. I was hopping to find a better solution.
 

Offline ifrythings

  • Contributor
  • Posts: 37
  • Country: ca
Re: Protection against short on gpio?
« Reply #14 on: May 09, 2025, 08:40:40 pm »
How about using CAN transceivers? They are heavy protected usually up to 42v or more.
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #15 on: May 10, 2025, 01:43:06 am »
How about using CAN transceivers? They are heavy protected usually up to 42v or more.

that 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.
« Last Edit: May 10, 2025, 02:47:29 am by thephantom1492 »
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3838
  • Country: us
Re: Protection against short on gpio?
« Reply #16 on: May 10, 2025, 04:15:00 am »
... 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.

I 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.
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #17 on: May 10, 2025, 04:17:26 am »
I 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.

That 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.
 

Offline ifrythings

  • Contributor
  • Posts: 37
  • Country: ca
Re: Protection against short on gpio?
« Reply #18 on: May 10, 2025, 12:14:27 pm »
How about using CAN transceivers? They are heavy protected usually up to 42v or more.

that 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.

You 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.
 

Offline thephantom1492Topic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Protection against short on gpio?
« Reply #19 on: May 10, 2025, 09:34:51 pm »
You 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.

Oh  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...
 

Offline ifrythings

  • Contributor
  • Posts: 37
  • Country: ca
Re: Protection against short on gpio?
« Reply #20 on: May 11, 2025, 01:34:24 am »
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.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 18750
  • Country: us
  • DavidH
Re: Protection against short on gpio?
« Reply #21 on: May 11, 2025, 02:46:51 am »
I have a circuit that I want to protect against a direct short to 24V/gnd.

Good ...

Quote
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.

Good ...

Quote
Problem is, the other side have a very limited board space (maybe 8x8mm) and can't be enlarged.

Bad ...

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 MOSFETs like 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.
« Last Edit: May 11, 2025, 03:06:28 am by David Hess »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 21897
  • Country: gb
  • 0999
Re: Protection against short on gpio?
« Reply #22 on: May 11, 2025, 01:56:39 pm »
It depends on what the maximum acceptable current is?

A J-FET can be used to limit the current from the 24V supply.

 

Offline PGPG

  • Frequent Contributor
  • **
  • Posts: 908
  • Country: pl
Re: Protection against short on gpio?
« Reply #23 on: May 11, 2025, 02:47:46 pm »
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.

Of 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.
« Last Edit: May 11, 2025, 02:53:45 pm by PGPG »
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 18750
  • Country: us
  • DavidH
Re: Protection against short on gpio?
« Reply #24 on: May 11, 2025, 06:49:05 pm »
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.

Of 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.

The 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.

It depends on what the maximum acceptable current is?

A J-FET can be used to limit the current from the 24V supply.

I 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.

« Last Edit: May 11, 2025, 06:50:58 pm by David Hess »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf