Sensor interferance and USB

I have a strange problem that I can't explain. I have a custom designed PCB board that has two Atmegas soldered to it. They are both connected with software serial so I can transfer data between them. One Atmega is connected to two IR sensors with 10m cable. If one of the IR sensor changes status an interrupt is triggered, and one atmega sends message to another. This atmega has some other sensors, LCD display... connected to it. And also a nokia DKU5 USB cable - it is used instead of FTDI chip on original arduino boards so I can have serial communication without any additional hardware. I simply connect the ground and Rx/Tx pins.

Now the problem - If I turn off or on the light or some other electrical device in the room the interrupt (on one of the atmegas) gets triggered. But this only happens if I have the USB cable connected to the computer (power is delivered via 12V outside power source). If I disconnect the USB cable from the computer everything is working. I can turn the light on/off and nothing will happen (as expected). But if I plug the usb cable into the computer and turn the light on/off the interrupt gets triggered. Which of course is very annoying.

Sounds like EMI, the conducted or radiated "click" (transient) could be passing thru your circuit board, using 33 ft of cable and a PC as a counterpoise could be a fairly effective antenna.

Most cases are "common mode" noise, or "longitudinal" noise in phone language.

First eliminate any other possibilities, like cover up all the IR sensors and emitters. If you still got problem, then it may indeed be EMI. Try a common mode choke to isolate the trouble spot.

For low frequencies (Hz to kHz) you can use the laminated silicon-steel core of a small power transformer. Break apart the E and I shaped laminations, remove the bobbin, wind one of your cables around the E as many times as you can and clamp on the I pieces with rubber bands or ty-raps.

For slightly higher freqs (kHz to MHz) use a ferrite core from a classic TV deflection yoke to do the same thing.

For MHz to GHz the ferrite beads sold for EMI reduction are effective.

If you can pinpoint a cable that is particularly vulnerable and a type of core thats effective in stopping it, you can derive a prettier solution. If you end up redoing the layout of your board, study books by Henry Ott, or Howard Johnson or others.

Good Luck !

Hmm I noticed something interesting. At first I thought that the problem occurs when I plug in any electrical device in the room (this happened before when I was using an unshielded cable). But I noticed now that this only happens when I turn on the light in the room (fluorescent lamp). I am now using a telephone cable that has a foil around it.

Another interesting thing is - why does this only happen if the USB cable is plugged in?

Another interesting thing is - why does this only happen if the USB cable is plugged in?

Your PC or at least one device connected to your PC is probably connected to Earth Ground as well. There could be a group loop that is manifesting between your PC and the other electronic devices (like the fluorescent light) which results in the behavior when USB is plugged in.

Any ideas how I can fix the problem?

Any ideas how I can fix the problem?

you mean troubleshoot. You got to get to the root cause before you design the fix. Not a hand-waving hypothesis, but the actual root cause..

First eliminate any other possibilities, like cover up all the IR sensors and emitters. If you still got problem, then it may indeed be EMI. Try a common mode choke to isolate the trouble spot.

when you have done this tell us the result.

I tried covering up the sensors to prevent any other outside interferance - that was actualy one of the first things I did. As for common mode choke - what could that be :slight_smile: ?

What I don't get is this - sensors themself are digital. They output 1 (if IR light is detected) or 0. So the only way that the interrupt gets triggered is if somehow the voltage on the arduino pin drops (the interrupt is configured to trigger on falling voltage) when I turn on the light.