Understanding noise

I have a long wire (3-4m) that effectively forms one side of a primitive pseudo switch. It is connected to ground on my circuit.
When the end of the wire contacts a second stationary contact, it pulls down an interupt (Uno - Pin 2) which is held high by a 1KΩ resistor.

Interupt noise.jpg

When the long wire is unplugged, it will erroniously triggers the ISR.
I understand this is down to noise, and that a cap may help prevent this (I haven't quite figured out what yet - I think a small ceramic beteen Vcc and Gnd?). (Twisting cables also isn't an option.)

What I don't understand is why debouncing code doesn't seem to have any effect, and it only seems to effect Interupts not digital inputs.
Can anyone explain this ... err ... (:))) ... simply?

Interupt noise.jpg

idrisdraig:
When the long wire is unplugged, it will erroniously triggers the ISR.

Put a cap between 10nF and 1μF between your input and the ground.

(Twisting cables also isn't an option.)

Then use a shielded/screened cable...

Unplugging the wire turned the other wire into a large antenna I think, hence the triggering.

Not using twisted or screened cable will mean a lot more noise pickup, and that capacitor will be needed.

If you use two separate wires with a large gap inbetween you have a magnetic loop antenna, the worst
scenario of all (this is what happens if using the body / chassis of the equipment as the return wire).

An interrupt input will record the slightest pulse on the wire, even if it lasts for a fraction of a microsecond,
which makes the problem much more noticable.

Any mechanical switch will have bouncing too, which causes multiple interrupts, so you'll have to allow
for this too perhaps?

Where is the resistor? Is it being unplugged with the wire, or is it right at the board and always in circuit?

RIN67630:
Put a cap between 10nF and 1μF between your input and the ground.

Thanks.

MarkT:
An interrupt input will record the slightest pulse on the wire, even if it lasts for a fraction of a microsecond, which makes the problem much more noticable.

But why doesn't debouncing the interupt with code make any difference?

AJLElectronics:
Where is the resistor? Is it being unplugged with the wire, or is it right at the board and always in circuit?

Yeah, the pull-up resistor is permanently on the board (currently breadboard, ultimately PCB/shield).

If you use shielded cable (not impossible, but for 25-30% of the length that's impossible as it's necessarily represnets a pre-existing cable) and the "signal" line needs to be tied to ground to pull down a logic value, what do you tie the shield to?

idrisdraig:
what do you tie the shield to?

Earth / Ground, as always. To avoid hum loops, only tie one end down to earth,

So both the signal line and the shield are are tied to ground? Surely the same noise is then on both?

Sadly neither a 0.01μF nor 0.1μF are making any obvious difference.

Hi,
Use an opto-coupler at the UNO, the contacts of the remote switch controlling the LED input of the opto.
In other words you will be lowering the impedance of the system, so better immunity form noise.


Tom... :slight_smile:

idrisdraig:
So both the signal line and the shield are are tied to ground? Surely the same noise is then on both?

Interference currents will flow on the outside of the shield only, safely conducted to ground. Any
current on the signal wire would induce a voltage at the Arduino pin because its not connected to ground.

If you disconnect the shield the whole cable is free to pick up noise voltages as a whole injecting them
direct into the signal pin.

A well designed plug such as USB will disconnect data pins before power and ground when unplugging.

BTW we often speak of EMI or interference for unwanted signals appearing on wires, 'noise' is commonly reserved for random fluctuations created by fundamental physical phenomena in electronics components such as resistors and transistors - but this distinction is often ignored.

Debouncing is a separate issue to this unplugging thing, thought I'd point it out anyway.

When the long wire is unplugged, it will erroniously triggers the ISR.

Is the switch normally open or normally closed? Is it triggered by a high or low?

What I don't understand is why debouncing code doesn't seem to have any effect

Because the interrupt interrupts the processor and runs immediately before the debounce code has a chance to do anything. :wink:

TomGeorge:
Use an opto-coupler at the UNO, the contacts of the remote switch controlling the LED input of the opto.
In other words you will be lowering the impedance of the system, so better immunity form noise.

I wondered about optoisolators. I was hoping to keep component count to an absolute minumum, but maybe I need to reconsider that.
In terms of impedance, I don't currently have a resistor in series with the "switch". (The equivalent of R1 n your opto-isolator circuit.) If I understand RC filters correctly, (in my ciircuit above) would putting somthing like a 1MΩ resistor in series with the switch and a small cap between D2 and Gnd be a possible solution?

DVDdoug:
Is the switch normally open or normally closed? Is it triggered by a high or low?

Normally open, function called on FALLING.

Because the interrupt interrupts the processor and runs immediately before the debounce code has a chance to do anything. :wink:

Doh!!! When I sat and thought about it I realised that in my head wasn't separating the interupt and the function it calls. So what I was wanting to do was stop the interupt interupting the function it calls. Which it won't. Grrrrr ....