Go Down

Topic: Random pin triggers (Read 2491 times) previous topic - next topic

dogmaphobic

Jan 20, 2011, 06:05 pm Last Edit: Jan 20, 2011, 06:06 pm by grubba Reason: 1
Keep in mind that my knowledge of electronics is rather limited. To make a long story short, my house was already wired for a security system but the actual alarm system was never installed nor did I care for one. However, the prospect of playing around with an Arduino was too great to pass. I'm not trying to create a security system, just a system that keeps track of movement, doors opening and closing and so forth.

I connected the various security cables into an Arduino. These are all normally closed circuits. Reed switches for doors, PIR sensors, etc. I run one wire to ground and the other to an Arduino digital I/O pin, which I set to HIGH. This is with the assumption that it enables the internal pullup resistors.

Code: [Select]
<...>
   pinMode(PIR_KITCHEN,INPUT);
   pinMode(PIR_BASEMENT,INPUT);
   digitalWrite(PIR_KITCHEN,HIGH);
   digitalWrite(PIR_BASEMENT,HIGH);
<...>


The problem I see is that every now and then, when something is triggered, some other pin is also triggered. That is, a door opens and some pin sensing another door is also triggered. In addition, some times, when I switch a fluorescent light (the long tube with ballasts type), some random pin gets triggered as well. All in all, it all works fine. It's just that some times I get this "extra" triggers. The documentation talks about pins capacitively coupling the state of a nearby pin but I was under the assumption that the pullup resistor would handle it.

How to fix this?

Thanks!

retrolefty

#1
Jan 20, 2011, 06:32 pm Last Edit: Jan 20, 2011, 06:36 pm by retrolefty Reason: 1
Quote
The documentation talks about pins capacitively coupling the state of a nearby pin but I was under the assumption that the pullup resistor would handle it.


I suspect the problem is more likely noise from capacitive coupling between the wires of the long wire runs. Potential fixes could be using real external pullup resistors of say 1k ohms to +5vdc or wiring .1ufd caps from pin inputs to ground at the arduino end, or both. The internal pull-ups you are enabling are pretty 'weak' at around 40+K ohms or so.

Lefty


WalterM

#2
Jan 20, 2011, 06:33 pm Last Edit: Jan 20, 2011, 06:35 pm by 3WalterM4 Reason: 1
The very long cables could act as antennas.

I think the contacts at the doors and windows will pull the inputs by a burglary to Gnd. Therefore additionally connect resistors á about 100 Ohms from each input to 5V of the Arduino.

Edit: I had sent my post nearly exactly parallel to retrolefty.

retrolefty

Quote
Edit: I had sent my post nearly exactly parallel to retrolefty.


But it got posted serially.  ;D

dogmaphobic

Quote
But it got posted serially.


Just like my random pin triggers! :)

Got it! Back to the drawing board...

Indeed, some of these wire runs are over 200' long. I wondered what that would do... I'm also assuming that if I do add my own pullup resistors, I should disabled the internal ones, right?

Thanks!

g

Udo Klein

To get more resistant to coupling you might want to try smaller pull up resistor and maybe some caps.

Udo
Check out my experiments http://blog.blinkenlight.net

Coding Badly

Quote
Indeed, some of these wire runs are over 200' long. I wondered what that would do...

When file servers were expensive, my boss at the time refused to lay out the money.  Instead, for "print serving" he had a very long printer cable made.  "Sharing" the printer amounted to locating the PC end of the cable and dragging it to your office.

One afternoon we were working together.  I took a quick look around and asked him, "can you smell smoke?"  "No."  A few seconds later a loud POP came from inside his computer followed by a trail of black smoke.  He yanked the power cord.  We opened the case.  Several parts on the parallel port adapter had melted or exploded.  The "print server" went into a closet.

The moral of the story: long cables are evil.

retrolefty

Quote
long cables are evil.


Unless they are holding up a suspension bridge. Then they are your best buddies.

Lefty

retrolefty

Quote
I should disabled the internal ones, right?


Doesn't really matter, doesn't do any harm. I would leave them on in case you ever disconnect a external resistor, you won't get a lot of bogus alarms.

Lefty

dogmaphobic

Resistors added, it's all working perfectly now. Thanks to all who helped me out with this. For the benefit of those bumping into this thread later on, I found this link with a good explanation for all of the above:

http://www.thebox.myzen.co.uk/Tutorial/Inputs.html

Upon closer inspection, the problem I was having was with the "open" circuits. That is, those that are normally open such as the door bell switch, doors that remain open for extended periods, etc. Those were the wires woking double duty as antennas :)

g

Go Up