counting while loop

I'm trying to stop a while using a countdown with the ability to stop using the stop button in the loop. However when the timer reaches 0 the vi does not stop.

Oh sorry didn't save it before you download. I used vi of the time to achieve this. Thank you guys

Tags: NI Software

Similar Questions

  • DLL slows parrellel while loop

    Hello

    I am changing a VI I wrote, to work with another piece of equipment. Communication tends to work directly through labVIEW. My new equipment provided with a driver/dll library and now I have many layers before reaching the material (LabVIEW-> driver-> software-> the measuring equipment). I have some time this account down to run alongside my Subvi who manages my method of measurement of the loop. As I put in place the screw that call DLLs that count - while loop slows down in the same frequency, I'm calling the dll. I've changed the "Run in the user interface thread" setting to the "Run in any thread" option in the call library function node. In fact, which got rid of my problem about 90%. But my meter still comes in a few seconds at the end. I wonder in what sense the crux of library function call delayed a seemingly parallel thread?

    Any suggestion on the place where to continue searching for a fix?

    Welcome them

    / Lorenz

    It is hard to tell what might work without knowing your DLL and what he actually did, but I see something in your loop that will force LabVIEW to toggle the user interface thread! The property node to update the text of the start_method th button will ALWAYS force a change of context for the UI thread. If you can avoid this really should not be possible for the DLL block your loop more. At least try to not update this property if it needs to be changed with regard to the previous value and not at each iteration of the loop.

    A guess is that the DLL actually interfaces to ActiveX code somehow. LabVIEW initializes its ActiveX environment to run in the UI thread, because it is the only safe thread system in LabVIEW to perform many threaded ActiveX components or when the data marshaling is involved. If your DLL tries also to connect to an ActiveX interface, it will be forced to go the UI thread that explains how to access the property in your loop can get delayed.

    And another problem you have is the moment of software. count you down the loop increments of 10 ms, but Windows will be hardpressured for hard real-time performance. While you are not using the "wait until the next ms Multiple" to take account of some jitter, if the loop is blocked for more than 10 ms through an external resource, you will actually jump an interval.

    Better would be to calculate the time elapsed directly reading the timer tick before entering the loop, then use the output of graduation of timer her to "wait until the next ms Multiple" to calculate the difference. Dividing this difference by 10, and then adding your counter value initial this result would give you the same value that you feed your VI calculation, but what about the real system clock, not a counter loop running asynchronously with questionable interval.

  • To count the number of while loops, you just attach a DBL indicator for the little that I framed in the while loop of the program?

    I followed just one example in a book as while loops and I want to just make sure that I haven't missed something simple. My program is attached

    Hi type'ssteel,

    I can't open your vi at the moment, but as you say, you can use the terminal i. For iterations, you must add 1 to it. I start with 0.

    Mike

  • How to use count imaq objects in a while loop?

    Hello, I am using objects IMAQ County and works well, but when I use a loop and I want to change the picture that I analyze to see results instantly, the search box, and the locations of the remains of the objects in the picture, even if I return to the original (for example at the threshold) values, objects of the location and the green rectangle remains there as the next image :

    This is the pattern I use:

    I used this same setup with the 3D IMAQ view and it works well, I change the values and changes in 3D view so do I.

    I use unduly the IMAQ dispose?

    Thank you very much for your help and comments.

    Bene

    The problem is due to the way works IMAQ Vision: the thread of the image contains a reference (handle), to the image, not the image itself. Means that once an image has been changed somewhere, the mods are propagated worldwide.

    The solution is simple: just add an IMAQ clear Overlay immediately upon entering the while loop (and add a small timer inside the loop).

    As an example, see the vi attached.

  • 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

  • for loop nested within a while loop

    I wrote a data logging VI to get data from a data acquisition, then write on a worksheet. It worked well. What I'm trying to do now and I am having problems is to place that vi within a while loop that will automatically write a new file name after the loop For ends its iterations. In a text based program when the loop finished I would just send it to the while loop for her write the new file name, and then run the loop data collection and spreadsheet iterations of writing.  Here is the general outline of the operations of the program.

    Set the file name and path based on iterations of the loop (eventually this will be the date and time)

    run to the loop for the specified iterations:

    read DAQ

    write data to a .csv spreadsheet

    In specified iterations are more:

    new name of file writley

    Rerun the loop for

    Repeat this until you press stop

    What actually happens is the file name and path are established, the loop runs through its iterations, but wrote that the last set of data and then the program stops.

    any ideas?  Program attached

    Don't know about the termination of the program. I replaced the methods with a random number generator and everything seemed good environment according to the writing of worksheet to add instead of create a new file each time that work.

    p.s., cleaned up the wiring to make it readable - counties of cleanliness.

  • I can constant maniuplate outdoors to separate while loops?

    What I want to do is subtract the constants incrementing in while loops 1 & 2. I removed the meat of the code, as it would get in the way of the question. Basically, a value is read (outside the structure of the case) each time, iI want to increment the "number of times read. The same thing happens in the second loop (they are basically independent of each other). I can't escape outside the while loop because the code never leaves the loop. I use a global variable? Thanks for any response.

    You will need to put in globals or functional globals to make your available outside your earrings acquisition counter values.

    You'll need a third loop at the same time to do the subtraction of values you have in your globals.

    You can also examine the help of queues and the authors of notifications.

    Another way to do would be to unstack a notifier received notifications whenever you receive a tag and then have a processing loop that manages the authors.

  • Measurement of time in a While loop

    Greetings gentleman;

    I'm kinda new to Labview, and although I sought an answer without assignment, I wasn't able to find one.

    So here my question, I would like to know how I can measure the time a loop sequence, in other words, what time is my point of view VI to run the main loop together?

    A little explanation, the attached VI tries to be a Markov chain, it takes some values in the first case structure based on the previus loop, then, if the values are correct, it passes to the next step and so on. It's pretty simple, and yet, my problem lies in the measurement of time. Since it is a 'distribution', it would take infinite time to execute a simple loop if it does not fulfill the characteristics, but it is scheduled to meet them so an average time should work.

    So, if you look to the while loop, should the big one, I want to measure how long I take for a ride.

    Thanks for the help, I'd be happy to read some ideas on how to measure this.

    Kind regards

    IRAN.

    You will find examples in the example Finder OR by searching for 'speed test' or ' reference '.

    Essentially, you create a flat sequence structure inside of your loop. In the first image, you measure the current number of cycles. In the middle frame, you run your code. In the last image, you measure the number of cycles again and subtract the first number of this. This gives you the run time to execute the code.

    You can see a page of the community about it here.

    There is a high-resolution time tick count VI hang out somewhere which is great for benchmarking and improving efficiency, used instead the number of cycles (ms) primitive.

    Edit - remember where he was

    https://decibel.NI.com/content/blogs/EvanP/2010/10/04/tick-count-us--microsecond-timing-granularity-...

  • Stop and start the task in while loop

    I try to start and stop an output meter (creates pulsed output) in a while loop and I don't know how this is possible. I have a while loop running who is taking measures from a digital compass. If my title is within acceptable limits, the outputs of the meter (2 of them to turn to the left and right) must be turned off. If the title is out of the acceptable range, let say too far to the right, I want to start one of my outings of the counter to activate the object to the left. The issue I am having is that if I put the block 'Start the task' in the while loop the system will try to start each iteration of the loop, even if it is already on. I don't know if there is a problem, but it does not appear effective from a programming perspective. I remember reading somewhere that stop and start tasks can really slow a loop. Any suggestions?

    I actually just to understand it. If you use some if statements and the "fact of task is" block you can make it work.

  • while loop: delay enforcement and continuous updated: VI back to fake out of time?

    Hi all

    I want to control the time of execution of a while loop. I want the user to have the ability to decide how long he wants to run the while loop. The while loop is used to update certain values, then it should run continuously, not only run once and wait (that I could easily using the synchronization functions).

    I used the time up VI as suggested in this post:

    http://forums.NI.com/T5/LabVIEW/how-to-create-a-time-control-for-while-loop/m-p/2530212/highlight/FA...

    and works well, but the while loops are integrated into another loop for and when Goes to the next iteration, the elapsed time Boolean result is set to true and it does not run at all (I think that's the problem).

    Can I return the Boolean result of the elapsed time VI to false, after reaching the target of time? That would solve my problem, I think that...

    I attach some of my VI, although I don't know that it could be useful for you...

    Thanks for your help

    Use the iteration for while loops count and an equal to zero? node.  Then the output of the comparison at the entrance to reset the elapsed time functions.  The idea is that reset you on the first iteration (when I = 0).

  • Two questions in table "While loop"

    Hello

    I have two questions about creating tables in while loops. I'm using LabView 8.5.1.

    In its simplest form, my current while loop (delay set to 0, 2 s) has 3 variables that have been changed by moving a slider. They are each sent to a line in a block of 'Building the table' (data type is DBL 1 d) - this table is then written to a spreadsheet file, such as the three values are written to a new line (one value per column) whenever the while loop runs.

    Question 1

    How can I add a column 'Time' in this worksheet? In other words, get at the present time the loop works since then, from 0 seconds in the spreadsheet, via the table block building.

    I can think of how to do this with a loop For, but given that the While loop runs through an unknown number of iterations, I can't figure out how to get the counter to work.

    Question 2

    How can I text column headings on the worksheet?

    Thanks for the help and if you need anything anyone stating, please let me know

    To answer question 1:

    There is a function of 'Elapsed Time' you can put as the first colum of the data.

    This then reformatted your spreadsheet as
    Time Data1 Data2 Data3

    Time Data1 Data2 Data3

    Time Data1 Data2 Data3

    etc...

    To answer question 2:

    Build a table of positions, then write this table in the file only once, outside the loop.

    Your table with the data and time will write inside the loop.

  • While/loop and reset the value i in time loop

    Hello!

    I have a question about the use of while/loop for.

    I read the data of 5 devices.

    Starting with the 0 position when I = 0, I read the data at position 0.

    And when I click on NextPosition, then I = 1 and stop when I = 5.

    But in the meantime, if I want to break the system of position 3 for now. I click on the BREAK.

    I chose the position back to 0, it will go to this post.

    But if I click on NextPosition, the value is always my 0 and not 1, which is the next position upward.

    In addition, whenever I click NextPosition, it will count up to i = 5 and to stop the program.

    Is there a way I can address the issue?

    Thanks for trying!

    I don't know what your needs are, so I guess you want to keep hitting the same device until you press the button of the next device and you want to be able to specify that one then.

    In the attached code, I changed your mechanical action of the pause button and renamed position Reset.

    I also changed the code suchthat conditionally, we increment the device number (only when the next button is hit).

    I have alos moved local so that us do not draft times and put it in the case of the rest the structure so it is written or read but not both.

    If this does not meet your needs;

    1) look in bulb mode and see where I went wrong

    (2) If you are unable to set up a truth table of all combinations buttn and doc what steps should occur for each condition.

    Always trying to help,

    Ben

  • 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.

  • How to end parallel while loops

    Hi, I'm using LV8.5.  I have 2 while loops, running in parallel.  Loop1 is faster (waiting time of 100 ms) and Loop2 is slower (several minutes waiting time).  I use a local variable (STOP button) Boolean to commonality between the loops.  The button is in the loop faster (Loop1) and the local variable is in Loop2.  When I try to end the While loop, Loop1 stops immediately, while I have to wait for Loop2 finish.  Is there a simple way to make two loops to stop immediately?  I have been using a Control\Stop Application, but may not be the right solution.

    Thank you.

    Hi shanx2,

    reduce waiting time in your second loop and count the iterations instead. The loop will do the same, but the stop will react much faster. Another possibility would be to use a queue instead. Connect to a timeout that corresponds to the current time-out period, you use and send a message to stop the loop. You can choose between the queue has been exceeded or not. Connect this result to the conditional loop. You can send the message from the queue after the first loop was arrested.

    Mike

  • Code Golf: stop two while loops with guaranteed ratio iteration

    Proposal

    In the vein of the tradition of Perl, I would like to see if there is any interest to solve a few puzzles programming in LabVIEW. Can someone post a problem and define the rules to solve.

    Here's a question for beginning/intermediate to sharpen your "palette".

    Description

    With a user action, how you would stop two while loops such as the relationship between iterations is the still the same? Concrete to view this situation is to take action: both instruments use the same source of synchronization to take measures, but second divides the clock down so that it is a little slower than the first whole factor. For example, if the slower instrument is four times slower, then at the end of the VI, the slower instrument takes 100 measures the fastest instrument took 400.

    Rules

    • You can use vi.lib
    • You cannot include any other subVIs
    • Your solution should pass for loop1 interval as low as 25 ms

    Model (joint in LabVIEW 2009)

     

    If people are interested in this, then we will find a way to improve future problems. Please post your suggestions and criticisms, but only if you also post a presentation ;-)

    MacNorth wrote:

    [..]

    If we choose the first suggestions, the VI has yet to recover the data at different speeds. You can dedicate a loop for each instrument to disassociate a jitter and latency introduced by their connectivity or the inner workings. This adds a margin of safety when there is a conflict of thread and the pilot. You can also implement a simple counting as altenbach loop and renounce the multiloop complexity.
    [..]

    It is a very good point. But I wanted to make sure, you should / need to discuss the benefits, but also the disadvantages of the design. Implementation of an application is most often a process of 'special cases '. If a framework/design for a single application model does not necessarily correspond to another application.

    Designs are always strongly according to the requirements and constraints. What gives here designs will result in educational services, of course, but not necessarily as reference models for specific applications.

    Advantage of simple loop:

    • No synchronization between several loops required
    • Can easily implement any whole factor between services (quotent & function remains for a case structure

    Disadvantage of simple loop:

    • Take advantage of the multi core systems (at least not much)
    • Can easily run out of the time constraints (material not "not responding" enough, fast manipulation of data takes too long,...)
    • Code will accumulate within the structures of the case, where the readability could suff

    The advantage of multiple loops:

    • See essentially the disadvantages of single loop (several loops solve those)

    Disadvantage of multiple loops:

    • More complex, especially for the sync switch (not beginner friendly, requires a more/better design)
    • May contain easily questions source such as race conditions and locks

    A little side note:

    Even if the equipment works different acquisition rate, this does not necessarily that the software must use different rates for data extraction. You can use the same model of an hour, but get X times more values for the task faster than the slower running. The 'only' thing to care of are the sizes of buffers and bottlenecks in the data transfer.

    MacNorth wrote:

    [..] The best advice published OR shutter multiple while loops (https://www.google.com/search?q=labview+stop+multiple+while+loops) are laughable (and the 'solution' in my model). [..]

    No, it's not laughable. For many applications, this approach to shutter at the same time several loops running is OK. The constraint: only for simple parallel running loops.

    More complex loops (producer/consumer and similar) with the more complex data relationship ships require more valiant approaches such as queues, declaring events or user.

    My 5 cents only,

    Norbert

Maybe you are looking for