Go Down

Topic: Understanding noise (Read 294 times) previous topic - next topic

idrisdraig

Mar 07, 2020, 10:14 am Last Edit: Mar 07, 2020, 10:15 am by idrisdraig
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.



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?

RIN67630

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.

MarkT

Quote
(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?
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

AJLElectronics

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

idrisdraig

#4
Mar 07, 2020, 11:00 am Last Edit: Mar 07, 2020, 11:05 am by idrisdraig
Put a cap between 10nF and 1μF between your input and the ground.
Thanks.

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?

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?

AJLElectronics

what do you tie the shield to?
Earth / Ground, as always.  To avoid hum loops, only tie one end down to earth,

idrisdraig

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

idrisdraig

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

TomGeorge

#8
Mar 07, 2020, 02:44 pm Last Edit: Mar 07, 2020, 02:45 pm by TomGeorge
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... :)
Everything runs on smoke, let the smoke out, it stops running....

MarkT

#9
Mar 07, 2020, 03:46 pm Last Edit: Mar 07, 2020, 03:54 pm by MarkT
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.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

DVDdoug

Quote
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?

Quote
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. ;)

idrisdraig

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?


Is the switch normally open or normally closed?    Is it triggered by a  high or low?
Normally open, function called on FALLING.
Quote
Because the interrupt interrupts the processor and runs immediately before the debounce code has a chance to do anything. ;)
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 ....

Go Up