911!!! Need to figure out how to debounce my switch

Thread Starter

MATTY B

Joined Jan 26, 2008
49
Hey Im in a big bind, I need help with debouncing the switches Im using with this circuit I built>> http://that.homepage.dk/PDF/PBS2.pdf . The schematic is on the second page that Im using. The circuit itself works fine however I have found that the circuit is unstable with the way I have to switch it. If you notice the switching has a common, a normally open and a normally closed lead. I am using a 5 pin relay to acclomplish this with a standard momentary switch (com is on pin 30, normally open is on pin 87 and normally closed is on pin 87a). I am assuming that the relay contacts are bouncing causing the outputs to be very erratic. Sometimes it works fine and other times it seems like it is skipping steps or not working altogether. The schmitt trigger should or at least I assumed handle debouncing the switch but it is still happening. When I remove the relay and touch the com to nc then to no it works fine everytime. I dont know what to do but my friend cannot drive his car cause we installed this and he cant get it to work correctly. Is there ANYTHING I can do to add on to the circuit to possibly take care of this problem? This is an urgent problem and I need to figure out a solution quickly. Please help I am desperate right now
 

Thread Starter

MATTY B

Joined Jan 26, 2008
49
I looked at that prior to posting among other pages and most recommend a schmitt trigger which I already have in the circuit. Anyone have an idea as to why I would be getting bounce to begin with? Or possibly a way to delay it that also works with a CMOS like Im working with? Believe me Im the king of google, hell thats how I found this site.
 

thingmaker3

Joined May 16, 2005
5,083
Add one capacitor from 30 to 87, and another from 30 to 87a. In conjunction with the 10K resistors, this should provide enough additional denouncing.

Assuming you've got a good relay that isn't chattering, that is.
 

Thread Starter

MATTY B

Joined Jan 26, 2008
49
what size you think I should use? I tried a .01 mfd and a .047 mfd and although it seems to have slowed it down it didnt fix it unless I need a larger capacitor. Maybe there is something other than a relay to do what I need and get rid of the problem altogether. Im using a Bosch relay so its not what Id call cheap by any means but its made for automotive applications not digital circuits so go figure. All I need is something to use a momentary switch and do clean switching between the two. At this point Im totally open to ideas
 

Wendy

Joined Mar 24, 2008
23,415
Larger caps should fix the problem. Here are the examples I've put in my album. Larger pull up resistors would also have the same effect.

 

Thread Starter

MATTY B

Joined Jan 26, 2008
49
thanks for the help guys do you have any suggestions on size for the caps or for larger pullups? I know theres 10k pullups now should I make em 100k, 50k ect?? If I get some caps what would you suggest for those? I can follow directions but Im not good at designing this stuff, once again thanks for the help
 

SgtWookie

Joined Jul 17, 2007
22,230
Matty! Why on earth are you using a switch to control a relay to drive the debounced switch circuit?

Why didn't you just get a pushbutton switch that was single-pole, double throw? You would not be having this problem if you had done that.

Your problem doesn't lie with the board that Soren designed - it's because you're using a single-pole single-throw switch that has bouncing contacts to energize the relay's coil. This is causing the relay to chatter on and off several times, instead of simply turning on when you push the button, and off when you release it. Changing things on Soren's board will not fix this problem, because it is between the non-debounced pushbutton switch and the relay. Adding a capacitor across the relay's coil will help things temporarily, but it will result in the switch contacts rapidly getting burned up.

If you get a proper single-pole double-throw pushbutton switch and get rid of the relay, your problem will dissappear.

If getting a proper single-pole double-throw pushbutton switch is out of the question, there IS a way to mod the board to make it work with a single-pole single-throw switch (sans relay) - but the debouncing won't be nearly as reliable as if you went the SPDT route. I urge you to get the proper switch instead.
 
Last edited:

Thread Starter

MATTY B

Joined Jan 26, 2008
49
Im using the relay cause you cant find many single pole double throw switches that say ENGINE START on them not mention many push button SPDT for that matter, also I never said there was an issue with the circuit just the way I have to switch it. What is the other way to do it? Because of me my friend is out of his car until I can get this fixed.
 

thingmaker3

Joined May 16, 2005
5,083
Microswitches are SPDT, and come in a variety of packages, including pushbutton. If labeling is an issue, surely one can print out a stick-on label.
 

mik3

Joined Feb 4, 2008
4,843
Hey Im in a big bind, I need help with debouncing the switches Im using with this circuit I built>> http://that.homepage.dk/PDF/PBS2.pdf . The schematic is on the second page that Im using. The circuit itself works fine however I have found that the circuit is unstable with the way I have to switch it. If you notice the switching has a common, a normally open and a normally closed lead. I am using a 5 pin relay to acclomplish this with a standard momentary switch (com is on pin 30, normally open is on pin 87 and normally closed is on pin 87a). I am assuming that the relay contacts are bouncing causing the outputs to be very erratic. Sometimes it works fine and other times it seems like it is skipping steps or not working altogether. The schmitt trigger should or at least I assumed handle debouncing the switch but it is still happening. When I remove the relay and touch the com to nc then to no it works fine everytime. I dont know what to do but my friend cannot drive his car cause we installed this and he cant get it to work correctly. Is there ANYTHING I can do to add on to the circuit to possibly take care of this problem? This is an urgent problem and I need to figure out a solution quickly. Please help I am desperate right now
Why dont you debounce the switch by using only a SR flip-flop?
 

