I'm not sure how to draw a picture for you, but here's my opinion in text. There are three basic considerations.
1) Will the circuit work? The wire has a resistance you can look up based on it's size. You need to make sure the voltage divider created with the pull up resistor and the wire resistance is such that the PIC can detect a low, in your configuration. No issue with either approach, but since there is more margin between what the PIC will see as a high and VDD than there is between what the PIC will see as a low and GND, you may wish to use the switch to pull up a normally low line, than to pull down a normally high one. Not a huge difference, but if you are getting into really long runs, eventually it might.
2) Will the circuit falsely trigger? Long runs will pick up noise. The key to fighting this is low values in the pullup resistor, and high values in the decoupling cap. The tradeoff is the speed of operation of the switch. I think slower is better until you start to get into the seconds range, when it comes to alarm systems. The pull up resistor value is about right, but I'd be tempted to make the cap a bit bigger. Just stay with low ESR / ESL technologies, like ceramic caps.
3) What happen with transients, like nearby lightning, or big motors starting, and so on? The TVS in your circuit isn't going to do much. You will find it's tolerance and speed is such that you will not be able to guarantee the pin is protected. You would do better with a dual diode right on the pin, arranged so that if the pin tries to go over VDD the current will go into the positive supply, and if the pin tries to go under 0 V the current will flow into GND. Then add a series resistor as you did, although I'd make it smaller in value. Too big can contribute to noise, too small limits the elasticity. The extra cap likely isn't necessary, although it will help slow things down and improve noise immunity. Slowing down transients also gives the protection diodes more time to start to do their job.
To summarize: I'd recommend the second configuration, but with protection steering diodes right on the pin, slight value changes, and removal of the TVS.
Bookmarks