Good, I have the same requirement for my alarm project. My garage is 2 stories, 40ft long, so max might be 2x50ft, so 100ft round trip for switch on far window.
Robert
Good, I have the same requirement for my alarm project. My garage is 2 stories, 40ft long, so max might be 2x50ft, so 100ft round trip for switch on far window.
Robert
Thanks and Regards;
Gadelhas
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.
Use twisted pair cable. Capacitive filters and (possibly) inductors - you can get three-terminal C-L-C filter components - would be acceptable. False triggering could be catered for in programming (similar to keyboard debounce).
Wouldn't an opto-coupler like MCT6 protect the pins?
Robert
Last edited by Demon; - 9th July 2013 at 15:42.
Well... an opto coupler requires power, so you need to add still more complexity, and yet another power source for isolation. Then of course, how do you test that the opto has not failed, since the operating condition and the usual broken condition look the same? And given the cost of an opto and the cost of a PIC these days are not that far apart, you are sort of into diminishing returns. So IMHO, an opto is not a good solution in this instance.
The previous poster's twisted pair recommendation is very good. A CLC filter would be good too, but again, a bit of overkill for this application, I think. RC filter is plenty, unless you are worried about radiating electromagnetic interference from your circuit with the antennae you are stringing all over the place... in that case a CLC filter is more bidirectional, and will help prevent you causing problems for your neighbors. Your board layout and clock choices and enclosure will all play a role here too - EMC in non-trivial.
I don't know why using wire, excluding any EMC potential, would be a problem if the correct wire gauge is selected. This site http://www.cirris.com/testing/resistance/wire.html shows that using 20 ga. wire for 1200 feet (approx. 400 meters) would get you in the range of 12 ohms. If you continue to use the 1.5k as a pull up, when the the switch closes you'd have around 40 millivolts(at 5 volts) from pin2 to ground. This well within the limits for the PIC to recognize a logic low.
Now if you use .050 ribbon cable you'd have around 7200 ohms just for the wire and a "low" voltage of 3.9ish. That voltage would be probably interpreted as never having switched. But you could also use the .050 wire but use a 100k as a pullup and you'd get around .33 volts(at 5 volts) which should be seen as a logic low.
EMC could be soved by routing, cheaper, or using shielded wire which would about double your wiring costs. Routing the sensing wire at 90 degrees to electrical wiring where it corsses will minimize EMC pickup from that source. Might even be cheaper to run conduit in suspect areas if you're handy with that sort of thing. Of course you could use a debounce routine like someone else suggested.
I also don't see any value in the TVS but I am curious how you came about the values used for you filter network.
Bookmarks