'Double-Click' switch detector circuit ?

Thread Starter

timetec

Joined May 10, 2009
2
Interesting problem
:

I need to create a latching output from the 'double-click' of a momentary push-button switch, but only within a fixed time period, say 2 seconds....

Think of double-clicking a mouse button - you must do it within a fixed period of time for the action to take place.

Here's the idea :

1/ A momentary switch is pressed once.

2/ After pressing the switch, a timer starts, with a duration of 2 seconds.

3/ If no further switch press is detected within the 2 second limit, no further action is taken - the output of the latch remains OFF / low.

4/ If the switch IS pressed again before the 2 second time limit is reached, the output is latched ON / high.

5/ A further single switch press simply resets the latch output to it's OFF / low state.

I've thought of using 555's, AND gates & counters, but am now really pulling my hair out....

Any circuit suggestions / sketches or tips would be greatly appreciated.

Thanks all
 

JDT

Joined Feb 12, 2009
657
Not too difficult to do either using some CMOS logic and a monostable timer or could be done in a simple micro-controller.

What you have got to be careful of is "switch bounce". On a normal mechanical switch (using contacts), every ON to OFF and OFF to ON will be a multitude of edges over a short time. You can see this if you have an oscilloscope. So be very careful of using "edge-triggered" logic.

In a discrete component solution you will need to filter the switch with a CR network. Then apply to your logic with schmitt-trigger gates.

In a micro-controller system, the switch is normally "de-bounced" by looking at its state over an over again at a fairly high speed (say 1000 times per sec). If the last n readings were all the same (16 say), then it is assumed to be stable. A number less is ignored. Then you apply your timer and double-click logic.

This is actually a kind of digital filtering.
 

Thread Starter

timetec

Joined May 10, 2009
2
I really like the idea of using a dedicated 8-pin PIC to do the donkey-work, instead of using a handful of CMOS IC's and many, many headaches !

How big a job would it be to create a routine to do this ?

Many thanks
 

CDRIVE

Joined Jul 1, 2008
2,219
You can download the free and very slick Programmer/Editor here.
http://www.rev-ed.co.uk/picaxe/

Here are othe Picaxe sources.
http://www.world-educational-servic...h=picaxe&search_button.x=15&search_button.y=8

http://www.hippy.freeserve.co.uk/picaxeqa.htm

http://www.sparkfun.com/commerce/product_info.php?products_id=8322

The programming editor has a Simulation Mode that enables the developer to write and test a program without any connection to the chip, though some programs really need real time for a true test of your code. This is because the simulator intentionally runs in adjustable slow motion and does not run in real time.
 

erikspan

Joined Feb 29, 2016
4
Hi, I realize this is an old thread, but I came across it searching for a solution for exactly the same problem! So I was wondering how you fixed it in the end?
 

JohnInTX

Joined Jun 26, 2012
4,787
It is usually best to start a new thread with your question but since you indicate that your problem is exactly the same, the thread can continue.
I like the others' idea of using a small uC instead of a lot of logic. Personally, I'd use a small PIC coded with XC8 but we'll see what other good ideas are offered. Its unlikely that the original members will answer since the thread is so old.
You should post a sketch of what you want to control with a detailed description of how you want to do it.
Good luck.
 

Sensacell

Joined Jun 19, 2012
3,432
Another way to accomplish this is with a capacitor charge pump.
One button press doesn't reach the trigger threshold, but two in rapid succession does.

It's a simple analog solution.
 

erikspan

Joined Feb 29, 2016
4
Thanks! That is an interesting approach. I hadn't think of an analog solution before. I'm definitely going to try that. Combined with a Schmitt-trigger for instance this could do the trick.
 

crutschow

Joined Mar 14, 2008
34,281
Below is my take on doing the charge pump approach suggested by Sensacell.
It's operation is shown for two push button presses 0.5s apart with multiple contact bounce pulses per press.
The signal is converted to a digital pulse at the second button press by a NAND Schmitt trigger.
The values of R1 and R2 can be varied to control the time between pulses, and the time to reset.

upload_2016-3-19_13-27-34.png
 

Attachments

blocco a spirale

Joined Jun 18, 2008
1,546
Below is my take on doing the charge pump approach suggested by Sensacell.
It's operation is shown for two push button presses 0.5s apart with multiple contact bounce pulses per press.
The signal is converted to a digital pulse at the second button press by a NAND Schmitt trigger.
The values of R1 and R2 can be varied to control the time between pulses, and the time to reset.

View attachment 102721
But it doesn't meet the criteria defined by the TS. i.e. double click = latch on, single click = off.
 

dannyf

Joined Sep 13, 2015
2,197
Check out ladder logic: it can program AVR / PIC graphically for something like this.

As to analog solution, it shouldn't be difficult to do so with a resistor + capacitor.
 

WBahn

Joined Mar 31, 2012
29,976
But it doesn't meet the criteria defined by the TS. i.e. double click = latch on, single click = off.
I think this would be used to detect the double-click case and a separate circuit would detect the single-click case and reset the latch. The single-click detection would have to be filtered by the double click circuit to prevent resetting the latch on the first click of a double-click event.
 

WBahn

Joined Mar 31, 2012
29,976
Yes, I didn't include that.
My interest was in how to detect the double click with an analog circuit.
It may not be that amenable to the double-click, single-click requirement. :confused:
I was curious how it would respond to the bounces, too. Thanks for the doing the sim.
 
Top