Pages: [1]   Go Down
Author Topic: Random pin triggers  (Read 2168 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Ardweeb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
<...>
    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!
« Last Edit: January 20, 2011, 12:06:39 pm by grubba » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

« Last Edit: January 20, 2011, 12:36:13 pm by retrolefty » Logged

Braunschweig, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 65
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 20, 2011, 12:35:57 pm by 3WalterM4 » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

But it got posted serially.  ;D
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Ardweeb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But it got posted serially.

Just like my random pin triggers! smiley

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
Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Udo
Logged

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

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 198
Posts: 12753
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
long cables are evil.

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

Lefty
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17262
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Ardweeb
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley

g
Logged

Pages: [1]   Go Up
Jump to: