Give away medical masks when you place an order. learn more

Protecting Inputs in Digital Electronics


In a generic electronic system there are some inputs that are controlled by the end user. These inputs are read by electronics and acted upon by using outputs. The inputs can come from a myriad of sources: buttons, switches, sensors, relays, and communication devices, to name a few. In certain environments and situations, these input signals can pose a threat to the electronics reading them – especially if those electronics are designed without thought of protection. One such environment is the world of industrial electronics.

An important aspect of designs for this environment is interfacing sensitive electronics with inputs coming from the harsh conditions of a factory floor. Usually, inputs are read by some sort of intelligent processor such as a microcontroller, FPGA, or state machine. In cases like these, it is imperative to protect the processor from the inputs, while still providing a usable signal for the processor to read.

Problem definition

In a typical factory system there may be buttons on a control panel located remotely from the central processing unit. The buttons are connected to central processing via long wires. Unfortunately this can lead to inadvertent electronic failure. Long wires can act as an inductor and when a button is opened or closed, large voltage spikes can show up on the electronic paths. Figure 1 shows a simplified diagram of this situation.

Figure 1: Simplified electronic system.

In order to discuss approaches to overcoming this problem, a more specific example will be used. Typical microcontrollers have input impedance on the order of 20 MΩ. In addition, system voltages range from 1.2 V to 5.0 V. In this case, we will assume a 5 V system. Figure 2 shows Figure 1 reconfigured as a simplified electronic model.

Figure 2: Input model into a simplified electronic model.

Using this model, it is easy to see the problems with unprotected inputs. Any large voltage that shows up on input pin is presented directly to the interior electronics (microcontroller). Regardless of how this voltage is produced (ESD, induced EMI, switch closure, user error), this can damage the microcontroller, and perhaps cause the entire system to fail. Because of this, different protection strategies must be implemented to create a robust system.

In order to discuss the problem in detail, a simple system will be set up as shown in Figure 3. It is a simple switch that is connected to a microcontroller with a 25 foot wire connection. Note the switch is a 2-pole switch and it switches between open and ground. A pull-up resistor on the microcontroller causes the open position to be read as ‘high’ by the microcontroller.

Figure 3: Simple switch circuit.

When the position of the switch is changed, a large voltage is induced over the 25 feet of wire, and it appears at the microcontroller. This is demonstrated in Figure 4. Note the minimum voltage caused by the inductive ringing is -5.88V. This is more than large enough to cause serious problems within an electronic system.

With this circuit and the simple scope captures, the large voltage problem can be seen. Now it is time to look at approaches to fixing this problem.

Figure 4: Switch from open to ground.

Protection approaches

An important aspect of microcontroller inputs (and the vast majority of any logic ICs) that was left out of the simple model shown in Figure 3 is that they have internal protection diodes that are used to protect the inputs, as shown in Figure 5. These normally forward bias at 0.7 V.

Under ideal circumstances, this can protect the microcontroller. However, if the voltage is large enough or lasts for a long enough time, it can destroy the internal diodes in a shorted position, thereby ‘breaking’ the input pin. Even worse, the input pin is now directly connected to a power rail, so, when the next large voltage shows up on the input pin, it is shunted directly to the power bus, wreaking havoc throughout the microcontroller and most-likely damaging it further.

Figure 5: Enhanced microcontroller input model.

Even if the diodes are not destroyed, a large ESD spike can induce a current surge through the microcontroller’s power bus, which can corrupt internal registers and settings leading to unpredictable behavior. With all of this in mind, the first attempt to protect the input pin is found within current limiting.

Current limiting

The simplest protection mechanism is a current limiting resistor, as shown in Figure 6. The input resistor is sized so that the voltage drop across it does not affect the voltage at the microcontroller input. As this is a simple voltage divider, and the input resistance in the controller is about 20 MΩ, this resistor can be fairly big. For most digital inputs, a good value is between 100 Ω and 10 kΩ. For our system, a value of 1 kΩ is used.

Figure 6: Current limit protection for an input.

 This type of protection works well for short wire connection lengths and enclosed wire runs (little chance of EMI, etc.). Figure 7 shows how this circuit works to implement the protection. In Figure 7, the ringing edges from the induced voltage are clipped at -0.810 V.

Figure 7: Current limit circuit results.


Figure 6 showed a simple current limit circuit. However, with the addition of a capacitor, more protection can be added by turning the current limit circuit into a simple low-pass filter as shown in Figure 8.