SgtWookie

Joined Jul 17, 2007
22,230
Why dont you debounce the switch by using only a SR flip-flop?
If you'd looked at the schematic in the PDF file he'd linked to in his first post, you would see that the board already HAS the equivalent of a S/R FF, complete with Schmitt-trigger inputs.

Where Matty went wrong is that he tried to use a non-debounced SPST switch to drive the coil of a SPDT relay.

He can't use a S/R FF with the relay, because it wouldn't have enough current to drive the relay. So he'd have to add transistors to drive it. The whole thing would get ridiculously complicated for something that's already taken care of on the circuit board. What he really needs to do is just get the proper switch, let the board do what it was designed to do, and all of these problems go away.

There is a work-around, but it's not going to be nearly as good as the way Soren has it now.
 

SgtWookie

Joined Jul 17, 2007
22,230
Going from Soren's schematic on the 2nd page of the PDF:
1) Cut the trace from IC1 pin 4.
2) Remove R2, replace it with a 220K resistor.
3) Short IC1 pins 1 and 2 together.
4) Connect a 1uF (approximate) capacitor between ground (Vss) and IC1 pins 1 & 2, - side on ground.
5) Remove the SPDT relay that you added.
6) Connect one side of your SPST switch to the BTN-NO terminal.
7) Connect the other side of your SPST switch to ground using a 10k resistor.


You will probably need to adjust the size of the capacitor. If the switch action is too slow, decrease it. If you get switch bounce (skipped stages) then increase it. You are better off having it responding slowly than skipping stages.

Keep looking for an appropriate SPDT switch. That's the best fix. Even if you get it working "pretty good" now, eventually the switch will get worn enough so that the bounce problem will return.

Soren's de-bounce won't have that problem - it will never bounce. It will go straight from working perfectly, to not working when the switch eventually wears out.
 

Attachments

Last edited:

Thread Starter

MATTY B

Joined Jan 26, 2008
49
Thanks man, I will try that out. If a switch needs to be replaced after a few years thats no big deal. It being a custom car though, looks precede function as in this case so I gotta make it work with the switch I have. Thanks so much for the help though Ill post back when I get it modded
 

SgtWookie

Joined Jul 17, 2007
22,230
This is a simulation of the switch hack.

Pressing the button will get an almost instant response; that part isn't shown.

It will take 2/10 of a second for the switch to fully release.

You should consider increasing the capacitor to 2.2uF, that will give about a 1/2 second response time.
 

Attachments

Thread Starter

MATTY B

Joined Jan 26, 2008
49
ok well unfortunately that didnt work. It engages cleanly but it seems to discharge the cap and it turns off. Example hit the button ACC turns on for about a half second then it turns off. Hit the button again and the ACC and IGN turn on and once again after about half sec they both turn off. Start doesnt even work and you need to remove power from the board for it to start over. Im gonna order an SPDT switch from Allied, they have a nice 30mm vandal switch that will work, not what he want nor would I but its that or nothing.
 

SgtWookie

Joined Jul 17, 2007
22,230
Sounds like you've managed to short out Vdd by connecting the switch to the wrong side of R2, with no current limiting resistor - or maybe you used a 22 Ohm resistor for R2 instead of 220k (red red yellow).

Double-check that you have connected the pushbutton switch between IC1's pins 1 & 2 (which should be shorted together) and ground, with a 10k resistor in series.
 
Last edited:

Thread Starter

MATTY B

Joined Jan 26, 2008
49
heres what I did. I cut the trace to pin 4 with a razor blade. Solder bridged pins 1 and 2. Drill a hole on the trace that comes off of pin 1 and to the ground plane and installed the cap. Replaced r2 with a 220k ohm resistor hooked the NO wire to one side of the switch. Hooked the other side of the switch to com which is on the ground plane and soldered a 10k resistor in line on the wire. It did not work plain and simple. I followed your instructions to a T and i just didnt work properly. If you have any other ideas Im all ears or to what part of this I did wrong. I verify all components with my fluke 88 so the resistors are verified to make sure Im not color blind and that meter is auto ranging swo there isnt a chance that I read it on the wrong scale. Ill try whatever I can but at this point I gotta get a switch cause my friend is bumming rides to get to work and Im to blame. Itd be cool if I can get this to work cause I bought a trick Altima engine start button but it is momentary and even that bounces.
 
Top