Debounce relay switch connected to logic input? - Page 1
Forum section: electronics / projects

author: bernz
author_rank: Newbie
timestamp: February 03, 2018, 11:30:06 pm
content: I'm working with one of those cheap but cool USB relay boards ( PCB with a number of relays and a USB function that creates a virtual serial port on the host; control relays by sending bytes to the USB function ), and I want to control the logic input of another IC using one of the relay switches.Do I need to debounce the relay contacts? I want the logic to switch cleanly from one state to the other, and the input is on a chip that is not programmable, so I feel like it would be good to put an RC snubber on the relay contacts.Is this overkill?If not, what are good values for the snubber? There are some "rule of thumb" formulas for choosing values for C and R, but I don't know how to interpret the datasheet well enough to find the values to use for the formulas. Based on what I know of the chip -- datasheet here:http://www.ti.com/lit/ds/symlink/ts3usb221.pdf-- my gut says something between 20 and 40 pF, and 5 k - 10 k ohms.Any hints?

author: JonPyro
author_rank: Regular Contributor
timestamp: February 04, 2018, 03:37:50 pm
content: I think the datasheet is trying to show switch capacitance in the bottom diagrams if that is where you are getting your pf values from.This article maybe some help if you scroll down and see how they have debounced their switch :https://www.allaboutcircuits.com/technical-articles/switch-bounce-how-to-deal-with-it/You could also achieve something similar going though a NAND gate and this site goes into it well as well as RC circuit :http://www.ganssle.com/debouncing-pt2.htmI presume you are not able to scope the relay to see how much bounce/noise it makes?

author: phil from seattle
author_rank: Super Contributor
timestamp: February 04, 2018, 04:52:02 pm
content: There are lots of ways to debounce contacts. Via HW a low pass rc filter works well (if you get the RC constant right) or you can use some sort of latching circuit like Ganssle shows in the link JonPyro gave (btw, Ganssle is a great resource on the topic of debouncingPart 1 shouldbe required reading).Via SW you basically test the value of the contacts over a period of time (say every 5 mS over a 40 mS period) and when they stop changing, the value is stable. I use a counter method where closed adds to the count and open subtracts. When the count reaches a preset maximum, the switch is closed. Otherwise it's open. Easy to implements via a timer interrupt but can be polled as well.

author: ahbushnell
author_rank: Frequent Contributor
timestamp: February 04, 2018, 07:43:22 pm
content: Quote from: bernz on February 03, 2018, 11:30:06 pmIf the board uses a mechanical relay then it could be a problem. But if the board is using a solid state relay then I wouldn't think there would be bounce issues.

author: daedalux
author_rank: Contributor
timestamp: February 04, 2018, 09:18:28 pm
content: Electronic devices as IGBT and such need snubbers indeed. I think that they work even worse than relays without that. Variable frequency drives for motors have always them at the IGBT no matter how small o cheap the drive.

author: danadak
author_rank: Super Contributor
timestamp: February 04, 2018, 10:13:28 pm
content: Some ref material on debouncing -https://www.dropbox.com/s/r8vfqea5fhiuzw1/Debounce.zip?dl=0Regards, Dana.

author: bernz
author_rank: Newbie
timestamp: February 05, 2018, 03:15:35 am
content: Thanks, all, for your input. I found the Ganssle stuff very illuminating. The 'allaboutcircuits' link was also full of good info.I decided to try an RC snubber with a transition time of 10 ms, because the application doesn't require fast switching.There is a scope at work, which I will see if I can get some time on, to look at the device with and without the snubber. It seemed to work okay without, when I first tried it.If I get some scope time, I will try to post photos of the noise waveforms.

author: phil from seattle
author_rank: Super Contributor
timestamp: February 05, 2018, 05:00:18 am
content: your rc snubber (aka Low Pass Filter) needs to have a cut-off that will attenuate the slowest pulses from the contact bounce. 10 mS, i.e. 100 Hz may be ok but it really depends on your relay. A scope or even a logic analyzer can give you a clue. An LA might miss the really fast pulses but those will get filtered easily.

author: macboy
author_rank: Super Contributor
timestamp: February 05, 2018, 09:00:03 pm
content: Another idea to consider for ultra-cheap, simple logic output from a PC is to use a USB-to-TTL serial converter, but make sure to get one with all modem control signals (RTS, CTS, DTR, etc.). The modem control signal outputs can be directly manipulated by whatever software has opened that serial port. Likewise, the inputs can be directly read. No data needs to be sent over the serial port, you can simply use those signals as general purpose I/O.Yet another even better idea is to use a cheap $3 Arduino clone (especially a "Nano", having in USB-to-serial). Write or copy a sketch that will accept simple commands over the serial port to set I/O pins to desired state. With small additional effort, you can read digital state, and even read analog levels at the analog pins as well. I'm certain there are many, many people who have written and shared such sketches.You should consider that those relay boards use the cheapest of the cheap power relays. Not only are they not especially reliable relays even for their intended use, but using a power relay to switch a low current, low voltage signal is a poor choice. The lack of sufficient current and voltage to create a small arc when operating the relay will mean that oxides and other contaminants will not be burned off and will build up over time. Eventually, the contacts fail. You really need to use a small signal relay for this type of thing, as their contacts are designed with non-oxidizing materials including gold. In contrast to power relays, which should arc (a little), signal relays are very sensitive and their contacts mustneverbe allowed to arc. Generating an arc even a handful of times can destroy this thin precious metal contact plating, leading to early failure. Fun stuff.

author: bernz
author_rank: Newbie
timestamp: February 07, 2018, 03:06:52 am
content: Wow, fantastic deep clues on relay contact arcing,macboy!phil from seattle, i agree, checking the relays out on a scope is the most sensible first step to dealing with this question.I have discovered a "deluxe" model of these "cheap-ass relay boards", with a much higher market price ( 75-ish bucks ) which uses SSRs.The project involves a secondary switch function: a DC device load, where the target device is rated at 5 A ( on its DC 12 V power supply ). Using a "relay board" with 4 SSR "channels" each rated to switch 3 A DC loads, is it madness to connect two of the SSR switched lines in parallel, and then tie together their driver input logic lines, so that if either SSR is activated, they both activate nearly-simultaneously to provide current handling of 6 A by "using up" two of the SSR channels?It seems there would be a risk of one of the paired SSRs to "activate" ( begin passing the 5 A DC current through its switched side ) a bit sooner than the other, so it would bear the full brunt of the load, exceeding its spec, and leading to loss of magic smoke. Or am I worried about nothing significant here?