PIC Input Vs Cable Length - Page 1
Forum section: electronics / projects

author: ElectricGuy
author_rank: Regular Contributor
timestamp: July 08, 2013, 05:26:16 pm
content: 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 a home 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?Thank YouElectricGuy

author: bilko
author_rank: Frequent Contributor
timestamp: July 08, 2013, 07:13:02 pm
content: I would use an opto isolator, run the 200m leg through resistor, LED and switch, opto to PIC input

author: ElectricGuy
author_rank: Regular Contributor
timestamp: July 08, 2013, 07:35:29 pm
content: Quote from: bilko on July 08, 2013, 07:13:02 pmI Bilko,Many thanks for your answer!I thought about that, but i think that will increase the Boom cost, as well I've looked at some commercial home alarm system, and most of them use some variations, if not equal, circuits that i post on the schematic.That was why i posted here this circuits, because on brand use one type of approach, other brand, another, but most of all, just use passive components.I want to understand why! If possible, of course!It seems to me that the circuit that uses the TVS is a more reliable solution, however it can be overkill, since the circuit connected to the first input is also reliable for this kind of design ( Home alarm system).Using passive components what do you think is the best approach?

author: bilko
author_rank: Frequent Contributor
timestamp: July 08, 2013, 08:00:26 pm
content: I don't think that the opto will cost more than your transil solution, the opto can be had for pennies, and it is far more robust.Most alarm system field wiring runs on 12V, PIR detectors included.Using your passive components also presents the systems VCC on the loop, you would have to isolate this anyway for robustness.Usually the sensors are all wired in series because they present normally closed contacts, this means one opto per zone. Because the input system is basically a current loop and with isolation, it is effectively noise immune.

author: ElectricGuy
author_rank: Regular Contributor
timestamp: July 08, 2013, 09:41:12 pm
content: Quote from: bilko on July 08, 2013, 08:00:26 pmOk Bilko, thank you once again!But imagine this, forget the PIR, i only have a switch, nothing more. Int his case the opto will note have the same effect because it will need to share the same vcc and ground (in both led and receiver) . So in this case what is the best solution?

author: Mike Warren
author_rank: Unknown
timestamp: July 08, 2013, 10:45:10 pm
content: This is how I've done it in the past. Note that the switch is tied to 12V rather than ground. This is the convention and can sometimes simplify wiring.You need to do some good debouncing in the software. Not normal switch debouncing, but you need to make sure the state has changed for at least 100mS to minimise false triggers. Also, most alarms now days will use an external resistor in series with the switch(es) and use an ADC to monitor the voltage for change. That way you can detect a short and report it as a fault (or tampering).The 12V output would be supplied via a polyswitch, usually for a group of inputs.

author: ElectricGuy
author_rank: Regular Contributor
timestamp: July 08, 2013, 10:59:18 pm
content: Quote from: Mike Warren on July 08, 2013, 10:45:10 pmThank you Mike for your answer.I'm aware of the software debouncing and the ADC method that is used this days, but since my design is just to personal use, not commercial i will just use the free contact without resistance.What i need is to avoid false alarms, and also to avoid the damage of the PIC input due to transient voltages on the lines.Thank you once again!

author: Mike Warren
author_rank: Unknown
timestamp: July 08, 2013, 11:07:35 pm
content: Quote from: ElectricGuy on July 08, 2013, 10:59:18 pmProtection from false alarms is mostly down to the software, but I've also used that circuit with standard CMOS Schmitt trigger inputs and not had false alarms.As for the transients; are you wanting it to survive being connected to 240V mains? If not, that will protect the input fine in a normal domestic environment.Another reason for feeding the switches with 12V is that a loss of 12V due to tampering or a major fault will produce a trigger. That way, a faulty system doesn't go unnoticed.

author: ElectricGuy
author_rank: Regular Contributor
timestamp: July 08, 2013, 11:11:45 pm
content: Quote from: Mike Warren on July 08, 2013, 11:07:35 pm

author: ConKbot
author_rank: Super Contributor
timestamp: July 09, 2013, 02:15:34 am
content: Quote from: ElectricGuy on July 08, 2013, 11:11:45 pmIts not that unreasonable of a question. When I put together a high speed isolator for triggering a DAQ system, to make it relatively operator-proof, I made sure it could take 120V mains across the input. You never know where mains voltage will get hooked up

author: Niklas
author_rank: Frequent Contributor
timestamp: July 09, 2013, 11:27:22 am
content: Will the PIR sensor also get its supply voltage from the input circuitry or is just an isolated mechanical switch?If it is just a switch, then I would go for a resistor divider solution and read the voltage level with an ADC channel. On the input side: V+ -> 1k -> 10k -> 1k -> 0V with the sensor connected in parallell with the 10k resistor. From each side of the 10k resistor place a capacitor down to 0V. Also place a capacitor in parallell with the 10k resistor. Small ferrite beads or chokes in series with the sensor. From the V+ end of the 10k resistor connect a low pass filter and perhaps also some clamping diode before connecting it to the ADC. The filter should have at least a series resistor to limit the current but a small choke could also be nice.On the sensor side, a series resistor of maybe 1k and a 10k resistor in parallell with both the switch and the series resistor.The solution is about the same as for a differential bus and will also give you some diagnostic possibilities. Open circuit, short V+, short 0V, short sensor/wiring etc. Define different ranges of ADC values for both accepted signals (sensor ok but not activated, sensor ok and activated) and for various errors.