I am building a project that has nothing to do with capacitive touch, but did notice my project responds to it in an undesired way. I'm hoping this simply isn't going to be a problem, but I'd like to understand what's happening so I can convince myself that this will not happen when my project is wired into the system it's monitoring (and no humans are fiddling with the wires), which happens to be my car.
Below is a pretty simple schematic and a pretty simple program. I am currently able reproduce this behavior with this exact hardware and software combination:
So it seems that input D2 is seeing a falling signal over and over. This seems bad, and seems like I probably need extra components (maybe a capacitor?) to prevent this from happening. I understand a lot of basic components but have never used capacitors.
I actually already have a custom PCB designed, so I'm hoping that I won't have to worry about this phenomenon when D2 is actually wired to a transistor which is triggered by the starter in my car to connect D2 to ground.
Your body is picking up electrostatic fields from the mains supply and passing it to the input pin, which has a high enough impedance to allow the signal to repeatedly toggle the input state. If you want a demo, touch the input pin of a guitar cord plugged into an amp and hear the ear popping buzz.
If you connect the pin to something low impedance like a sensor output, it can't happen.
aarg:
Your body is picking up electrostatic fields from the mains supply
Strictly speaking that's electric fields, as they are not static!
People are often surprized by the voltage you can pick up this way, for instance I'm currently
picking up 15Vrms just be being near some mains cables.
Mains cables are almost never screened, here in the UK we have 240Vac on the live wire, 0Vac on
neutral and earth (hopefully) - this means on average a mains cable appears to be running at about 80Vac
from the perspective of a distant object. Depending on how close you are to cables and how well earthed you
are you might be floating at anything from 0V to 80Vac. That's easily enough to fry MOSFETs if you pick
them up by the gate pin, note.
Since this is coupling to you through a few pF of capacitance or so, the current available is a few microamps
at worst, you'd never feel this.
That 15V I measured above is into the 10M input impedance of a 'scope probe - without that 10M resistor to
ground I might be at a considerably higher potential even!
Interesting, thanks to both of y'all. This is obviously why, or one reason why, we want to ground ourselves when we are handling components, soldering, etc. I guess I should invest in one of those wrist ground straps.
What I still don't get about this whole thing is why in my example above it continuously, or I should say repeatedly, triggers the FALLING interrupt. It seems like it would trigger it once, just like when I connect D2 to GND.
When I modify my code to just print the value of the pin, it's flipping 1/0 very quickly. No discernible pattern. Anyway, I don't think this will change my design, I just had to investigate to make sure it's not going to be a factor.
jwallis:
What I still don't get about this whole thing is why in my example above it continuously, or I should say repeatedly, triggers the FALLING interrupt. It seems like it would trigger it once, just like when I connect D2 to GND.
Because the line voltage alternates 50 or 60 times a second.
Paul__B:
Seems you do not comprehend what interrupts are for.
Never mind, I won't repeat my standard comment on that unless provoked.
Other than insulting and/or baiting me, I do not find a ton of information in that post...
I'm guessing it was based on the delay I put in my ISR, which was designed and works to filter out false (less than a few hundred ms) signals. Since my application works on the order of tenths of a second and not microseconds, I don't mind the time expense I'm incurring.