8
\$\begingroup\$

I'm using the SM32F207Z MCU for input/outputs digital processing. The MCU will also handle Ethernet communications. I/O port functions will be provided by 16 + 16 digital input/outputs.

Our application will read logic levels from GPIO pins configured as inputs, but it is also able to write to a GPIO pin port configured as an output.

Our application consists of a '0' level input detection on 16 input pins. Every pin has a 10K pull-up to 3.3 V to give a default read level of logic high. I have also added a current limiter resistor in case a pin is programmed as an output by mistake.

input circuit and pcb inputs connector

The application will also use GPIO outputs to control external loads, such as LEDs, relays etc. Obviously, NMOS transistors will be needed for this output proposal and this part is our choice.

From the outside, our card interface could be seen as a '0' detector and '0' writable card, a kind of 'NPN inputs, NPN outputs concept'. We can read '0' from one pin and we can also put '0' in other one in order to close external input/output circuitry. Briefly: the card reads GND and it also gives GND to some user-attached circuits.

one output circuit

Having said this, users must give a 'GND' or 'hi-Z' to the input pins through their external circuits. The user's input circuits should not drive voltages into here, but this could happen by user error.

connection between external GND node and PCB input connectors

I want to design the input circuit to withstand an accidental 12 V or 24 V into an input that expects 3.3 V or 5 V.

It doesn't seem to occur much but we don't want the card to be damaged by it when it happens, if it is possible.

As I have read in a datasheet, I/O pins can allow less than 3.3 V or 5 V but it depends on the kind of pin.

max rating

The same is happening at the outputs. The external circuit is connecting its GND reference node there. Their circuit node (their GND node) could be driven by our card with a steady logic high, a steady logic low or be switched at a frequency. But sometimes, users could accidentally connect a voltage to our card output instead of the correct load node (GND node). I know nMOS maximum VDS value can be up to 30V, so I don't panic about damage to the card if a user puts 12V..24V by mistake onto an output pin.

I think the risk of card circuitry damage is at the input pins.

enter image description here

The first thought that comes to my head is using the Zener and TVS diodes. But Zener is designed for steady states and TVS seems to deal with transients. I also consider the worst case situation, where users could continue, not realising they've made a bad connection. I don't know how TVS handles a continuous overload condition. On the other hand I have read that a Zener diode could give problems with the input read level due its leakage current.

I would also use double Schottky diodes to protect my ADC inputs from overvoltage because they are better than a Zener for this, but that's not the same situation. I have seen discussion about this topic. But I think that my case has two factor that makes this one different.

  • The most cases deal with transient situation. My case is close to be a steady voltage situation (1, 2,.., even 5 minutes).
  • I don't see any diodes solution with pull up resistor at the input. I think that way could be adding an undesirable current path from 24V node to 3.3V.

schematic

simulate this circuit – Schematic created using CircuitLab

I made simulations for the above circuit, taking GPIO internal impedance as resistor value from 100K to 1M (I don't find it on datasheet). Some simulators shown the zener limitation with this solution. The main one is the current that it can drive, such as 5mA. My configuration is driveng about 5mA. If I push up the resistor value I can decrease the zener current, but GPIO Low state goes up, near logic level bordier. Making some resistors exchange I find that my GPIO low level logic state is compromised by the current I need to decrease.

So:

  1. I would like to know how to give a protection against putting voltages greater than 3.3V/5V at MCU input pins. Out of fuses, TVS diodes, Zener diodes up to 24 V, which one is better?

  2. How should I correctly connect the diodes to my input circuit to work, specially with the pull-up resistor and serial resistor?

  3. How should I choose the correct parameters for the diode?

Thanks to the post cooperators I have achieved two kind of solutions. My prefered and most popular one was a zener based protection. But theorically I can adjust values for keeping the 3 voltage values that application needs to be read correctly. I think it is because of low current that zener allows. It is forcing a higher resistor values than voltage divisor needs to get 3.3V.

Then I went to Schottky solution that someone from here suggest me. It would work theorically fine. The last step is to test with real devices. But bring the real circuit results will take some time. So I will put my proposal at the end of the question.

Final proposals

Interactive link here: for life simulations clik here

\$\endgroup\$
4
  • 5
    \$\begingroup\$ Putting aside a little grammar, this is an excellently-written question with a lot of effort put into it that's to be applauded. I'm pleased to upvote it :-) But I'm sure this question, or variations of it, have been answered many times on this site. Did you find anything by searching for keywords? \$\endgroup\$
    – TonyM
    Commented Sep 14, 2022 at 15:48
  • 1
    \$\begingroup\$ Take a look at this answer and see if the circuit there can be a basis for your input circuit. You will need to consider the logic low voltages that will reach your GPIO input through the diode. But it will give you protection from over-voltages and a (say 2K2) series resistor between the diode/pull-up and the GPIO would give some undervoltage protection with another clamp diode. \$\endgroup\$
    – TonyM
    Commented Sep 15, 2022 at 16:37
  • 1
    \$\begingroup\$ @TonyM thanks for your compliment. I tried to efford with the best. I added some words and circuit in order to explain what I'm looking for here with this post. I don't know what to do with the Rpull up and the limiter resistor if a Zener is used. I begin to be convinced that final solution is zener based circuit. But I'm not really sure on how to connect the diode with the other parts. I have even chosen a specific part. But once again I also need to be sure about diode parameters for a good part selection. \$\endgroup\$
    – Suvi_Eu
    Commented Sep 16, 2022 at 11:58
  • \$\begingroup\$ @TonyM If I can not find a zener diode with an higher Iz than 5mA I would consider your shared answer link. First I need to calculate the 3 voltage level that it needs to keep under limits of the GPIOs for a correct interpretation. I hope this configuration works for me. \$\endgroup\$
    – Suvi_Eu
    Commented Sep 20, 2022 at 11:38

