Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MCU: Strong interference/ripple when touching a wire connected to a GPIO

Status
Not open for further replies.

ranger81

Newbie level 3
Joined
Feb 28, 2017
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
58
Hello,

I have a microcontroller (ESP8266 or Atmega328p) which has one GPIO pin configured as "INPUT" with external 4k7 pullup resistor.
If I check the voltage of this pin using an oscilloscope I can see that it's near VCC (5v) with very low ripple/noise.
A 10cm wire with open end is connected to this GPIO pin. Once I touch the open end of this wire, the GPIO pin "goes crazy".
The oscilloscope shows very high noise (peak to peak approx. 4v) and this behavior continues as long as I'm touching the wire.

This also causes an interrupt (which is enabled on this GPIO) to trigger continously, which is my problem I need to solve.
I need to "harden" my circuit, that even touching the open end of the wire does not bring any (or very low) interference into the circuit.
But why do I have a wire with an open end? Well, under normal circumstances I do not have this situation.
A sensor is connected to this wire, but maybe the user unplugs the sensor from the cable and touches the wire.
This is why my circuit has to deal with this situation.

Here is a quick video demonstration of the behavior: https://youtu.be/QMgDTJJYQGg

I tried to solve this by putting an 100n capacitor across the GPIO pin and GND. The oscilloscope showed, that there is no more interference.
As an alterantive, I found out, that a very strong pullup of 220R also solves the issue, but of course the quiescent current is way too much...

The microcontroller is powered by a switching power supply. With a different power supply the issue does not occur! Only with the (cheap) power supply which is installed in my ceiling.
The problem: I'm forced to use the cheap power supply... The schematics of this cheap power supply is here: https://abload.de/img/psuxzlte.png

I would like to know, is the approach (fixing it with a cap between gpio+gnd) correct, it even works without the pullup resistor? And why does touching the open end of the wire cause a pulled-up GPIO pin to go crazy? Is this an EMI issue related to the power supply or whats the explaination for this?

Any comments are greatly appreciated!
Thanks
 

Hi,

I'd simply prevent that the wire can be touched.
(Usually I avoid touching "unknown" wires, because it may be dangerous. So why should one touch the wire at all?)
Besides the unwanted interrupts you will have other problems: ESD. It's generally no good idea to make microcontroller signals acessable.
If there is a need to keep it "touchable", then you need true ESD protection.

***
To your problem.
The problem is that the SMPS introduces high frequency switching common mode noise to your application.
This noise is referenced to earth ground, therefore, as sonn as you touch the wire (and you are referenced to earth ground, too somehow) there is a current flow. It's not unusual, that an AC voltmeter shows up to100V between your finger and your application_gnd.

Klaus
 

Thanks for your comment.

Two questions:
- Probably a dumb question, but since we are in the elementary forum... Why is there a earth referece if I touch the wire. I think the switching pwer supply creates an isolated voltage using a transformer? So there is still an earth reference? Why does this issues not occur for other power supplies?

- Endusers... You can't forbid them to touch the wires. If you tell them, they'll touch them on purpose. What about the "solution" I have posted above. Adding a 100n between this GPIO and GND? Is this an acceptable way how to solve this?
 

Hi,

Mains voltage usually (at least in Europe) is referenced to earth GND.
Now in SMPS there is a primary side high frequency switch that causes high voltage noise.
The SMPS inside transformer (is small) and it couples those high frequency noise from primary side to secondary side (often coupling is caused by parasitic capacitance - winding to winding).

Some of the SMPS have internal capacitors to suppress those high frequency noise. Sometimes they use two capacitors (small in value, and safety rated) from each mains input to secondary GND.

While this truely suppresses high frequency noise they introduce mains AC current to the secondary side. Low frequency.

****
Isolating. Yes.
In an ideal imagination this means infinite high impedance between primary and secondary side. It means zero pF of coupling capacitance. It means infinite distance between primary and secondary.
But we live in a real world.

100pF of coupling capacitance at 50Hz means about 32MOhms.
the same capacitance at 300kHz switching frequency means just 5kOhms.

****
Why is this not with usual power supplies?
* no high frequency switching
* no need for high frequency suppressing capacitors
* low coupling capacitance from primary to secondary

***
"Forbid" ... I said "prevent", like at every mains outlet.

Capacitor: If there is no functional problem with a capacitor, then you may use a capacitor.
But this does not mean you don´t need ESD protection. ESD means energy, but a capacitor doesn´t dissipate energy.

Klaus
 

I see two simple points.

1. If a signal is exposed to the outside, it needs ESD protection, as explained by KlausST.
2. If floating input is an expected condition, you need to reconsider your software design. A continuous interrupt blocking your system must never happen. There are many ways to disable the regular pin function temporarily if the floating condition is detected.

Placing a big capacitor can be appropriate if the sensor signal is really slow. Overvoltage protection for exposed signals is necessary though.
 

@KlausST: Thank you very much for clearing things up with the SMPS, isolation and noise.

@FvM: Could you please point out a little bit more in detail how to disable the regular pin function temporarily if floating is detected ?
I would implement this the following way:
Inside the ISR, check when the ISR was called the last time, if this is just a few ms, then detach the interrupt.
In my main loop after a certain time has passed, I will attach the interrupt again. Is this the same approach you were pointing out, or are there better alternatives?

Thank you very much for your support!
 

Inside the ISR, check when the ISR was called the last time, if this is just a few ms, then detach the interrupt.
In my main loop after a certain time has passed, I will attach the interrupt again. Is this the same approach you were pointing out, or are there better alternatives?
Yes I was considering something like this.

Seriously I have no clue what's the point of using an interrupt for a slow sensor that can be filtered with 100 nF. Just polling the pin periodically would avoid problems of continuous interrupt. But if you find interrupt appropriate for some reason, the sketched solution should work.
 

Seriously I have no clue what's the point of using an interrupt for a slow sensor that can be filtered with 100 nF.
The microcontroller might be busy reconnecting to the wifi network and therfore does not recognise the sensors input. Therefore it's essential for me to use an interrupt, except.... I could use a timer to do this? As far as I know timers also run regardless of the current software "loop" instruction?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top