0
\$\begingroup\$

Let's take the ATmega328P for example. It has a minimum input voltage of -0.5 and maximum input voltage of Vcc + 0.5.

enter image description here

But what if I say Vcc = -5 V and GND = 0 V? Will it break then, because the minimum voltage is lower than -0.5V?

How can I protect the inputs from negative voltages?

This is a way to protect a MCU pin e.g ADC input from high voltage, but it does not protect if I set GND to -10 V. The linear voltage regulator has a diode as protection, but I don't know if that helps.

enter image description here

Update:

Let's say that we have three cases:

Case 1: If A = Positive, B = 0V and C = High, then the zener diode will protect. - OK!

Case 2: If A = 0V, B = Positive and C = 0V, then current is going to flow from B -> C and leaving a voltage drop at A0 depending on how large R1 is. This can hurt my analog input A0 - How can I protect it in that case?

Case 3: If B = Negative and A = Positive, this will hurt my MCU directly. How can I protect it in this case?

enter image description here

\$\endgroup\$
10
  • \$\begingroup\$ "How can I protect inputs from negative voltage" -- What are the specifications / range of voltage (min, max) that can possibly appear in that input pin? \$\endgroup\$
    – Mitu Raj
    Commented Nov 30, 2021 at 18:49
  • \$\begingroup\$ What's the use case here? Are you afraid of accidental or intentional application of negative voltage? \$\endgroup\$
    – vir
    Commented Nov 30, 2021 at 18:51
  • 1
    \$\begingroup\$ In your diagram, what is the source of the "0 V" signal and the "-10 V" signal? \$\endgroup\$
    – The Photon
    Commented Nov 30, 2021 at 18:51
  • 1
    \$\begingroup\$ "say Vcc = -5V and GND = 0V volt" [...] "I set GND = -10V" It is unclear how the power rails of the uC relate to the other voltages in the circuit. \$\endgroup\$
    – devnull
    Commented Nov 30, 2021 at 18:53
  • \$\begingroup\$ @ThePhoton The -10 is the GND and 0V is the input signal. In this case, it's a voltage divider for scale down 0-10V to 0-5V. \$\endgroup\$
    – euraad
    Commented Nov 30, 2021 at 18:54

4 Answers 4

2
\$\begingroup\$

How can I protect the inputs from negative voltages?

Using diodes and Zener's is not accurate when protecting inputs for your MCUs. If you want to protect the input then use a device such as the TLV6001 to buffer the input signals. This is the only way to provide professional protection that is viable for both digital and A/D inputs.

A simple circuit such as this will provide accurate translation of the 0-5v signal for any application.

schematic

simulate this circuit – Schematic created using CircuitLab

The TLV6001 (or TLV6004) is rated for rail-rail operation and so allows the full range of MCU range for A/D input ...in addition the device is rated to carry 10mA in the input protection diodes, though you need to provide the series resistor. This allows the configuration shown above to withstand voltages of +/-200 V on the input resistor R2 (providing your resistors are rated for this voltage). If you only need protection for say 24-58VDC you can reduce the input resistor to suit your need.

Since the TLV600 is powered by the MCU +5 V supply it cannot produce an output voltage above 5 V or below 0 V, so the input is accurately clamped WITHOUT impacting the A/D range at all, and of course this would work for digital inputs just as well. You must make sure that your MCU solution is always drawing a minimum current greater than your expected protection current (this is only an issue if you put things into a sleep state).

You always need to provide a good ground/0V reference on your interface, it is never a good idea to capture signal relative to a power supply rail.

\$\endgroup\$
1
  • \$\begingroup\$ I like this one! \$\endgroup\$
    – euraad
    Commented Nov 30, 2021 at 22:38
2
\$\begingroup\$

But what if I say Vcc = -5V and GND = 0V volt? Then it will break?

Yes, it will break.

You will be forward biasing the ESD protection diodes on every IO pin, and sending uncontrolled current through them. This will almost certainly damage the chip within a fraction of a second.

How can I protect the inputs from negative voltage?

You can connect a Schottky diode with its cathode connected to the data line and anode connected to ground (the same node as the ground pins of the uC). Use a resistor in series with the signal to limit current through the Schottky diode.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
17
  • \$\begingroup\$ Yes! I have a zener diode. Do you think that's OK? \$\endgroup\$
    – euraad
    Commented Nov 30, 2021 at 19:00
  • 1
    \$\begingroup\$ Do not use a zener diode on an analog input! The zener diode will begin to conduct before the rated voltage and cause analog errors. \$\endgroup\$
    – Kartman
    Commented Nov 30, 2021 at 19:18
  • 1
    \$\begingroup\$ @MrYui, no you want a Schottky diode, not a Zener. A zener will likely have a high enough forward voltage to provide no protection to the internal ESD protection diodes. \$\endgroup\$
    – The Photon
    Commented Nov 30, 2021 at 19:22
  • 1
    \$\begingroup\$ @MrYui, voltage is a measurement between 2 points. If "They set negative voltage on GND", then where is the 0V you're measuring this negative voltage from? \$\endgroup\$
    – brhans
    Commented Nov 30, 2021 at 20:17
  • 1
    \$\begingroup\$ @MrYui, the picture you're trying to draw with words just doesn't make sense. You need to actually draw what you're trying to describe before this conversation can go much further. But I strongly suspect that once you draw it you might start to see the contradictions in what you're describing... If Falstad won't cooperate then draw it on paper and take a pic if you must. But this site also has a built-in schematic editor you can use if you edit your question. \$\endgroup\$
    – brhans
    Commented Nov 30, 2021 at 20:30
2
\$\begingroup\$

Voltage is relative, you are correct there. BUT you can't put things in opposite polarity, because in the context of the microcontroller, you're going outside it's operating parameters according to the datasheet.

But what if I say Vcc = -5V and GND = 0V volt? Then it will break?

Yes, it will break.

Now an interesting thing you can do with this knowledge is to run the microcontroller with Vcc=0V and Gnd=-5V. Note, this doesn't violate the datasheet, and note the polarity! 0V is greater than -5V. Also, if you were to do something like this, you'll need to run your entire circuit at these shifted voltages, or else make a properly designed voltage translator to interface to something that is running at the more common Gnd=0V reference.

EDIT: After seeing more comments on the OP, this answer doesn't really apply to the OP, but leaving it for anyone else who needs to do some non-common circuit design.

\$\endgroup\$
2
  • \$\begingroup\$ Good post! FYI, we do this a lot in the GaAs RF world. These devices like to be powered with 0V and -5V. In order to control them, the inputs need to stay within that range. So we power the controlling digital device with Vdd (Vcc) =0V and GND (or Vss) = -5V. Then we level translate whatever is providing the inputs to the controlling digital device. \$\endgroup\$
    – SteveSh
    Commented Nov 30, 2021 at 21:55
  • \$\begingroup\$ @SteveSh Thanks! On my first job out of college I was tasked with running a 5V chip off a 24V supply by hanging it off the 24V rail and create a 19V rail for ground. Bent my mind a bit, but opened my eyes. \$\endgroup\$
    – Aaron
    Commented Dec 2, 2021 at 20:26
0
\$\begingroup\$

This is a solution. I use a PNP transistor. Now when I apply -10V, then I get very low voltage to the MCU pin. If I apply +10V, then I get 5 voltage to the MCU pin because the zener diode is at 5V level.

enter image description here

Or one could use a simple "fools diod" between ground and input. Then all the current will flow from GND to the input.

enter image description here

\$\endgroup\$

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.