Do I need a TVS? what kind?

Thread Starter

mariosergio

Joined Feb 23, 2018
13
Hello everyone, and thanks for reading

I´ve been working in a project to dim lamps from a cellphone, and it´s so frustrating because everything works really good when I'm testing, but when I install the device in the wall to control actual lamps everything starts to behave in a non desirable way.

The circuit consists of a microcontroller controlling 2 triacs via optocouplers. Microcontroller knows the timing because it receives a Zero Cross signal from a full bridge rectifier (also via optocouplers). Microcontroller also receives Rx and Tx with messages to control de lamp.

So far everything works good, the problems start when I connect the wall switches to the Interruption on Change pins of the microcontroller.
I'm using the build-in pull-up resistors. The wall switches receives two small wires, one for ground and the other goes back to the microcontroller.
The problems I see is when I change a switch, sometimes nothing happens, sometimes the lamp turns on/off and sometimes the non related lamp turn on/off. I'm guessing that this is caused by the long wire that goes from the microcontroller to the wall switch. The wire is about 10 meters (30 feet).

Thinks that I believe is related:
  • The triacs are model BTA16-600BW (and the W means it's snubberless)
  • AC is 127V@60Hz
  • VCC is 3.3V
  • I´m using a 5 to 10 ms for debouncing the switches
  • Circuit have a 1nF capacitor connecting the microcontroller pins to the ground (the pins related to interruption-on-change)
This last two measurements have reduced the problem considerable, but problems still occurs.

I've done some research and found this article, so it looks like a Transient voltage suppressor may be needed, but how can I know if that is the case? And what kind of TVS do I need?

Please, keep in mind that when the wall switches are not connect, everything works fine, even the serial communication

I´m not home right now, but latter night I can post images of the circuit if it's necessary.

Thank you very much for taking the time to help me, and sorry for the long post.
 

Sensacell

Joined Jun 19, 2012
2,567
Share your schematic- of the entire system.

Just randomly adding a TVS is not going to do it, let's help you figure out what's causing the problem.
 

danadak

Joined Mar 10, 2018
4,057
I found mechanical switches that had horrible bounce, and so
almost always use 100 mS for debounce. Use your DSO and do
single shot triggers, it will amaze you, performance of one switch
to another.

As far as relying on hi z pullup, hi in the sense of 5 - 10K, and long
wire runs, I would drop that to 1K or less, to minimize coupled pickup.

Any other input pin on UP not driven by a low z source, force their
impedance with PU or PD in the low 1K range.

I have read where others use light C bypass on inputs, depending
on application.

You can use your DSO on infinite persistence, 100 mS/div or so,
and look at pins individually in use to see what pk-pk noise looks
like.

Twisted wire runs reject CM noise to some extent.

Regards, Dana.
 
Last edited:

Thread Starter

mariosergio

Joined Feb 23, 2018
13
Hello everyone, updates on the issue..

I found some erros in the code.

The interruption on change was causing the MCU to access unplanned addresses in memory. I adjusted some variable sizes and everything works better now.

The system can now work properly for several hours, but at some point it just starts a strange behave . I guess that it reforces the theory for the TVS, right?

Below is a picture of the single shot Danadak was talking about, the bouncing signal is indeed very different then what I expected, but it seams that 5ms deboucing is ok.

Is there any experiment I can to verify that this is caused by transients?

kind regard

20171112_584139.png
 

danadak

Joined Mar 10, 2018
4,057
When you say strange is code still running or has CPU lost its marbles ?

Your scope capture gives me the impression it is not sampling fast enough.
I would say 1 uS would reveal the true nature of the transients.

I would start putting scope on power rail set for one shot trigger, say .5V above
or below the rail nominal V. Then move on to inputs one by one. Tedious but
no easy answer.

Bypassing, polymer tants best for bulk bypassing, parallel-ed by .01 and/or .1 uF
ceramic on power rail.



Regards, Dana.
 
Last edited:
Top