View Full Version : Measuring Relay Debounce Time

08-21-2005, 02:06 PM
REV 1.4
Relay Coto 2200-2301

ahaaa The Boss at my primary Job finally is going to let "The Network Admin" (Me) Do a STAMP project for work.
It appears we got a bunch of Bad relays recently .... with the 1 ms debounce time out of spec. I have been
looking through the BS Mauual and it looks like the COUNT command may do the trick .... here's my logic for how to implement
this :

the stamp to a 2n2222A which drives the coil
turning on the relay (Relay Closed). Output
of relay goes to PIN 3 Stamp (Pullup Resistor)
2. Set COUNT for 1 second to PIN 3 Stamp COUNT 3,1000,MyVar

Multipl MyVar * 1.20us Visual Basic APP

P2 HIGH 1 sec

RELAY Bouncing

I would reach the 65535 threshold of MyVar if the Debounce
times was ~75ms. Im not sure what the pulse width of the bounce
is however Im thinking it doesnt mattter. Im Basicall just waiting for
it to end and making sure MyVar*1.2us <1ms. Am I in the general



Koy Ja !

Chris Savage
08-21-2005, 11:14 PM

I see four things in your message that flag me. One is connecting the transistor. You need a resistor between the base and the Stamp I/O pin controlling it, but you didn't mention it. Also, when you talk about the output of the Relay going into the Stamp I/O pin, you mention a pull-up resistor. Does this mean the other relay contact is going to ground? It should be. You can follow the example in the help file for the button command on a circuit to connect this properly.

On the code side, you mention something about a VB App? I'm not sure what that relates to, but you cannot directly multiply times a decimal number. There are functions within the BASIC Stamp that can get around this though.

Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Jon Williams
08-21-2005, 11:50 PM
It seems to me that job is best done with a high-speed 'scope -- I don't think the contact bounce pulses will be long enough for the BASIC Stamp to "see."

Jon Williams
Applications Engineer, Parallax

Chris Savage
08-22-2005, 02:50 AM
And then there's what Jon added... =)

Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

08-22-2005, 06:12 AM
Sorry I forgot to mention the complete setup .... Luckily I have it already built into
"The Never Ending Project" As you can see from the Photo (and I didnt mention :)
There is a current limiting res going into the Base of the Transistor. One side of the
switch is going to 499K pullup(5V) and the other side to ground ... I needed to modify
the gnd portion but was easily done because it went to an RCA connector wich I just
cut into the cable and connected to ground. The VB app I was mentioning would convert
the 0-65K MyVar to timing since Im not to familair (YET!) with doing Floating point math
with the STAMP.

I then did what Jon suggested and hooked up the Fluke 123 ScopeMeter .... As usual
you guys are correct ! The Pulses are only ~200ns and the Peak start at only 1V ...
I believe the STAMP needs 1.4 Volts to detect. I could use a window comparator
to to give me crisp 0 and 5V transistions but then I would still have the timing issue
to worry about. As you know the Min Pulse width for the BS2P40 Im using for debug
is 1.20us ..... I cannot find the spec for MPW for your newest part BS2PX. I dont think
it will be in the range of 100ns i would need.

Here's a pic of the Debounce on the scope.

Thanks again Guys


Koy Ja !