How to avoid interference for an uC when I open/close the switch?

Thread Starter

korstiaan

Joined Jan 30, 2017
4
Hi,

I have a compact solution where I want my microcontroller to detect a open/close of a switch.
Due to existing cabling I can only provide 230VAC or nothing via this switch.
In order to get this interfaced with my microcontroller I used an optocoupler. (see schematic)
It all works fine except that if I my switch/optocoupler is too close to my power supply/microcontroller and I open or close the switch, I see interference in my power circuit and as a result my microcontroller reboots.
I can avoid it by placing the optocoupler far away but that I cannot use because it all has to fit on 1 small PCB. (except the switch, this is a wall pushbutton in the field).
Even if the transistor is not connected to the microcontroller I still have the problem. The problem comes from emissions in the power circuit.
On my oscilloscope I see glitches in the 3.3VDC circuit every time I open close the switch?
How can avoid this unwanted reboots?
I don't know how to filter out this unwanted glitches. (I also don't have a lot of space)
The easiest way would be to filter them out on the 3.3VDC side, but how?
Is there another, safer way to convert my 230VAC signal to a 3.3VDC input signal?

Thanks for helping.

Nieuwe notitie-800x573.png
 

thumb2

Joined Oct 4, 2015
122
Glitches are always a pain in the ... :(

I would try to filter the 3V3 line with a low pass filter with very lo
To step down the 230 VAC to 3V3 I would use a small step down transformer, an half wave rectifier and a trigger comparator.
 
Last edited:

crutschow

Joined Mar 14, 2008
28,215
Mount the 56k resistors as far from the micro circuit as possible.
Add a non-polarized capacitor at and across the output side of the two resistors.
 

Thread Starter

korstiaan

Joined Jan 30, 2017
4
Mount the 56k resistors as far from the micro circuit as possible.
Add a non-polarized capacitor at and across the output side of the two resistors.
Hi,

Yes, when I put resistor(s) at the switch and not on the PCB it is OK.
It is not so pretty to place these resistors in the wall switch instead of on the PCB but if it helps I can deal with it.
Anyway I tried to capture the signal, when I press the pushbutton, on my 3v3 power supply. I don't know if this really on the 3V3 power line OR if this is picked up by the oscilloscope probe. A fact is that the uC reboots.

file.png
 

Thread Starter

korstiaan

Joined Jan 30, 2017
4
First, I am convinced that it is possible to accomplish this task.

But can we be allowed to see a full schematic of the project, and a picture or two of the PCB?
It is still in testing phase.
I don't have designed a PCB yet. It is still on a breadboard (is also not good for all kinds of interference, I know, but I have to start somewhere).
Therefore, when the problem occurred I stripped all the connections to the uC so that there was nothing connected, only the power supply. (no other wires who can act as antenna's) The uC is an ESP8266 module from olimex. Only 3v3 and gnd connected. Even if the optocoupler is not connected to this uC, the uC reboots if I place my resitors on my breadboard.
 

AnalogKid

Joined Aug 1, 2013
9,498
It is still in testing phase.
I don't see how that affects the schematic...

Why is the opto LED current so low? 3 mA peak?

The only interference paths are radiation and conduction. Without a schematic and a view of the construction, I'm not sure what kind of advice you expect.

ak
 

crutschow

Joined Mar 14, 2008
28,215
Yes, when I put resistor(s) at the switch and not on the PCB it is OK.
So it would seem it's radiating from the cable.
If you don't want to use the resistors at the switch, you might try using shielded, twisted-pair cable with the shield connected to the mains safety ground.
 

GopherT

Joined Nov 23, 2012
8,012
If your microcontroller has an external reset pin (or configured as an external reset pin) make sure it is connected to a pull-up resistor (or pull down resistor depending on microcontroller). Power glitches can easily cause a reset if the connections are not appropriate for the reset.

Again, if you WANT HELP, post the necessary information. If you don't have a schematic, draw one out on paper and snap a photo.
 
Top