Microcontroller Interfacing – Part 10

Input Protection


Integrated circuits (ICs) are made up of sensitive transistors. Most are rated for 3 to 5 Volts DC although newer ones operate at even lower voltages. Exceeding that voltage can damage or destroy the IC.  Electro Static Discharges (ESD) from human contact can exceed 10,000 Volts. This section describes methods for protecting microcontroller inputs.

Static Electricity Input Protection with R/C filtering.

Semiconductors are really fragile critters.  If you exceed the maximum voltage you can burn it out. If the input voltage goes below ground by more than a few tenths of a volt, the whole IC can latch up in a high current mode and burn up.   Static electricity can build up on the user and then discharge through your circuit when they touch a switch or other control.  Putting some protection on the inputs can be a good idea.

Figure 10-1 shows a switch configuration similar to that shown in Part 6.  Two additional parts are added, R2 and C1.  Adding just R2 by itself will provide some protection.  If a voltage spike is applied to the switch the resistor R2 will limit the current flowing into the input port.  Typically R2 will be between 10 and a few hundred ohms.

Adding C1 will improve protection to the input.  A capacitor resists change in the voltage across it. The capacitor will become charged as current flows into it. The amount of current will be limited by the value of R2.   The time it takes to charge to the input voltage will increase as the capacitance of C1 and the value of R2 increases.  Figure 10-2 shows the voltage across a capacitor with a step input. 

Figure 10-1

Assume that the input voltage Vin and voltage across the capacitor Vc is zero volts. At some point Vin jumps to the value V.  At that instant Vc is still zero volts. Over time the capacitor will start to charge and if Vin stays at V long enough, Vc will approach V.  The rate Vc approaches V depends on the time constant (TC). 


Where R is resistance of R in ohms, and C is capacitance of C in Farads. TC is measured in seconds.

The voltage at time t can be calculated with the following equation:


At a period of 1 TC Vc will reach about 63% of V.  At 2 TC the voltage will reach 63% of the remaining difference between Vc and V, or about 86% of V, and so on.  At 4 * TC Vc will be within 99% of V. Technically Vc will never reach V, but the difference will be infinitesimal.  At some point Vin returns to zero volts, and the capacitor will discharge at the same rate it charged. 

Now consider the situation where Vin is at voltage V for a short period of time.  The capacitor will not have time to charge very much, and Vc will not be able to approach V.  If the length of Vin being high is short compared to  TC, Vc may not get high enough to reach the threshold voltage of the microcontroller input.  The microcontroller will never recognize the input signal went high.

Let’s get back to our static electricity problem.  A static electricity burst is usually a very short pulse.  The RC circuit will limit how high the voltage will get.   A resistor of a couple of hundred ohms and a capacitor of .01 or .1 microfarads will give reasonable protection to the input.

Figure 10-2

An RC circuit is also known as a low pass filter. If the period of a signal is long (low frequency) compared to TC, the signal will pass through reasonably intact. If the period is short with respect to TC it will be filtered out.

The low pass filter can be used for other purposes. Part 6 mentioned switch bounce. This is where a mechanical switch will often make and break contact when it is actuated.  Proper values of RC can filter out these spikes.   RC filters are also used for filtering out high frequencies for A/D (Analog to Digital) converters. Their use in those applications will be covered in a future installment.

The nature of the signal inputs must be kept in mind when using RC filtering.  Suppose we have a sensor that indicates one revolution of a motor. If the motor is running fast enough, or if the values of R and C are too high, the inputs will be filtered out.  The voltage at the pin will never reach the switching threshold and the micro will think the motor is not running.

Looking at the situation from the analog world, an RC circuit has a frequency at which point ½ of the input voltage is lost. This is also known as the 3dB point. This is known as the cut off frequency, or Fc. 

Fc = 1/(2πRC)

The frequency of a signal going through an RC filter must be much less than Fc for proper operation.

Another characteristic of an RC filter might be important in some applications. Take a look at Figure 10-2. Suppose that our application requires the microcontroller to perform some operation very quickly when Vin rises to V.  Further assume that the threshold voltage for determining the input registering as a 1 or a 0 is at ½ V.  It takes nearly 1 full TC for Vc to reach that voltage.  This might be too late for the microcontroller to complete its operation in time.

Some microcontroller inputs depend on the input signal rising quickly. Reset pins and edge triggered interrupt lines may not work properly if an RC circuit slows the rate the signal changes. Consult the microcontroller data sheet before putting RC networks on these types of microcontroller inputs.

Zener Diode Protection

Figure 10-3 shows an input protected with a zener diode.  A zener diode acts like a regular diode with one exception. If the reverse voltage reaches a certain point, the diode will start to conduct. In combination with R to limit the current and drop the excess voltage, the voltage seen by the input will never exceed the zener voltage, Vz.  This of course assumes the input signal does not exceed the ratings of the zener diode or resistor.

Select a zener diode with a Vz that is higher than the Vcc powering the microcontroller, but less than the voltage that will cause damage. For 5V systems, 5.1V zeners such as the 1N5231 and the 1N4733 are commonly used.

Transient Suppressor Protection

Special electronic components specifically designed for ESD protection are available.  The go by the name of TVS, MOV, and a large number of trade names.  They are easy to use, and have many advantages over the zener protection including faster response times and higher energy capacity. Some are also available as arrays, handling a number of signal lines in a single package. Figure 10-4 shows a microcontroller input protected by one of these devices.  The schematic symbol may vary depending on the technology of the device.

In normal operation these look like a capacitor.  If the applied voltage reaches the Varistor Voltage, the varistor acts like a switch shorting the signal to ground.  Most types are bidirectional, meaning they will switch on if the varistor voltage is reached regardless of polarity.

The first data sheet parameter to look for is the Maximum Allowable Voltage.  This must be higher than the normal operating signal voltages. Otherwise, the normal signal will trip it, possibly preventing the signal from reaching the threshold voltage.  Another key specification is the capacitance.  You will want to use low capacitance suppressors for high frequency signals. Otherwise, the signal will get filtered out as in the RC filter described earlier. Another specification is the maximum surge current.  The higher this is, the more abuse the circuit can take, but often at a higher cost, size and capacitance.

Figure 10-3

Figure 10-4

Since transient suppressors look like capacitors during normal operation, you need to consider the same frequency related considerations as if you had used a regular RC filter.  The resistor is optional. Use one between 10 and a few hundred ohms for things like user switches. Leave the resistor off and use low capacitance types for high frequency signals.


It is a dangerous world out there.  For tough environments or equipment with high reliability requirements, input protection is called for.  RC filters, zeners and transient protectors are some of the methods that can be used to protect your sensitive microcontroller circuit.


Gotcha List

1. Be sure the cut off frequency of the RC network is higher than the desired signal.

2. Protection devices can affect the accuracy and maximum conversion rates of A/D inputs.

3. Check the microcontroller data sheet before putting RC networks on reset or edge triggered interrupt inputs.

4. RC networks add a delay. This will affect how fast your microcontroller can react to an input change.

5. Select zener voltages and varistor voltages above the normal operating voltages of your system. 

I sell on Tindie

© 2009 - 2022 Gary C. Sutcliffe


Created with the QTH.com SiteBuilder.