Force the While loop to exit when the delay is running

Hello guys,.

I have a While loop containing some jobs. One of them is delay for 10 seconds. When I push the stop button, the loop does not stop immediately. Instead, it stops after a few seconds (can be, pending other jobs is done).

What can I do if I want to stop the loop immediately after I press the stop button?

Thank you for sharing...

Hello Yoppy,

I don't know if I understand your problem completely, but here's the method I use to stop the while loop immediately (some ms delay will be there for you).

I would like to know if the attachment helps.

There are several ways to do it and you can get better solutions than this one on this community.

Tags: NI Software

Similar Questions

  • force stop while loop

    Hello

    I'm writing a VI that make a transaction within a while loop. I replaced the operation with a simple mathematical operation in the attached photo of the VI. For loop in the picture, I just want to add 1 every 15 secs until it reaches 10 and stops. However, I also want to be able to force the while loop to stop immediately all 15 sec until the next iteration. Is there a way out of the waiting time for the while loop? Thanks for the help!

    Altenbach says:

    Use the event with a timeount 15000ms structure and an event for the stop button. Urgent stop immediately interrupts the time-out.

    Here's what I had in mind (LV 8.5).

  • How to force the msi to run under one account other than system deployment msi via gpo?

    Hello fellows,

    I'm deploying a bundled program msi via gpo. by default, msi is run with the system account on the client computers. but the program must be installed with a local administrator domain/admin account in order to work properly. I didn't find a way to assign this account to msi via gpo. can anyone share some experiences? In my view, that it is an unusual scenario.

    see you soon

    This issue is beyond the scope of this site (for consumers) and to be sure, you get the best (and fastest) reply, we have to ask either on Technet (for IT Pro) or MSDN (for developers)
    *
  • stop the loop inside while loop

    Hi all

    Is there a way to stop a loop within a while loop? Error-free program will stop running when you press the stop button, but I want to while loop continues to run in and only for the loop stops when the condition is met.

    Thank you!

    Hi TayAus 1.

    If you want to run the execution once? Maybe something like below? The code inside the structure of events can only run when the event source is triggered. For example, the code in the digital works only when it detects a change in the numerical value (just an example).

    When the button is selected, it should raise the event to stop as shown below:

    If you want to create the event source, create the structure of the event > right-click on the frame and select edit events dealing with this... > This should open Edit events.

    The example below is that I put the event source for the change in the value of x and x 2.

    So when x or x 2 value is changed, executes the code in the sous-schema event shown below.

    Warm greetings,

    Lennard.C

  • Any way to force the execution of the workflow on existing data?

    I wrote a workflow rule to update the field back to match the sum of a few custom customer field. When the record is updated or a new record is created income is updated with the desired value. However, I have a few thousands opportunities that already exist. Is there a way to force the workflow to run on any existing data? If not, is the only option for export and re - import all data used?

    Using the mass update is another choice, but to 50 cases per race that is rather painful. The route of export/import is much less clicks. Just empty the opportunity name and filed a trivial you don't use. Change the trivial field in Excel. Recharge with update.

    The f

  • While loop with reading of text file - calendar of events in a given period

    Hello world.

    I created a program that if serial interface via a port to a syringe push in my lab. Currently, the program reads in a text file-flow rate values and sends them to the pump, one by one, through various commands. I need to ensure that whenever a new flow rate value is sent to the pump, it does in a specific/hard time for a while. I.e. every 0.1 seconds, changes in flow rate and must are active until the next period. I tried to use a timed loop and I think I've succeeded, but it hogs system resources, so I was wondering if there was a way to do it using the number of cycles or something of this nature. I just started using LabView, so I'm slowly getting the hang of it (easy when you watch my VI!)

    See attached VI. I took orders from serial port and have instead orders display in an indicator. The nested and densely populated while loop contains the commands that need to be completed/last during the period (like 0.1 second).

    Thank you for your time and help!

    -Phebotalus

    Hi, you should read some introductory material on LabVIEW to down the idea of the stream.

    Basically, the data flow in the wires from left to right, and any node will not work until it has reached all of his contributions.

    The thread of the error is the best way to run data streams.

    ***

    In your VI I use data wires, their execution through structures, and forcing the structures to run in the sequence.  Using a structure of sequence you mentioned in your next post will force the two scripts to execute in the order of (the only one we discussed to be in race condition.)

    Similarly, for brevity, I would wrap the EMO and she is business structure in a single sequence and force it to run last using stream.  In this way the user has the most possible time to decide to hit the EMO before she is called by the application.  As it is now, it most likely is interviewed at the beginning of the loop, so if it's the exchange value you won't see results until the next loop.

    When running in execution of highlight you see the order of data flow, but that is not guaranteed to be the same for a normal performance, where the use of the data stream.

    ***

    The counter tick account ms up to a very large number and then "says" reset and start counting again.  I know you want to START the loop as close to every 10 ms.  Yes, using data flow, take the number of cycles first, perform actions, then return the number of cycles.   The second time of the tick read that you are in a nested loop that does not stop until you get 10 or more difference on the number of cycles.

    And, on the off chance that you must achieve "return" on the tick counter comes stops the nested loop then move.  (if the second measurement is less than the first, then the tick counter handed.  If you miss this situation while you'd have to wait a long time for the condition of the difference > 10 in the reunion, basically locked in the loop.

    ***

    You could put the EMO sequence, we have seen, in line with data streams.  Before or after the second control of ticks will not make much difference in terms of 10ms.  I would put it after checking the tick, again give the user more time to hit the EMO if necessary.

    ***

    I put in a queue for the stream error and removed the other stuff.

    LV2010

    Check out some of the LabVIEW intro docs, they are online, they discuss these issues and much more.

  • Timeout on while loop

    Hello

    I need to insert a time-out on a while loop to exit this loop in the case of the device is not able to answer.

    How can I do?

    Best regards

    Create a local Variable:

    Locals.StartTime

    In a stage of expression before the while loop set Locals.StartTime = Seconds()

    As part of the condition of the loop While use: (Seconds() - Locals.StartTime)<>

    where X is your timeout in seconds.

    Hope this helps,

  • Need help with while loop and shift registers

    I have a broad set of data and required to read data at maybe 200 samples at a time to process these samples through my VI and have add and concatenate a file separate lvm.  The part where I am confused is the shift registers. How can I limit the number of samples read in an iteration? How do the while loop to stop when all data are read in?

    I have attached my diagram, there may be something wrong with my technique?

    This will give you an idea.  There are a lot of other (probably more effective) methods.  It is a basic solution, quick and dirty to help you grasp the overall concept.

  • When boolean is set to skip a step in the while loop

    Hey guys,.

    I have a program that controls a fan that pumps gas at a certain speed. This entire process is run in a while loop. When we move from the gas by a gimbal which is located on the front, we immediately jump in a cycle of breakdown and then goes back to the pumping of the gas at the rate previous, but we do not know how to achieve this. Can you guys give advice? Thank you!

    Sincerely,

    The Z.

    Hello,

    A shift in your loop register may be able to achieve this type of functionality. If wire you the switch in the shift register to the right and register in the structure in case of wire left shift, the loop must travel once more before moving on to the HP gas. Here is a link to a tutorial on shift registers:

    http://www.NI.com/gettingstarted/labviewbasics/shiftregisters.htm#shift records

    -Erik S

  • In the attached VI why looping force the type of data while the other does not?

    In the attached VI why looping force the type of data while the other does not?

    I'm guessing that you have created the Enum on the front panel.  If you right click and create an indicator, it corresponds to the type and be an enum.  LabVIEW represents enums as U16, but because the types are not the same (for example, your enum has 3 values, but a U16's 65 536 values), LabVIEW automatically converts value (or converts) the smallest representation (enum) in the largest value (U16).

  • URGENT::opening multiple files - i have 3 files in my directory... When I run the code I can open a file and read it... but the while loop get blocked after the first iteration... can someone me help or give some indications

    bbmChatDB of public database;

    public static FileConnection fconnRead = null;
    public static String fileReadData = "";
    public static InputStream is = null;
    data Byte [] = null;
    DataInputStream is = null;

    Here is my code...

    I have 3 files in my directory... When I run the code I can open a file and read it... but the while loop get blocked after the first iteration... can someone me help or give some indications

    try {}

    FileConnection fc = Connector.open("file:///store/home/user/documents/BSM/") (FileConnection); "

    If (fc.exists ()) {}

    Enumeration e = fc.list ();

    While (e.hasMoreElements ()) {}

    System.out.println ("files are:" + (String) e.nextElement ());

    play this file
    StringBuffer stringBuff = new StringBuffer();
    try {}
    System.out.println ("opening file")-;
    System.out.println ("file name is:" + (String) e.nextElement ());
    fconnRead = Connector.open("file:///store/home/user/documents/BSM/(String)e.nextElement(),Connector.READ_WRITE) (FileConnection);
    System.out.println ("data length")-;
    If (fconnRead.exists ()) {}
    is = fconnRead.openDataInputStream ();
    data = IOUtilities.streamToBytes (is);
    Ddd = new String string (data);
    fileReadData = ddd.toString ();
    System.out.println ("length of data:" + fileReadData.length ());
    System.out.println ("read data :" + fileReadData);

    }

    } catch (IOException ee) {}
    ee.printStackTrace ();
    System.out.println ("Exception in the read data :")
    + ee.getMessage ());
    }

    }
    }

    } catch (IOException e) {}

    e.printStackTrace ();
    }

    {Finally

    try {}
    If (is! = null) {}
    is. Close();
    }
    System.out.println ("is closed...");
    } catch (IOException e1) {}

    E1. PrintStackTrace();
    }

    If (fconnRead! = null) {}
    try {}
    fconnRead.close ();
    } catch (Exception e) {}
    System.out.println (try ());
    }

    }

    }

    You can recode this treatment so that it uses only:

    e.nextElement ())

    Once a loop iteration.

    Directly at the start saying something like:

    String fileName = e.nextElement ());

    and use fileName everywhere in your loop.

    Also be aware that printStackTrace() will do nothing in your situation, it only works if you catch Throwable.  So make sure you something output all your catches exception and also have a catch (Throwable t) to catch the things you miss, as follows:

    {} catch (Throwable t)

    t.printStackTrace ();

    System.out.println ("Eception exception:" + t.toString ());

    }

    I think your code is thrown an exception and you don't see it.

  • Control of the event: how to stop the race while loop within a structure of the event

    Hello

    I have some problems with control of a while loop inside a structure of the event (see annex VI).

    I have 3 buttons (the "Start measurement, stop, exit the program"). When a measure is running, it should be possible to stop the measure by clicking on "Stop the measure", but it does not work.

    Someone at - it an idea?

    Thank you very much and best regards,

    Michael

    Hi Michael,

    create a process parallel to your measurement. You can use the design model "producer/consumer with vents. You'll find it with «File-> new...» ».

    Another possibility would be to remove the "lock frontpanel" sign, in the case of event start measurement.

    Mike

  • Structure of the event inside while loop

    I'm still fairly new to Labview and this may seem a simple question.  I'm doing a Subvi to display, edit, and create configuration files.  I use a ListBox to list all sections of a config file and structure of the event to update the values in each section, when they are clicked.  The problem is that the structure of the event seems to be a break the while loop so that the buttons do not work until the event has executed.  What I would like is the while loop to run continuously and the event to run only when I click in the listbox control.  I hope this makes sense.  There is a peak in the diagram below. Thank you

    There are a number of issues with your code that could cause problems:

    1. You must use the FP. Open method to open the front panel of a VI and of the public Service. Close method to close. I don't remember exactly the problem, but starting with the 7 worm nor indicated that these methods were the preferred way to perform these tasks.
    2. Based on what seems to be the code, the event for the control of Presets of wood should be a change the value - not a mouse down event. After changing the type of event, use the event data NewVal to drive the indexer table index entry.
    3. The buttons Ok and cancel them should be handled in their own events to change the value. The value change event Cancel would exit the loop, while passing the output error (which indicates that cancel was pressed) and default values for the other 4 outputs. The change of the value Ok event would leave the loop by passing the values that the operator had concluded the 4 controls on the front panel.
    4. An event of timeout with a very short time (1 msec) would stop loop if an error has occurred, or the output of the gate AND is set to true.
    5. The wait function is not necessary, as is the case outside the loop structure.

    Mike...

  • run a while loop in separate vi, minimize the window flashing

    My apologies in advance for not including a VI; I cannot give it, cannot even provide screenshots.

    I have a state machine base with a cluster of Boolean values that are analyzed in the 'default' State, the scan index = true determining the next State. All other States to return to the default state. The State of 'stop' stop the loop with a Boolean constant = True, located inside the structure case wired to the time entry conditional loop (all States have a Boolean constant False wired to it). Apart from the cases

    statement, the wire connected to the conditional entry is connected to a Boolean indicator, ' Stop, in really. The time delay within the State of the machine while loop is currently set at 100 ms.

    In addition to the 'State' shift register, the state machine has a "boolean" shift register. All States, except one, feeds the value passed the Boolean value through to the next State (i.e. wired directly from left to right the structure of the case). The exception is the State which inverts the Boolean value, with the output of the inverter transferred to the State following and also connected to a Boolean flag, 'Show the State', the

    indicator outside the case statement but inside the while loop. All other States wire just the previous state of the Boolean value through the following State, unchanged.

    In addition to the State of the machine while loop, I have a parallel while loop (scourge of the LV forums). All entered conditional loop is connected to a local variable to 'stop, really. " A True/False case in this while loop structure contains a Subvi in the case of True value. The Boolean value of entry to the case statement is connected to a local variable for 'Show status'. The Subvi, which is in the real case is to display the State of the

    user.

    The Subvi which provides status through its frontage runs a script in python via a 'comand prompt"vi. The necessary update to the python command send is ~ 1/second. Within the Sub - VI is a 1 second delay time after execution of the code.

    It works but I'm doing some improvements with minimal impact on what I have.

    Two cases of VI properties that relate to the conduct of the State Subvi (floating or default, modal does not at all):

    1. with "Firm when previously closed" selected, the window switches VI (via the main switch VI) open and closed but when it is open there is the a second window flash that could cause seizures in some users.

    2. with "closes when previously closed" deselected, the window remains open and it is difficult to tell the difference between the running state and is not running. In addition, the Subvi window will not be reduced for this option.

    Is there a little invasive change, I have the code in force to stop a second flash described in #1 above and activate / deactivate the Subvi status window?

    Thank you

    Jeff


  • What is READ the array returned by the DAQmx meter? How can I know the two functions DAQmx READ data stream in the same WHILE loop?

    I have a question about the order of execution.  In the WHILE loop, I have two things to measure, period and tension using the DAQmx READ functions for voltage and the meter.  In the end, I want to collect these data as points almost simultaneously as possible, as a pair and then send them together to another piece of code (not shown here) which them will result in some sort of command for an engine.  It would be run, and then I want to perceive the tension and the period at a time later and do the same thing.

    (1.) I'm a little confused on what the meter of the READ function is back because it's a table.  What is a picture of?  I thought that it was up to the value of the individual periods between rising edges.  The output of the counter 1 DBL d's a table. How many elements in this table, and what determines the size of this table?  Are the elements of the array the individual delays between the edges?  How many values are stored in the array by executing?   We take the AVERAGE of the last 15 items, but do not know if we are throwing some of the data or what.  How to understand the composition of this painting?  How can I change the composition of this painting?  Is it possible to measure only one period at a time, for example the time between TWO edges?

    2.) Will this WHILE loop execute as it gathers tension and a "period table ' (remains to be understood by me) by TIME running in a loop?  In particular, we want that the value of the tension associated with the value of the AVERAGE of the period "array", so we can use two data items to create orders of next control every time that the two values are reported.  The structure for the delivery of vi will be attached data in pairs like this?  I understand that one of the READING functions run not before the other function of READING in the WHILE loop.  I want that the period "means" and "strain (Volt) collected at the same pace. This vi will he?

    Thank you

    Dave

    Hi David,

    I suggest including the DAQmx Start Task function. If it does not start before the loop, it starts the loop and work very well, but it is not as fast and efficient. In the model of task status, task wiill go to run the checked each iteration of the loop and then back the time checked running when it restarts.

    The status of the task model: http://zone.ni.com/reference/en-XX/help/370466V-01/mxcncpts/taskstatemodel/

    Kind regards

    Jason D

    Technical sales engineer

    National Instruments

Maybe you are looking for