Digital input to an IC - do I need a resistor?

Hi,

I'm currently designing a device based around a PIC microcontroller. However, in getting to this point I have rather leapfrogged over more basic electronics - I'm a software developer by trade. Any general advice people care to give is welcome, but my specific question today is whether I need to include resistors in digital input lines. That is, can a pin which is configured on the chip as a digital input be connected directly to a push-to-make button and thence to the power rail, or should I include a resistor in series to limit the current that can flow? (I'm aware that I will also need debounce, but intend to implement this in firmware since the PIC is not working very hard).

The IC, if it matters, is Microchip's PIC16F914:

formatting link

Thanks,

Pete

Reply to
Pete Verdon
Loading thread data ...

If the switch is going to ground or the processor's Vcc, you don't need a series resistor, but you will need a pull-up or pull-down resistor to ensure that the input goes to the opposite state when the switch is open.

From long experience with TTL logic, I would connect the switch from the input pin to ground, and a 3 - 5K resistor from the input pin to

+Vcc.
Reply to
Peter Bennett

If im not mistaken, PICs are voltage controlled devices. Meaning that if you are inputting TTL voltages, you will not need a series resistor to limit current flow (assuming your logic voltages are being generated by other such devices). If your logic is somehow directly connected to your Vcc (ie, a switch, or a transistor switch) then you will need a series resistor because you will short your entire Vcc source to ground..and that quite frankly...is bad..

eP

PIC16F914:

formatting link

Reply to
reperera

No. You don't need a series-resistor to limit the current. As others noted: you may need a pull-up or pull-down resistor.

But if you realy want to connect a push button, you may need something else: a debounce circuit.

If you push the button near your frontdoor, your bell will (simply) ring. If you connect a push button to an electronic circuit it will 'see' a train of pulses, for upto 1 or 2 mSec at least. Normally, you have to cope with that, either in software or by a hardware circuit.

--
Kind regards,
Gerard Bok
Reply to
Gerard Bok

Thanks very much, that's really helpful.

How crucial is the resistor value, though? I ask because it seems my colleagues are planning to use a lot of 10K resistors elsewhere; would these be OK or is your 5K pretty much the limit?

Thanks,

Pete

Reply to
Pete Verdon

10K should be fine - I'm probably stuck in an older, higher current, era...

You might also put an 0.01 uF capacitor across the switch to reduce the contact bounce problem.

Reply to
Peter Bennett

Thanks. The order is going in very shortly!

Pete

Reply to
Pete Verdon

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.