2 Answers 2

3
\$\begingroup\$

Cost and PCB area are important factors during protection design. Since we don't have any hint about this I won't consider them.

Let's assume a generic GPIO structure like the following one:

enter image description here

Photo taken there:

https://www.artekit.eu/doc/guides/all-about-gpios/

Using a generic series resistance is a good choice (remember current is what destroy the pin!), but this one can't be be sized too much high in order to guarantee enough current the GPIO (you would risk to can't the signal). Therefore this is a basic solution, very helpful to avoid ESD and overcurrent caused when connecting electronic system with different ground potentials!

The easier way to overcome your problem ("Protect MCU GPIOs") can be to use an intermediate buffer or photocoupler for each gpio (solution non cost and PCB area efficient).

If you want a different solution with Diodes, you have to size an external pull up diode ( for the positive swing) with the relative resistance in series.

Hoping to be helpful.

\$\endgroup\$
9
  • \$\begingroup\$ thanks for your atention and explanations.I thought I have put that optos was not an option. I was moving on the diodes scope.I did what you said. I've arrived to the point in which series resistor value is compromising zener Iz vs VIL (voltage for low logic level).The best aproach that I could achieve is a resistor value where the circuit works at bordier acceptable values. This is very risky for the application. Sometimes could work fine and sometimes it could make this wrong. Little tolerances could bring the circuit to unstable point. So I followed another suggestion: schottky in series. \$\endgroup\$
    – Suvi_Eu
    Commented Sep 20, 2022 at 14:17
  • 1
    \$\begingroup\$ using a a schottky diode in series is an effective way but keep in mind that if an overvoltage would come, it could destroy the schottky and it would act in an indefinite way! Generally you have to condition the GPIO input or the problem is transferred to the schottky. However this thoughs are strictly related to the application. \$\endgroup\$
    – UMBRO93
    Commented Sep 20, 2022 at 14:34
  • 1
    \$\begingroup\$ yes, it can withstand 30V. An eventual solution could be to tie a signals group to a tvs in order to withstand eventual overvaltges (keep an eye on the quiescent current of the TVS, it can affect the quality of the line's signal!). However after the schottky diode I would continue using a small resistor. \$\endgroup\$
    – UMBRO93
    Commented Sep 21, 2022 at 6:32
  • 1
    \$\begingroup\$ The fact is that zener solution would work fine if internal input GPIO is close to 1M, but if it is close to 100K voltage levels fall in "red" zone (undefined states bordier). I don't find information about manufacturer considerations about this. So I went to schottky option and it seems to solve the Zener results and it keeps the 3 situations that application deals with 100K and 1M internal impedance. Anyways, you are refering to 150 Ohms (iex) when you said "a little series resistance"? or a lower one? \$\endgroup\$
    – Suvi_Eu
    Commented Sep 21, 2022 at 7:27
  • 1
    \$\begingroup\$ yes, for GPIO pin if not externally connected, I go even for 24 ohms. It depens on the device and its connections. \$\endgroup\$
    – UMBRO93
    Commented Sep 21, 2022 at 7:33
1
\$\begingroup\$

When I do something like this I design the input similar to what you did then place a resistor in series with the port pin, after the pull up instead in front of it. At this point I also add a small cap to help transient response and bouncing of the switches. I tend to use 24K on a 24V system for pull ups. The input protection diodes will protect the processor. You need to be sure the power supplies will either clamp or sink the additional current during the transient, mainly through the pull up resistors. I try to keep the input current to the micro to less than 0.5mA worse case with a 100K resistor in series with the port pin. I want at least 1mA for my input load, that would place the pull up resistors at 3.3K ea.

I would change your output circuit where the 10K resistor is from the port pin to ground. This eliminates the voltage divider to the gate and also assures it is off during reset etc. I would change the gate resistor to something in the 25 ohm range. Your output MOSFET will work fine but be sure to derate it as you are not fully enhancing it.

\$\endgroup\$
2
  • \$\begingroup\$ Hi @Gil, thank you. I was thinking about your proposal. Two question. When you say "input protection diodes" are you refering to the internal microcontroler input diodes, isn't it? When you say "You need to be sure the power supplies will either clamp or sink the additional current during the transient" how can I be sure? connecting diodes to every DC voltage rails (3.3V, 5V, etc..) of the circuit? \$\endgroup\$
    – Suvi_Eu
    Commented Sep 21, 2022 at 13:04
  • 1
    \$\begingroup\$ You are correct, the internal diodes. What happens when the transient occurs the input resistors will putting additional current into the microprocessor VCC and the pull up source. Those circuits have to adsorb it or the VCC will rise potentially damaging other parts. My circuits were not low current so I did not have any problems but I always put a zener in that is above VCC but below the max the devices will tolerate. You need to look at the zener curves to see where that point is. The bulk of the current depending on values should go back through the pull up resistors (12/24VDC). \$\endgroup\$
    – Gil
    Commented Sep 21, 2022 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.