LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Only execute a case if two consecutive button presses are separated by a certain time?

Hello, I am relatively new to labview and I'm writing a program for a
research application. A rat looks at images and presses a lever, and
if an image is classified as rewarded, a case structure executes code
that delivers a reward. However, I'd like to add a control so that if
the rat presses the lever twice before a specified amount of time
elapses it will not recieve a reward. Can someone help me out? If you
know how and can post code where a boolean button (OK button) lights an
indicator, but the indicator does not light if two button presses occur
before a certain amount of time elapses, I would be eternally grateful!


Thank you,
Henry

0 Kudos
Message 1 of 4
(2,786 Views)
You need to use the boolean to trigger a flag on and off. Whenever you trigger it on you should start checking whether your timeout elapses and if it does then you need to reset your flag. Attached is one example, but not one which would necessarily scale up nicely.

___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,771 Views)
You can just check the elapsed time inside the lever event and reward accordingly. Attached is a simple example. Let me know if you have questions. 🙂
 
Of course there are some issues that are not well defined. Do you want the time to reset at each reward or at each button press?
 
For example, if the reward timeout is five seconds and the lever is pulled every second, followed by a five second pause, followed by another lever pull. Should:
  1. the reward be give at the fifth pull and at the last pull? (2 rewards)
  2. the revard only be given at the last pull? (1 reward)

Currently, I implemented case 2. For case 1 just wire the new time across the reward case and the old time across the "no reward" case, then into the shift register.

0 Kudos
Message 3 of 4
(2,749 Views)

rat = discussion forum regular

images = posts

press lever once = submit good post response

reward = 5 stars

press lever twice = submit bad post response (reward = 1 star)

Sorry- for some reason my mind made the above associationsvery-happy smiley

Hope I didn't press the lever twice.

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 4 of 4
(2,740 Views)