Go Down

Topic: Does a 4021 need resistors? (Read 2839 times) previous topic - next topic

nickelliott

Hi all

I'm following the ShiftIn tutorials (I know, the code is a little outdated now, but there are enough examples in this forum to overcome that).

However, the circuit diagram in that tutorial shows the input pins connected via 10K pulldown resistors, but via the switches direct to +5V.  If I was connecting a switch directly to Arduino I would feed the switch line through a low-value resistor - 100 Ohm or so.

Is it bad practice to feed +5V straight into the 4021 input pins, or does the chip incorporate its own internal resistors?

Many thanks in advance

Nick

CrossRoads

I don't believe it has its own  pullup/pulldown resistors. Check it out at www.ti.com.
CMOS wants inputs to be either high or low, and not floating.
Adding 10K pullups will hold the pins high and allow you to ground them later via switch, or another device.

Unused pins, pins that will never be switched, may be connected to +5 or Gnd. Output Enable is one example.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

nickelliott

Hi CrossRoads

Many thanks for your reply; however, I don't think I made myself clear in the first post..

I have connected all the input pins with 10K resistors to GND.  But If I want a pin to register a switch press, can I feed it +5V straight from Arduino, or should I feed that switch signal through a small resistor first?

Hope that makes more sense..

Nick

Grumpy_Mike

Quote
But If I want a pin to register a switch press, can I feed it +5V straight from Arduino,

Yes.
Quote
If I was connecting a switch directly to Arduino I would feed the switch line through a low-value resistor - 100 Ohm or so.

Why? There is no need.
Have a read of this:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

nickelliott

Thanks for your reply.

Why you ask; well I picked up that practice from the tutorials I followed when I first started with Arduino.
But your response made me go back and check, and actually in this tutorial  http://www.ladyada.net/learn/arduino/lesson5.html I found this:

Quote


Whats this 100? resistor all about?

There's a 100? resistor we use to connect the input pin to either HIGH or LOW voltage. Why is it there? Well, lets say you accidentally set P2 to be an OUTPUT type pin, but then you connected it to 5V. If you write a LOW to the pin (0V) but its connected to HIGH (5V), you've basically caused a short circuit at that pin. This isn't very good for the pin and could damage it! The 100? resistor acts as a buffer, to protect the pin from short circuits.


So I guess I can stop using the small resistors then.

Nick

Grumpy_Mike

Yes to my mind you have made three mistakes in order to get damage. You have to set the pins to outputs, you have to write high to the output and then you have to push the button. A quite unlikely seriese of operations.

Paul__B

Actually, it's not such a bad habit, but particularly if you are using switches (or contacts, relays LDRs, etc) remote from the PCB just in case they get fouled up with other power supplies in that equipment or the mains - and as in recent discussions here absolutely essential if you are doing this in an automotive environment.

Since the Arduino inputs are a very high impedance anyway (but do have a few tens of pF capacitance) you can generally use a much higher resistance, say 22k or 47k, located immediately adjacent to the Arduino pin - unless that is, you are using the internal pull-up in which case the resistance should probably not exceed 1k.

I will mention as I so often do, that having the switch go to ground, and the pull-up be contained within the security of the PCB, is the vastly superior connection from an engineering (safety) point of view with the above considerations, than having the switch go to a 5V rail and the pull-down to ground.  Lady Ada gets it right where the Arduino tutorials mostly fail.

Grumpy_Mike

Quote
that having the switch go to ground, and the pull-up be contained within the security of the PCB, is the vastly superior connection from an engineering (safety) point of view

Well I agree with you on that one.
I discuss it here:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Paul__B


Well I agree with you on that one.
I discuss it here:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html


Yes, I like it.  I have duly bookmarked it and propose to use it as a reference in future.  :D

There is however a rendering blunder in the paragraph "Any disadvantages with using a pull down resistor?" which overlies the previous text unless you enable JavaScript.  :smiley-eek:

Do you not agree on the protective benefits of an extra resistor?  ("condom-resistor"?)

Grumpy_Mike

Quote
Do you not agree on the protective benefits of an extra resistor?  ("condom-resistor"?)

I do not. There is no NEED for the resistor, I have never used one and never will.
It will decrease the noise margin of the input and make it more susceptible to picking up interference.

Quote
here is however a rendering blunder

Depends on you browser, if you are using anything but IE let me know and I will look into it.

nickelliott

Quote
Quote

here is however a rendering blunder

Depends on you browser, if you are using anything but IE let me know and I will look into it.


Firefox with NoScript installed causes the rendering issue, but I guess that is only to be expected really.
If I temporarily enable javascript and refresh, the layout is fine.

I wouldn't expend too much time on it if I were you.

Nick

Go Up