Noise on Digital Inputs

Thread Starter

signalflow

Joined Mar 12, 2014
50
Hi, I am getting lots of noise on the digital inputs. See the schematic below. I have a switch that is remote and the 2 wires for the switch run in the same bundle as high voltage 240Vac wires.

I have a bi-directional TVS diode (Voltage_reverse_standoff=5.8V, voltage_breakdown_min=6.45V, voltage_clamping_max=10.5V).

I also have an RC filter with R1 and C1 and a cutoff of 160 Hz. I also added C2 (0.1uF) for extra filtering.

I am using a MCP23S17 as an IO expander for my PIC microchip.

I have determined that the noise is getting into the system from only this remote switch that I have and it is corrupting data on an LCD.

Anyone know how to better filter this digital input line?

Thanks.

 

THE_RB

Joined Feb 11, 2008
5,438
It would help if yuo showed a 'scope shot of the noise signal, so we can see what it looks like.

In the meantime I would make sure C2 is close to the digital chip, and connect the top of C2 directly to the digital input pin.

Then I would remove R2. And reduce R3 to 10k, and make R1 470 ohms, then put another R1b 470 ohms between the switch bottom terminal and the GND. That will RC filter noise on both switch wires.
 

ErnieM

Joined Apr 24, 2011
8,377
Two things: keep noise out, and squelch any that still gets in.

First to keep it out you can twist the wires together, and ever better replace with twisted and shielded wire. But just putting the wires into your portable drill will make a good thing: twist till the wires are fairly tight, there will be a noticable shortening on the length so allow for that (25-50%)

Next don't treat the "ground" wire as if it has magical properties: filter it too from the switch, at least put a resistor in series at your unit.
 

Thread Starter

signalflow

Joined Mar 12, 2014
50
OK, thanks for the input. I will add a resistor in series with the ground wire coming back from the switch.

It's difficult to move caps closer to the digital IC since I have a board already made and now I'm adding components externally to figure out how to best filter it before I get another board made. I want to prove the filtering out with breadboards before I spend time/money making another board.
 

Thread Starter

signalflow

Joined Mar 12, 2014
50
OK, I added a 470-ohm resistor in series with the ground wire coming from switch. I still get a few glitches on my LCD every once in a while but it seemed to have helped some at least.

I forgot to mention, I am switching a contactor and other AC motors on and off to generate the noise, glitches on the LCD.

I am trying to get rid of the glitches even with unshielded/untwisted wire that way I know it is robust and then I can change it to shielded wire. Is it possible to make the electronics robust enough to filter out noise even with unshielded wire? The above circuit almost works with the added 470-ohm in series with ground but not totally.
 

Thread Starter

signalflow

Joined Mar 12, 2014
50
Thanks Joey, I'll try that. What does the diode do for you? To shunt any positive voltages that appear on the ground line?
 

joeyd999

Joined Jun 6, 2011
5,285
Thanks Joey, I'll try that. What does the diode do for you? To shunt any positive voltages that appear on the ground line?
First, the 2222 is always on when the switch is open...the base gives a nice low impedance shunt to ground -- this is what eats the noise. You'll always see about 0.6 to 0.7 volts across the open switch.

Upon closure, the base is shorted hard to ground -- again...no path for noise.

The diode will shunt negative excursions to ground that may be induced inductively, protecting the base from exceeding its Vbe reverse breakdown voltage.

Edit: Also, this network protects the CPU (or whatever you have connected to the output) to a great extent. I generally don't like to leave CPU/digital inputs exposed to the outside, uncontrollable environment. In *really* noisy environments, optical coupling is better at provide absolute isolation -- but I don't think you will need it.
 

Thread Starter

signalflow

Joined Mar 12, 2014
50
OK, I added a 470-ohm resistor in series with gnd line going to switch and I moved C2 (0.1uF) directly to the chip (MCP23S17) between the Digin0 pin and Gnd pin.

I still get some noise. Seems better maybe, but still getting glitches on LCD.

I will probably try Joey's circuit next.

I also ordered some shielded cable for testing.
 
Top