bansari18
Posts: 21
Joined: Tue Mar 07, 2017 1:04 pm

using two or three tap for different operations

Thu Apr 06, 2017 1:45 pm

hello,
i want to know if it is possible to use single vibration sensor or touch sensor for 3 different operation.. like if i press it once it should do a particular task, if pressed twice then do some other work.. just like a mouse pointer do some different task for single click and double click.. if it is possible or not.. any help please..
Thanks in advance.
-Bansari

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: using two or three tap for different operations

Thu Apr 06, 2017 3:11 pm

Yes that doesn't sound too difficult, you just detect each "click/tap" and time if there are more than one detected within a certain amount of time.

User avatar
Paeryn
Posts: 2987
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: using two or three tap for different operations

Thu Apr 06, 2017 3:48 pm

bansari18 wrote:hello,
i want to know if it is possible to use single vibration sensor or touch sensor for 3 different operation.. like if i press it once it should do a particular task, if pressed twice then do some other work.. just like a mouse pointer do some different task for single click and double click.. if it is possible or not.. any help please..
Thanks in advance.
-Bansari
I can't see why not, it's just a matter of determining if two (or more) taps happen within whatever timeframe you want and doing the appropriate action. How you go about that depends entirely on how your sensor is connected and what programming language you use (or whether you have a particular program that can get readings from the sensor and carry out appropriate actions).
She who travels light — forgot something.

bansari18
Posts: 21
Joined: Tue Mar 07, 2017 1:04 pm

Re: using two or three tap for different operations

Fri Apr 07, 2017 8:49 am

Paeryn wrote:
bansari18 wrote:hello,
i want to know if it is possible to use single vibration sensor or touch sensor for 3 different operation.. like if i press it once it should do a particular task, if pressed twice then do some other work.. just like a mouse pointer do some different task for single click and double click.. if it is possible or not.. any help please..
Thanks in advance.
-Bansari
I can't see why not, it's just a matter of determining if two (or more) taps happen within whatever timeframe you want and doing the appropriate action. How you go about that depends entirely on how your sensor is connected and what programming language you use (or whether you have a particular program that can get readings from the sensor and carry out appropriate actions).
yes.. thats what i am actually trying to do.. i am using RPI 3 B and my programming is in Node.JS. I tried to detect tap but problem is that, when i press it for once only, it shows multiple taps.. so I want to know what kind of sensor should i use for this purpose . it would be great help if you can suggest one. i have tried using MPR121 ic and also made a touchpad with conductive material to work as push button. but not working as expected..
Thanks in advance.
-Bansari

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: using two or three tap for different operations

Fri Apr 07, 2017 1:51 pm

bansari18 wrote:when i press it for once only, it shows multiple taps
possibly this helps about software to make clean ON OFF signals when the hardware is not prepared for that:
https://www.arduino.cc/en/Tutorial/Debounce

it is about the idea, i not say you should use arduino!

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: using two or three tap for different operations

Sat Apr 08, 2017 4:24 am

Ha, i could not stop thinking about that and got a crazy idea:
treat it like a analog signal and filter and schmitt trigger it again https://en.wikipedia.org/wiki/Schmitt_trigger
that is what you actually would do if you have to solve it with hardware...
with a analog filter we smooth ( and delay the signal ) what works on a analog input but why not
also on a jumping digital input. see, if you run a analog filter on a PWM signal what you get?

-a- filter
tA = 0.2; // ( tunable 0 .. 1 )
// (tB = 1 - tA ) if tA = tB = 0.5 we have a average filter
PV = new input analog or digital 0.0 ... 1.0
PVf = PV * tA + PVf * ( 1 - tA );

-b- SCHMITT trigger hysteresis limits
// hH = 0.75;
// hL = 0.25;
newH = False;
newL = False;
if ( PVf > 0.75 ) { newH = True; }
if ( PVf < 0.25 ) { newL = True; }

-c- check on change and timing
if ( mySig == False && newH == True ) { mySig = True; pos_edge_time = now(); }
if ( mySig == True && newL == True ) { mySig = False; neg_edge_time = now(); }
deltaT = neg_edge_time - pos_edge_time;
// use 3 different times to select 3 different jobs example
if ( deltaT > T_job_A && deltaT < T_job_B ) { job_A(); }
if (deltaT > T_job_B && deltaT < T_job_C) { job_B(); }
if (deltaT > T_job_C ) { job_C(); }

point is you not have to deal with timers in microsec like with a software debouncing...
sorry i not have a easy idea to put that signal analysis in a trend graph to show my idea more understandable.

Return to “Beginners”