Series resistor between switch and MCU?

Thread Starter

Goxeman

Joined Feb 28, 2017
171
Hi everyone,

My doubt comes from a recommendation that someone from a MCU maker made me through support area but I dont understand the purpose. I explained the support agent that the project is battery powered (2 AA batteries) so I am very concerned about the battery duration (I dont know if this is the reason of the recommendation).

The project:
- One MCU (1.8V-3.6V work range) which inputs are activated with tact switches (10 in total)
- The inputs are activated with a high signal
- The tact switches are directly connected to the two AA batteries that supply 3V, so when they are closed they supply 3V to the MCU
- Each input connected to a tact switch has one pulldown

The support agent recommend within other advices to include a series resistor between the tact switch and the MCU input. I dont understand if this recommendation is related to consumption or to something else. The voltage supplied by the tact switch is within MCU range so the resistor purpose is not reducing the 3V.

My only idea is that I=V/R, then a resistance in series would reduce the current that input is drawing but I truly have no idea how much current would the input draw at 3V without any series resistor. What do you think?
 

AlbertHall

Joined Jun 4, 2014
12,345
The MCU input current is neglible provided you turn off any input pullup in the MCU. Such resistors are used to protect the MCU input - if somehow the switch voltage isn't the same as the MCU, bu static or other reasons. They will not affect the current consumption. They can be omitted at your own risk.
 

ebp

Joined Feb 8, 2018
2,332
[EDIT] I'm not entirely clear on the way things are powered. If the positive supply voltage for the processor is exactly the same as that used for the switches, then there is no risk of excessive current.

If you apply 3 volts to an input of processor running at less than about 2.4 volts current will flow through the input protection diodes to the positive supply of the processor. The amount of current the protection diodes can handle without damage is limited and must be determined from the processor datasheet. The allowable absolute maximum could be anything from about 2 mA to 40 mA. Typically it is best to limit the current to something well below the absolute maximum. A series resistor is satisfactory for the purpose in most cases. Sometimes additional external diodes are advisable. If the load on the power supply that runs the processor is very small, current through the protection diodes can raise the supply voltage, causing other problems.

[EDIT2] When you have inputs connected to things like switches there is a risk of electrostatic discharge. Series resistance can help protect the inputs from damage by ESD, but there are better methods than just a simple resistor, such as low-capacitance transient suppressors.
 
Last edited:

Thread Starter

Goxeman

Joined Feb 28, 2017
171
The MCU input current is neglible provided you turn off any input pullup in the MCU. Such resistors are used to protect the MCU input - if somehow the switch voltage isn't the same as the MCU, bu static or other reasons. They will not affect the current consumption. They can be omitted at your own risk.
Thank you Albert for you answer; all internal pullups have been disabled, I just use external pulldowns of 100K. Do you think that the voltage supplied could vary? The net connected to the switches is exactly the same that is connected to the power of the MCU

[EDIT] I'm not entirely clear on the way things are powered. If the positive supply voltage for the processor is exactly the same as that used for the switches, then there is no risk of excessive current.

If you apply 3 volts to an input of processor running at less than about 2.4 volts current will flow through the input protection diodes to the positive supply of the processor. The amount of current the protection diodes can handle without damage is limited and must be determined from the processor datasheet. The allowable absolute maximum could be anything from about 2 mA to 40 mA. Typically it is best to limit the current to something well below the absolute maximum. A series resistor is satisfactory for the purpose in most cases. Sometimes additional external diodes are advisable. If the load on the power supply that runs the processor is very small, current through the protection diodes can raise the supply voltage, causing other problems.

[EDIT2] When you have inputs connected to things like switches there is a risk of electrostatic discharge. Series resistance can help protect the inputs from damage by ESD, but there are better methods than just a simple resistor, such as low-capacitance transient suppressors.
Thank you ebp for your answer; sorry not to make it clear, as I answered above, the power net connected to the switches and the MCU is exactly the same

Now that I understand that it is optional (and I know it is optional because I made tests with switches without series resistor and nothing happens), I dont know what to do. Is a transient suppresor really going to make a difference?

In case of using something, the good thing of the resistors is that I could use a resistor array. How would you choose the value of the series resistors?
 

