I wrote about this system before. But I will focus my questions now on “ESD protection” direction. I have an SPI based system in which a Raspberry talks with a GPIO expender device using SPI communication. The chip reads and/or writes ‘0’/’1′ and send it to the Raspberry by bus. Expander GPIOs circuit is a very simple circuit. But somedays a dangerous overconsumption has been triggered randomly after hours of correctly working. This stops when I reset the device. After this, device is having a normal behaviour and normal consumption. Nowadays system is being connected and tested on a protoboard. So, wiring or lab material may be affecting a little -or a lot-.
Some people suggested me this behaviour seems to be a “latch up” caused by ESD. Otherwise it could be caused by voltage spikes, positives spikes or negatives GND ones. So, they tall me that my GPIOs needs to be protected with resistors, diodes and capacitors. But I don’t see any example with diodes, Cs and Rs protecting inputs/outputs at uC neither MCP based projects. As much I have seen is serial resistors at some of the GPIOs pins.
My circuit is too much simpler than those I have seen:
- 8 expander pins will be inputs. The rest will be outputs.
- Expander outputs will be writing ‘0’, never ‘1’.
- Expander inputs has an internal Rpull up that put input at 3.3V when not connected.
- I put a wire at every output and this wire could be connected directly to the inputs or not. So when read the 8 input pins, those who are connected to the inputs will read ‘0’, and the rest, will read ‘1’.
- An input would read these 3 scenarios:
- ‘1’ (when not connected),
- ‘0’ ouptut writing (if they are connected)
- ‘0’ = GND (if a GND point makes direct contact with an input).
A particular characteristic of this system is that GPIOs will not be configured as inputs or output for the rest of the times. So during one execution a pin can be configured as an input during initialization, but at the next execution the same pin could be configured to be an output.
This overheating phenomena doesn’t happens more than once or twice per day. But I’m afraid that only one time phenomena is enough for destroying the system.
At final PCB design GPIOs pins will be traced through the board achieving a 64-pin connector. Input and output will be connected through a wire that will connect -or not- two of this 64-pin connector pins. This way a circuit between one input and one output could be closed. But there could also be open circuits between the rest of input-outputs.
I have added 10Rs at every device GPIO and using a 100nF between VDD and GND. It seems not to happen anymore two days ago, but I would like to ensure my GPIOs if the circuit really needs.
Does this circuit need GPIO protection? Are these resistor enough?circuit-designraspberry-pispigpioesdshareedit follow flagedited 12 hours agoasked 14 hours agoEugenia Suarez52322 silver badges99 bronze badges
- 1If you did not have any bypass caps over the supply pins at the chip, that alone can cause all kinds of issues. But since you tried so many things at once, it is impossible to know what will help and what does not. I would have tried to figure out whether the two pins were accidentally set both to outputs, as then it is not a latchup caused by ESD, but maybe programming or communication error. – Justme 13 hours ago
- Ups! sorry I forgot drawing it, but there is a 100nF capacitor! so sorry! – Eugenia Suarez 13 hours ago
- @Justme I’ve read a lot of literature about this the last 3 days, and one of the ways for protecting in front of just what you say: programming errors and inputs being configured as outputs, was R series. So I put series resistors at every GPIO pin. It has two functions: current limitation in case of mistakes and improvement against ESD. Someone suggested me to use from 10K up to 200K. But I know there is users that has been used 200Ohms when inputs have push buttons – Eugenia Suarez 12 hours ago
- There seems some confusion. Let me clarify. (1) ESD usually destroys components when a human handling the components (a) before the component is inserted into the circuit, AND (b) the human is not earthed and he at the same time carries electrostatic charge. If your components are already in circuit, then there is no ESD problem. / to continue, … – tlfong01 12 hours ago
- Perhaps you are talking about two other things: (1) power mains surge. When there is a black out because of mains overloading (what you say “over consumption”, too many air cons say) tripping over MCB. And when everybody switches on/off at the same time afterwards, there might be surges/spikes from building’s nearby sub station. These spikes might be over 220V’s peak and resets the Rpi. Usually there should be no harm to Rpi because it gets only 5V power from adapter, not directly from mains, / to continue, … – tlfong01 12 hours ago
- And there is another thing called “back EMF”. If you are using Rpi to control inductive loads, like motor, solenoid or fan, perhaps by using 5V relay or SSR. Then when switchin off (a) the relay, and/or (b) the motor or solenoid, there might be a back EMF which is a voltage spike, sometimes a couple of time of the original power supply, causing current flow back to the Rpi’s circuit. This back EMF is usually minimized by using (i) “flyback” diode, (ii) optoisolation circuits. But the spikes might travel through the ground lines and trigger/reset the Rpi. / to continue, … – tlfong01 11 hours ago
- And “latching up” is another thing. Take Rpi for example, if one Rpi GPIO pin is in input mode, and the GPIO pin is connected through a series resistor to a 5V source. Then there is a 5% chance that “latching up” might happen, frying the Rpi’s GPIO pin circuit, or shortening the Rpi’s life. / to continue, … – tlfong01 11 hours ago
- To get a rough idea of “latching up”, you might like to read my answer to the following question: (1) “Rpi3 might have been fried by wrongly connected DHT11 temparature sensor – Rpi SE Latching up Q&A”: raspberrypi.stackexchange.com/questions/96560/…. Cheers. – tlfong01 11 hours ago
- some random comments. (1) If you are using MCP23S17, then you are using Rpi’s MOSI, MISO, CS to talk to MCP23S17. If what you are referring as GPIO, are MCP23S17’s GPIO pins, then don’t worry, because any spike, back EMF stuff will first fry MCP23S17, and Rpi hiding behind should be “safe”. (2) Usually when a Rpi or MCP23S17 GPIO is in output mode, and you want to protect it from shorting to ground, or shorting to another GPIO output pin and so they are fighting each other, then the usual trick is to use a series resistor, say 330R or 470R. / to continue, … – tlfong01 11 hours ago
- Using 10K is OK if your GPIO is to control a MOS device with high impedance input. But if the device is BJT, then the biasing resistance is usually 220R to 1k, then using 10k series to protect GPIO is a bit overdoing. Just casually talking aloud, my apologies for the typos. Ah, bed time. See you tomorrow. – tlfong01 11 hours ago
- Ah, I forgot that your Rpi also uses GPIO pins to set the address pins (A0 to A2) of the MCP23S17, but that should not cause any problem. A safe way is just tie those A0 to A2 pins direct to Vcc and/or Ground. Cheers. – tlfong01 11 hours ago
- (1) One more thing, about the MCP23x17 reset pin. When playing with MCP23x17, I found that the chip from time to time go crazy, and I need to push the manual reset button which I install because I find very useful in debugging. I do suspect that MCP23x17 is very noise sensitive, so might go crazy if your SPI/I2C connecting wires are very long (> 60cm). (2) Another thing is that I find it a good idea of not connecting MCP23x17’s interrupt pin direct to Rpi. Instead you use Rpi to loop the MCP23s17 interrupt status registers. Cheers. – tlfong01 2 secs ago Edit