Figure 8: Low pass filter protection for an input.

With this type of circuit, a little more thought must be applied to component selection. Because of the frequency limiting characteristics of the circuit in Figure 8, the value of the resistor and the capacitor must be sized so that the microcontroller does not miss any signals. The simple equation shown in Figure 9 can be used to determine the value of the resistor and the capacitor.

Figure 9: Equation for determining the resistor and capacitor values in a low pass filter circuit used for a digital input.

To calculate the value of R and C, use the following steps:

  • Find the fastest edge of the incoming signal – or determine the fastest frequency of the incoming signal and assume an edge speed of 1/100th of the input period (a 1 kHz input frequency has an edge of 10 µs).
  • Select ‘R’. Usually this can be selected to a common value already in the system, such as 1 kΩ.
  • Use the equation in Figure 9 to determine the value of ‘C’.
  • In some cases, the input signal is a very slow moving signal (button press, switch closure, etc.), so the value of ‘C’ can be then changed to match a common value on the board, as long as the order of magnitude is maintained.
As shown in Figure 8, the values for R and C are 1 kΩ and 0.01 µF (assumed a maximum input frequency of 1 kHz). Figure 10 shows how this circuit works with the input switch circuit. Note how the overshoot edges are now gone compared to Figure 7. This is the effect of the capacitor.

Figure 10: RC filter performance.

One added advantage to the RC filter circuit for a digital input is that it also rejects spurious/fast inputs that could cause false readings on the microcontroller. Unfortunately, for large ESD events and long wire runs, there can still be voltage spikes in the microcontroller because the circuit is relying on the clipping action of the internal diodes. This leads to the next approach.

External clipping diodes

To eliminate the use of the microcontroller’s internal diodes, external Schottky clipping diodes can be used. This is shown in Figure 11. Schottky diodes are implemented because they conduct before the internal diodes of the microcontroller (Schottky diodes forward bias at about 0.2 V as opposed to the 0.7 V of the internal diodes). Note that a small series resistor is used to protect the Schottky diodes from overcurrent. As these diodes are only on for a short time, a small resistor works well; something on the order of 10 Ω usually works fine. Alternatively, the 10 Ω resistor can be omitted if the Schottky diodes are beefy enough to handle short-duration, high current pulses.

Figure 11: External clipping diode circuit.

Figure 12 shows the results of this circuit with the input switch circuit. The yellow trace is the positive side of the capacitor, while the green trace is where the resistor meets the Schottky diodes. Note the negative spike is -0.650 V, which is below the forward bias voltage of the microcontroller. A voltage of this level on a well-designed PCB should not cause any problems.

Figure 12: External diode protection results.

So for the most ruggedized digital input protection, a combination of external resistors, capacitors, and diodes should be used.

Other ideas

These basic ideas can be further expanded for known high voltage inputs. For example, if the input signal was changed to switching a high voltage instead of ground, a circuit like the one shown in Figure 13 can be used.

Figure 13: Reading high voltage inputs.

The input clipping diode to ground is to protect from less than zero volt spikes. The input clipping diode to the positive bus is removed in favor of the zener diode after the current limiting resistor. This provides a known voltage for the input pin and reduces the amount of current shunted to the power bus. In addition, all of the connections on the input are now to ground, which can ease PCB routing. Note, in this case, the current limiting resistor must be sized small enough to provide enough current to allow zener breakdown at the correct voltage (about 1 mA minimum). Figure 14 shows the operation of this circuit, using a switched 12 V input.

Figure 14: Reading large input voltage digital inputs.


When interfacing digital circuitry with the outside world, care must be taken to protect the sensitive electronics. However, the circuitry required to provide the protection is small, inexpensive, and easy to understand. If a little bit of forethought is used when designing the system, many difficulties can be avoided once the system is deployed.

Solutions Cubed and the Hotenda Design Partner Program:

Hotenda, a world leader in high volume electronic component distribution, has included Solutions Cubed, LLC as a design resource. This allows our company to secure competitive pricing for registered designs belonging to our clients. As a Hotenda design resource, Solutions Cubed, LLC and Hotenda work as a team to streamline the design-to-manufacturing phases of product development and work with you to get the best possible solution with pricing as competitive as possible.

Solutions Cubed is an innovative electronic design firm. We have created successful designs for a myriad of industries including mass produced consumer products, deep-sea robotic components, and encrypted decoders for the banking industry. We love meeting new customers and are interested in hearing about your design.