ebp

Joined Feb 8, 2018
2,332
To calculate the maximum resistor value you need to consider the value of the internal pull-down resistors in the processor and the minimum allowable voltage for logic 1.

For example, if the internal pull-down resistors were 10k (use the minimum value that is specified - resistors on ICs often have quite large tolerance) and the minimum logic zero voltage were 2/3*Vcc (typical sort of way of specifying for "CMOS" inputs), you could use a resistor of 5k maximum (simple voltage divider calculation). It would be better, in terms of have a good logic level, to use a lower value. I would probably use 3.3k which would give (10k/(10k + 3.3k)) x Vcc = 0.77 x Vcc. (probably actually Vdd not Vcc)

I would consider transient suppressors if the system had be be used where relative humidity might be very low and there was a high chance of static discharge into one of the switches. I live in Canada and when it is -30 °C outdoors and heated indoor air isn't humidified, static discharge from the finger of someone who walks across a floor can be enough you can easily hear the spark. Small capacitors from the inputs to ground can help a lot because they absorb a lot of the charge and they are inexpensive. With inputs from key switches the delay and slow signal rise and fall times usually don't cause any problems because you already need to "debounce" the switches. You should be able to find lots of info on the web about electrostatic discharge (ESD) protection methods. Perhaps some other AAC members have some favorite applications notes or other sources they can direct you to.
 

Thread Starter

Goxeman

Joined Feb 28, 2017
171
To calculate the maximum resistor value you need to consider the value of the internal pull-down resistors in the processor and the minimum allowable voltage for logic 1.

For example, if the internal pull-down resistors were 10k (use the minimum value that is specified - resistors on ICs often have quite large tolerance) and the minimum logic zero voltage were 2/3*Vcc (typical sort of way of specifying for "CMOS" inputs), you could use a resistor of 5k maximum (simple voltage divider calculation). It would be better, in terms of have a good logic level, to use a lower value. I would probably use 3.3k which would give (10k/(10k + 3.3k)) x Vcc = 0.77 x Vcc. (probably actually Vdd not Vcc)

I would consider transient suppressors if the system had be be used where relative humidity might be very low and there was a high chance of static discharge into one of the switches. I live in Canada and when it is -30 °C outdoors and heated indoor air isn't humidified, static discharge from the finger of someone who walks across a floor can be enough you can easily hear the spark. Small capacitors from the inputs to ground can help a lot because they absorb a lot of the charge and they are inexpensive. With inputs from key switches the delay and slow signal rise and fall times usually don't cause any problems because you already need to "debounce" the switches. You should be able to find lots of info on the web about electrostatic discharge (ESD) protection methods. Perhaps some other AAC members have some favorite applications notes or other sources they can direct you to.
Thanks ebp for you accurate answer
1. Do you mean the pulls that you can wether activate or not? The MCU I am using doesnt have internal pulldown resistors, it only has optional pullup resistors of 10K-30K resistance. That is why I use external pulldown resistors of 100K
2. The debounce I will manage with the MCU. I wanted to use as few capacitors as possible as far as some energy (very few) will be wasted every time one switch is activated.
3. Related to the electrostatic discharge, I think it wont be an issue as far as I will be using some rubber-silicon keypad to push the switch, this means that I wont be pushing the switch directly through my finger but through a rubber. Imagine the rubber-silicone keypad used in tv remote controls. Knowing this, would still recommend ESD suppressors for the switches?
 

AlbertHall

Joined Jun 4, 2014
12,345
3. Related to the electrostatic discharge, I think it wont be an issue as far as I will be using some rubber-silicon keypad to push the switch, this means that I wont be pushing the switch directly through my finger but through a rubber. Imagine the rubber-silicone keypad used in tv remote controls. Knowing this, would still recommend ESD suppressors for the switches?
One day I was working with a piece of equipment in a plastic case. The manager came along and touched the case with his finger and a visible static spark leapt from his finger to this equipment and it immediately died and had to be sent for repair.
 

Thread Starter

Goxeman

