Jump to content

Random On LED, manual off, and time between


Recommended Posts

Hi all.

I am completely new to LabView, I have version 8.5. I am trying to desing a VI that will measure reaction times given a visual stimulus, so I though in big LED that will turn on randomly, like every 2-4 seconds, but random and then the user will turn it off with one button.

I have been playing with the random numbers, loops, LEDs, shift register, etc... and I have some pieces but can't get to what I want which is what I have stated above, so I will appreciate your help a lot.

The Idea is so simple, once the VI starts, a LED will turn on randomly between 2 to 4 seconds between each blink, but when it turns on, I want the user to turn it off by pressing a button, once the button is pressed the random timer (2 to 4 seconds) starts again until the LED turns on again and the user turns it off and like that continuously for a number of times, I think I can resolve the total number of times this will run, add time stamps from the time blinks to the button is pressed and measure time, add a start button and everything else, I am just stuck with this of the LED turning on and off.

Thanks in advance for your help.

Again: version 8.5, thanks.

Link to comment

This sounds like a job for a State Machine. It could be more easily accomplished with local variables and Sequence Structures, but I get hives when I use them.

This'll give you your 2-4 second wait. A better State Machine would have a mechanism to wait that doesn't freeze the program until the delay finishes, but you can do that later.

See if this helps and post back.

post-7534-125655458301_thumb.jpg

wait.vi

Link to comment

A better State Machine would have a mechanism to wait that doesn't freeze the program until the delay finishes, but you can do that later.

I think this is an important feature, because right now if I press OK before the light turns on, then when the light does turn on, it immediately thinks I pressed the OK button and will register a reaction time of 0ms.

A solution I think might be easier is replace the Time Delay, with a while loop that waits based on tick counts. Then in the while loop you can pole the OK button, and if it is pressed before the wait time is reached a dialog can pop up and say they were too early.

Link to comment

My first thought was an Event Case with a random timeout (2-4s) with an event for the button which will catch pre-mature clicks. After that, a second event case with the current tick count wired into it with, again, a case for the button, with no timeout which will calculate the reaction time. Wrap the whole thing in a while loop or just use run continuously. Adding a reaction time history is trivial, either way.

Link to comment

I agree with hooovahh because I actually need that feature, I will try to add it myself first after all this good thoughts you guys have shared with me and I do appreciate them.

Thanks for the VI jcarmody, with my short experience in labview this is gold for me, I think I wont figure it out by myself in weeks, maybe months.

I will review and modify to my needs and post back as soon as I can.

Thanks a lot, I really appreciate you guys thoughts and help.

Link to comment

I agree with hooovahh because I actually need that feature, I will try to add it myself first after all this good thoughts you guys have shared with me and I do appreciate them.

Thanks for the VI jcarmody, with my short experience in labview this is gold for me, I think I wont figure it out by myself in weeks, maybe months.

I will review and modify to my needs and post back as soon as I can.

Thanks a lot, I really appreciate you guys thoughts and help.

Just disable the "stop" button (not gray) and reactive-it when LED On

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.