Protecting PIC Digital Inputs
Posted: Fri Oct 21, 2011 6:42 pm
Hi,
I want to protect the digital inputs on my 18F4620.
I am using a 1x3 Male header to connect my sensors.
Pin 1 is the PIC PIN (Digital Input and is pulled hi to Vdd)
Pin 2 is 12V
Pin 3 is GND
I want to be able to power sensors that run on 10vdc - 20vdc as well ad make my own sensors that run at 5vdc. I will put 78L05 on my sensor pcbs using the 12V. I also want to be able to connect either a dry contact (push button) to the input as well as an NPN based sensor.
I have found this circuit in a few places on the web. The values of the Resistors and capacitor has never been given and was hoping someone would offer some suggestions with an explanation as to why they selected those values.
As I understand it:
R1 is simply a pull up resistor (this is typically all I have used in the past).
R2 is used to limit the current to the MCU pin.
C1 is used to help with noise and to debounce a mechanical contact input device (push button, reed switch).
I have read on a few sites that R2 could be up to a few hundred ohms and on other sites it should be 10K - 15K ohms.
I would normally use 10K pull up resistors but have been told there would be issues if both R1 and R2 were 10K (have been told that R1 should be more like 100K ohms).
I am hoping someone could explain what reasonable values would be for R1, R2 and C1.
Once my PCB's arrive I will start out using the following values.
R1 = 100K
R2 = 10K
C1 = 1uF to 2.2uF (C1 and R2 creating time value for contact debounce).
Thank you,
Ron
I want to protect the digital inputs on my 18F4620.
I am using a 1x3 Male header to connect my sensors.
Pin 1 is the PIC PIN (Digital Input and is pulled hi to Vdd)
Pin 2 is 12V
Pin 3 is GND
I want to be able to power sensors that run on 10vdc - 20vdc as well ad make my own sensors that run at 5vdc. I will put 78L05 on my sensor pcbs using the 12V. I also want to be able to connect either a dry contact (push button) to the input as well as an NPN based sensor.
I have found this circuit in a few places on the web. The values of the Resistors and capacitor has never been given and was hoping someone would offer some suggestions with an explanation as to why they selected those values.
As I understand it:
R1 is simply a pull up resistor (this is typically all I have used in the past).
R2 is used to limit the current to the MCU pin.
C1 is used to help with noise and to debounce a mechanical contact input device (push button, reed switch).
I have read on a few sites that R2 could be up to a few hundred ohms and on other sites it should be 10K - 15K ohms.
I would normally use 10K pull up resistors but have been told there would be issues if both R1 and R2 were 10K (have been told that R1 should be more like 100K ohms).
I am hoping someone could explain what reasonable values would be for R1, R2 and C1.
Once my PCB's arrive I will start out using the following values.
R1 = 100K
R2 = 10K
C1 = 1uF to 2.2uF (C1 and R2 creating time value for contact debounce).
Thank you,
Ron