PDA

View Full Version : PIC Input Vs Cable Length



gadelhas
- 8th July 2013, 23:32
Hi;

Please if possible give me your advice regarding the attached circuit.

It the schematic i have 1 type of circuit connected to one input of the PIC and another type of circuit connected to other input.
The final schematic is to make an alarm system.

My concern is how I should do to make the system more reliable in the inputs of the micro controller, because I can have PIR detectors at about 200 meters away and cable can be close to the electrical house system, which can cause all types of interferences.
As you can see, in the first input i only have a Pull-Up resistor and capacitor, in the second input, I also include a TVS and more caps and resistors?

What is the opinion of you guys regarding the type of circuit that I should put on the input of the PIC? Or, what you usually do in cases like this?

(Opto here is not an option, because i can just have a simple switch instead of a PIR )

Demon
- 9th July 2013, 00:46
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

gadelhas
- 9th July 2013, 00:54
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

I probably should go to my second design ( Circuit connected to RC3 ), however i would like to know some opinions about the designs that guys are doing regarding this matter!

Let's see if someone tell us something Robert!

Charlie
- 9th July 2013, 13:25
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.

kellyseye
- 9th July 2013, 13:46
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).

Demon
- 9th July 2013, 15:38
Wouldn't an opto-coupler like MCT6 protect the pins?

Robert

Charlie
- 9th July 2013, 16:22
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.

AvionicsMaster1
- 10th July 2013, 14:12
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.

BobK
- 30th July 2013, 17:04
Hi all!

I have been in the alarm business for over 38 years. Most of the systems I deal with utilize an end of line resistor for supervision of the circuit and it also allows the use of open and closed circuit switches on the same circuit. With this in mind, intrusion circuits are usually closed loop devices and fire circuits use both types of devices with specifically open circuit devices activating the fire loop and closed loop devices use for supervision of the fire circuit. An example of this type of fire circuit is a 4-wire smoke detector. At the end of the loop is an end of line relay circuit that monitors the power going to the smoke detector with the end of line resistor after the smoke detector's open contacts so that even if the end of line resistor was missing, you can still generate an alarm on that loop.

Anyhow, these types of circuits are usually fed into an LM339 voltage comparator so that both "open" and "shorted" loops can be detected. I use this type of design in things that I make and it works great. The loop has a resistor (the industry uses 1K, 2.2k, 4.7k and sometimes 5.6k values in their designs). There are one or two companies that even use 3.3k. There are some companies that utilize the A-D or comparator inputs on micros to do the analysing for them saving having to put another IC on the board. The input circuit looks like the second circuit shown in the example without the TVs and usually only have a .1uF capacitor in the circuit.

Hope this information helps you with your design!

BobK