10-15-2015 04:10 PM
Hi all
How do I i get a VI to stop running continuously ? It is running continuously even though i am not clicking on the "run continuously" button, just clicking on the run button
Thanks
10-15-2015 04:12 PM
Your VI will run until the code finishes. So without seeing your code, we can't help much...
Perhaps, do you have a never-ending While loop around your code?
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
10-15-2015 04:38 PM
Somewhere in your code (go look for it, or show it to us and we'll help you find it) you have a "Do Forever" loop. Note that "Forever" is an interesting concept -- I use unsigned integers as "tick counts", and tell my users that if they want to make a delay (all of my delays are in milliseconds, incidentally) "forever", they should specify a delay of -1. Well, 2^32-1 milliseconds is really just over 7 weeks, not really "forever" ...
Bob Schor
10-15-2015 04:42 PM - edited 10-15-2015 04:42 PM
Bob, do you ever have an application that would be required to wait "forever"? I've never had, or wanted, to wait 7 weeks for anything.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
10-15-2015 05:08 PM
Absolutely! We use this all the time!
Here's the scenario -- we are designing a Behavioral Experiment, with a lot of Bells and Whistles. We want the User (who knows nothing about LabVIEW, but everything about the Experiment) to be able to "program" the set of stimuli delivered.
An example would be Sound Localization. Suppose I could position a loud speaker in an arc in front of the subject (in the dark) and play a sound through it. Suppose also I had an LED on the speaker that I could flash, a movable Laser that I could position somewhere as another target, and a Laser Pointer that I could illuminate when the Subject was supposed to "point to where you think the sound is coming from". I also say "If you see a flashing light, but no sound, point to the light".
OK. The Experimenter is given an Excel Worksheet to fill out -- the Rows are the individual Experiment Trials for the Subject to perform, the Columns define what happens during a Trial. To help the Experimenter, I group "modalities" together. All Time parameters are given in milliseconds. Many of the Stimuli have a pair of parameters -- Delay (from Start of Stimulus Epoch) and Duration (once on). Consider the following cases for, say, Sound:
Delay = 0, Duration = 1000 1 second sound, starts immediately
Delay = 1000, Duration = 1000 1 second sound, starts after 1 second (i.e. one second off, one second on, then off)
Delay = -1, Duration = anything This is the "Wait Forever" case that effectively means "Don't use this stimulus"
Delay = 0, Duration = -1 This is the "Start and don't stop" (until you Press the Button that ends the Trial)
Delay = 0, Duration = 0 No sound (because a Duration of 0 is effectively "Stop Immediately" = "Never Start")
Now, in principle, I could have said "Put in a delay of a million if you want (for all practical purposes) to never start", but "reserving" the special values of -1 (forever) and 0 (never) are much more mnemonic for everyone.
I introduced this scheme after a complete overhaul of an existing code base written in LabVIEW 7 that had been in use for about 6 years. The students who were going to use the code were wildly enthusiastic about the new changes, and found it much more logical and easier to use -- my colleagues on the faculty who initially set out the specifications of the original code a decade ago were skeptical (but, as the students noted, "They'll Never Know the Difference ...").
Bob Schor
P.S. -- I do carefully explain that if they choose to keep the Subject in the room for 7 weeks waiting for the sound to occur, it will occur, but they usually use other "End of Trial" criteria to end really end the Trial earlier. Indeed, I have code that checks for "Forever" and, indeed, does not schedule a 7-week delay, so "Don't Even Think About It ...". So far, no one has been confused by this.
10-16-2015 09:14 AM
Ah, thanks for sharing!
I meant did you ever have an application that actually inputs a rediculously large 7-week value in to a Wait function. I use a -1 value all the time similarly to what you've described.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
10-16-2015 09:42 AM
Here is the link. Please open the Simulate Mouse clicks VI at the link below. That is the VI I am trying to run. Thanks for helping
http://digital.ni.com/public.nsf/allkb/9BB3211F3469623649257360000E272C
10-16-2015 09:50 AM - edited 10-16-2015 10:00 AM
@dks2710 wrote:
Here is the link. Please open the Simulate Mouse clicks VI at the link below. That is the VI I am trying to run. Thanks for helping
http://digital.ni.com/public.nsf/allkb/9BB3211F3469623649257360000E272C
Click on the "STOP" button and the VI stops...
If this doesn't make sense, then I think you have a misunderstanding of how LabVIEW (or maybe code in general) works. If there is a While loop in the code that is receiving a False boolean to the stop terminal, that while loop will continuously loop until that boolean is True. This means the code is still running. The VI itself isn't running "continuously", but the code inside the loop is.
"Give me six hours to chop down a tree and I will spend the first four sharpening the axe." - Abraham Lincoln
Here are some free training tools primarily focused on LabVIEW.
Learn NI Training Resource Videos
6 Hour LabVIEW Introduction
Self Paced training for students
Self Paced training beginner to advanced, SSP Required
LabVIEW Wiki on Training
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
10-16-2015 10:17 AM
@dks2710 wrote:
Here is the link. Please open the Simulate Mouse clicks VI at the link below. That is the VI I am trying to run. Thanks for helping
Well, this is quite a silly example, because it constantly fights you for control of the mouse cursor and you need to be fast to press the stop button before the code moves the mouse elsewhere again. If you would shorten the elapsed time, you would not be able to press the stop button. Very bad!
Even the oldest UI guideline discourage warping the mouse independently of user control, so this is not something you should typically do anyway. What are you trying to do? I recommend to find a better solution.
10-16-2015 10:18 AM
Thanks for the response. Yes I know clicking on Stop will stop it and I know how I while loop works 🙂 . But I only want the VI to click one time and release which is what the description on the page pictures the VI to do. I will have to look change the code