Joined Feb 28, 2017
171
One day I was working with a piece of equipment in a plastic case. The manager came along and touched the case with his finger and a visible static spark leapt from his finger to this equipment and it immediately died and had to be sent for repair.
Really? With a plastic case? Wow, this world never stops amazing me

Then ESD suppressors should be always used no? But in this case if I just use ESD suppressor in each switch-MCU net wouldnt be enough, shouldnt I better use a ESD suppresor in the VCC power line? Like TVS bidireccional diode?

Before I have used in other projects TVS bidireccional diodes from Stmicroelectronics within devices connected to cars batteries, but not in a hand device
 

AlbertHall

Joined Jun 4, 2014
12,345
It all depends on how reliable you want it to be.

If this was a classroom demonstration of a traffic light system with sensors for cars then a failure would not be a big deal. The situation is different for a real traffic light set.
 

ebeowulf17

Joined Aug 12, 2014
3,307
To calculate the maximum resistor value you need to consider the value of the internal pull-down resistors in the processor and the minimum allowable voltage for logic 1.

For example, if the internal pull-down resistors were 10k (use the minimum value that is specified - resistors on ICs often have quite large tolerance) and the minimum logic zero voltage were 2/3*Vcc (typical sort of way of specifying for "CMOS" inputs), you could use a resistor of 5k maximum (simple voltage divider calculation). It would be better, in terms of have a good logic level, to use a lower value. I would probably use 3.3k which would give (10k/(10k + 3.3k)) x Vcc = 0.77 x Vcc. (probably actually Vdd not Vcc)

I would consider transient suppressors if the system had be be used where relative humidity might be very low and there was a high chance of static discharge into one of the switches. I live in Canada and when it is -30 °C outdoors and heated indoor air isn't humidified, static discharge from the finger of someone who walks across a floor can be enough you can easily hear the spark. Small capacitors from the inputs to ground can help a lot because they absorb a lot of the charge and they are inexpensive. With inputs from key switches the delay and slow signal rise and fall times usually don't cause any problems because you already need to "debounce" the switches. You should be able to find lots of info on the web about electrostatic discharge (ESD) protection methods. Perhaps some other AAC members have some favorite applications notes or other sources they can direct you to.
Personally, I like this article. To the best of my knowledge, it all sounds like good advice, plus it's easy reading with lots of schematic examples:

https://www.digikey.com/en/articles/techzone/2012/apr/protecting-inputs-in-digital-electronics

I could've sworn there was also a very similar document from Analog Devices or TI, but I can't find it now.
 

joeyd999

Joined Jun 6, 2011
5,236

ebp

Joined Feb 8, 2018
2,332
Switches are often arranged so that they pull an input down rather than up. This was very common with TTL because the current for a logic 0 was much higher than for logic 1 - passive pulldown with TTL wasn't very practical. With CMOS it generally makes no functional difference with a processor where inversion is just a line of program, except in the case where you do have internal pullup resistors available on a processor. These are, as far as I know, much more common than passive pulldown resistors, but some processors offer either. External resistors still have there merits where you want to have specific current magnitude.

Many years ago I discharged a big static spark into the earth-grounded metal case of a video terminal I had built. I would have thought if it killed anything it would have been circuitry related to the keyboard. It actually destroyed the character generator IC which was electrically pretty deeply buried in the circuitry - and the single most expensive IC in the whole thing.

Small capacitors on inputs from a keypad will almost no effect average power consumption. Even a 100 nF cap, much bigger than I would use, holds a charge of only 450 nC at 3 V. If you charged it 10 times a second the average current would be only 4.5 µA. Your 100k pulldown resistor will take 30 µA at 3 V.
 

Thread Starter

Goxeman

Joined Feb 28, 2017
171
Thank you all, I checked all the information

I think a good way to protect this MCU and that could offer me a fair protection in this project would be using:
- A TVS diode array which zener diodes breakdown voltage is 6.1V (they are the most common)
- A series resistor of 1K-2K before the TVS diode the each line

What do you think? A link referred before suggests using before the series resistor a "clipping diode to ground is to protect from less than zero volt spikes". Also suggests using after the zener diode a 0,01uF capacitor.

I attach screenshot from the link beforeCaptura de pantalla 2018-10-02 a las 20.06.50.png
 
Top