While loop within a while loop

Just a general question, is a timed, while that while loop the loop inside of a timed bad design practice?

Any feed back on why it shouldn't be done is appreciated.

mhaque

Yes, it's very bad design.

The outer timed loop cannot complete its iteration unless the timed inner loop ends. This means that its target of time cannot be carried out unless it is guaranteed to be much longer than the total time of the execution of the inner loop. Too late!

What are you actually trying to do with all this?

Tags: NI Software

Similar Questions

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

  • For loop within a while loop

    I have for loop within a while loop... admission to the for loop N comes from the VI selection... the while loop I a condition essentially statement it stops just after to finish all the iteration in loop...

    Entrance to the N loop is bascially driven by a local variable... that's the problem Iam having:

    When I press the Start button to run the program... regardless of the output of the select VI is gives the N of the for loop, then the loop starts and then ends in place... and when the output of the select statement takes a different value (the N of the loop for) loop not work until I restart the program again... What can I do so that the for loop runs again for another value of N, the RUN program button is enabled.

    1. clean your diagram.  Style guides suggest keep the pattern of a single screen.  With a little effort, I was able to get your DB less than 1600 x 1000 pixels.

    2 then I can see (some) it happens all at once. This thing does nothing?

    3. local variables can lead to race conditions.  Output in Angle position may be a race condition, although is probably not what you wanted to do.  What does the wired local time at the moment present terminal meter? (Ooops! Two controls with the same name - which can be quite confusing as well!)  If you need or want two components of façade having the same text, use the legends.  Make the labels is different so the comic is more readable.

    4. having more than one Dequeue function on the same queue will lead to unpredictable results.  When an item is removed, it is removed from the queue and is not accessible to any other Dequeue function.  In parallel loops, you have no way of guessing which Dequeue will seize any particular element.

    5 use Boolean reverse instead of Select with wired False to true and true cable at the entrance to false entry. Better, just make the case of forgery in the structure of the case within the for loop the real deal. No required reversal.

    6. I was not looking for to determine the logic of the code within the structure of this case. It seems I could have posted a much simpler way to do this several weeks ago.

    7. use multiply from the Digital Palette rather than a node form multiply by 4 or 1.8. Uses less space BD and is much easier to read.

    8. as has been suggested, learn how to work the machine architecture and the State of producer/consumer.  They can make your life much easier.  Do not try to convert immediately to these models.   It's too much bite to at some point.  Learn how they work first.  Make a few simple examples.  Then rewrite this program in this format.  Probably faster than fixing what you have now.

    Lynn

  • While the loop within a box Structure runs only once a target FPGA

    I have a card OR cRIO-9012 RIO for the HIL system. I have a target FPGA file when I use a While loop within a while loop I use the box Structure to check a real condition inside I have the function of activation of the ports and selecting the analog and digital ports. But for my code the code runs only once on repeted times that we have in the LabVIEW environment.

    I also need help to optimize the code. I've seen people using While loop timed in the FPGA target I don't use in both cases.

    I've attached my FPGA with the Version of LV2012 file.

    Waiting for your comments.

    Thank you and best regards,

    Ganesha Moorthy

    You have while loops inside the structure to deal with a constant of false cable to the stop condition. These loops will obviously never stop so browse your outside while loop (containing the case structure) can never.

    This has nothing to do with the FPGA target, the same thing will happen in the development environment.

  • While the loop does not stop within a structure of business

    Hi all

    I have a business structure that works an engine to a certain PWM when my metal detector does not give an amount greater than the threshold that is ' false '. The motor is controlled by a PI controller so a while loop is used inside the false state. When my metal detector exceeds the threshold I want the "true state" to perform but which does not occur. the entire program is a while loop which aims essentially to maintain the operation of the metal detector. How can I make the State of the switch works.

    Once you get the code is trapped inside the inside while loop, it will never be a Boolean wire change because change is outside. All you need is a loop that contains a structure of housing. Run your program with execution highlighting to get a better understanding of the flow of data.

  • 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

  • Is it possible to execute a loop For independently within a while loop in LabVIEW 2013?

    In my program, I want to run a loop For inside a while loop and run independently, at their own rate of execution.  A test, I wrote a simple VI with a while loop with 1 second calendar and in this I inserted a loop For with 3 of a second.  I created indicators for the two terminals of the iteration.  When executing the VI, I found the while loop waiting for loop For run N times before the while loop is executed again.  I also found that sometimes the first iteration of the loop For ends at 1 second instead of 3 seconds and the STOP button to complete execution of the While loop does not always work.

    This is the expected behavior. LabVIEW is the language of s DATA stream. If you want the curls to be independent, it can be data forcing addictive so use separate loops.

  • How to extract an element of a table 1 d product within a while loop

    Dear all,

    IM new to labview. I got the task to create the program for the route of some settings in my lab. I created a program to interface sourcemeter keithley 2636b that will help me source voltages in a range and get the current and the resistance and ground them. I used a simple while loop for this. My problem is the following. I need t extract the nth element of the array created for resistance after each measure and store it in an array. I need to make a resistance measurement several times one after another and save the nth element each time these individual tables and push it into a buffer so that I can trace elements in the buffer against a setting (this is called a measure TLM). I tried several methods. Some nice guy / gal had posted a solution using the loop to retrieve an item. Its doesn't work don't not in my program I need to use a loop in my time loop and it gives is not the correct value. Kindly advice. IM in a lot of pain. Help!

    And indexing does not work?

    Why don't you check out 2D paintings and the bays of clusters and try to make your 'readable' with that code?

    Also there are many resources available online:

    Introduction of 3 hours
    Introduction of 6 hours
    Bases LabVEW
    Paced self-study for students
    Self Paced Training beginner to advanced, required SSP
    LabVIEW training Wiki
    OR learning
    Getting started with products OR

  • Tutorial: how to stop a loop 'while' Subvi, which within the main program loop 'while '.

    Hi ppl,

    I searched through the forum on the topic above, but still don't know how to do this. Maybe one of you can post the solution of this important issue.

    I have attached a very simple program: I've done a few while loop as a main program and Subvi as a post-secondary program. Inside the Subvi also manages some while loop. All I want to do is to push the stop button in the main program that will stop the while loop in the second channel; to create a kind of judgment of reference in the main program which influence only the stop button on the Subvi. During this time the loop of the main program will still work.

    Thank you.

    I modified the code that you have joined. check.

  • Functions don't run when a loop running in a while loop

    Hi all

    I have a loop within a while loop. All main functions are running in this while loop. However, once the for loop executes other functions in the while loop don't work anymore until the loop for stop execution. Could someone help me with this problem? Thank you.

    Kind regards

    Nicky

    Hi Nicky,

    Ah, well I don't have much suggestions but maybe you can try with a conditional for the loop. I've attached an example. You can go through it. I don't know if it's a good idea to use this way, but again, if this can help, so I'm glad that.

    To create a condtional for loop, place a normal for loop on the block diagram, right-click and select terminal condtional.

    Kind regards

    Amine31

    (Give congratulations to good answers and Mark as a Solution If your problem is resolved)

  • problems of operation of two while loops in a VI

    Hi forum,

    I am developing a project for the acquisition of data continuously for two types of signals (voltage and temperature), each consisting of 20 channels. The sampling frequency is different so I used two call loops of different period to take account of the sampling frequency. It is within the VI that is deployed to the target device. On the host VI, I have two loops while put each containing a VI write_to_measurement express so I can connect the data to two different filepaths. However when I run the program, that a signal is registered correctly while the signal remains would have only one row of data. Looks like one of the while loop is only on the iteration while the other is running smoothly. This is an example of the famine of memory? How can I solve this problem! Any help greatly appreciated! Thank you!

    Vincent

    What asked Fan Ravens is why do you use static variable to stop the loop?  You do something remotely?  Simply use a local variable in your second while loop to stop him.  You need to change the action of the button stop, but that would be the way to do it.  Stop buttons are perfect for debugging and development, but generally I will use one other mechanism to stop the program runs outside the environment of LV.

  • Can not on the button while loop

    Hi all... hoping to get a few design tips as I am very, very new to LabVIEW. I got a project that someone else had started and I've encountered a problem that I don't know how to solve.

    I'm using LabVIEW version 8.0.1 and I think my problem has to do with the help of DAQmx in a while loop. In "Working.vi" (including the Sub - VI 'Temp data to CSV.vi'), I copied - and stuck the while loop in a vacuum VI for testing. In this VI, with nothing else, it works - slowly, but it works.

    In the real VI, I can see the data of temperature updated every 4 seconds, so I know that the program is not frozen or something like that. However, by pressing the button "Return to main Menu" does nothing - the image of the button does not show that it is to be depressed, regardless of how many times you click or click and hold the button. I've attached a screenshot of the while loop inside the real VI; I prefer not to fix the real VI (especially because it contains references to many of the Subvi, and it is not currently contained within a LAW degree).

    I'm this coding the wrong way? I have the feeling that it might be caused by my settings DAQmx (continuous samples, 2 samples to read, 250 mHz). The very low rate would be the cause? Is there a better way to have readings of temperature taken every 4 seconds (approximately)?

    You have your case of event the value "lock the front panel" until full?  If so, then no other presses the button will be recognized until the ongoing case event complete.

    It is never a good idea to have a code in an event business that takes a long time to run.  It will make your UI seems to lag or even functional.  Any time I see someone with a while loop inside a case of the event, I'm afraid.  (By the way, I am also concerned all nodes comments hovering over the structure of your event?  What are doing?  Why some operate on the default data?)

    In general, events should take is no longer running then what ordinary person could be expected until they feel like the user interface is delayed.  Perhaps at the top of 1-2 seconds.  You should look at a model of design of producer/consumer with events.  The structure of your event should respond to UI events, then pass orders by a queue path to the part of your program that does the real work.

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

  • Update an indicator of in while loop with event driven programs

    I'm trying to update a chart shared by several events within a Structure of the event. I would like a change in value of a button (NOPE or OK buttons in the attached example images) causes the structure of the event causes a switch between the various outputs for the chart. In the example attached, clicking the OK button will send the graph random matrices, while clicking on the button NOPE will send constant tables to the curve.

    As the process within the structure of the event is underway, I use a while loop within each of the different events in the event Structure. So there is a structure of the event, and each event have while loops in them which should update the chart outside the structure of the event (see attached images).

    This does not update the graph, the graph remains static instead, why is this? How can I configure it to work as I described above?

    In my view, a question is: How can I use the same stop button in both inside while loops. In the example images, I have two that are different, one for each of the different events.

    Thank you!


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

Maybe you are looking for

  • Transfer a game with purchased materials

    I have just bought a new iPad Pro and tried to transfer a game I played with its content of a previous iPad, but it will not download. It opens a new version since the beginning. Amy idea how to do this please? Sandra

  • Pavilion 500-210qe: line IDT HD CODEC in "Not connected", but it is

    In October 2015, I was able at the entrance to the CAR my amp output signal to record with Audacity.  Now, with the identical cables, etc., Line In reports not "connected". I have restored an image of system of October 2015 and observed that Line In

  • How to recover the old operating system?

    I was trying to upgrade Windows Vista to fix the boot failure and sadly reintalled Vista completely. I remember a line to appear as mentioned I was able to retrieve files from my old Vista (somehow looking 'old version' or something), but have not be

  • WAE-7371-K9

    Hello In our society, we used Cisco WAE-511-K9 as a web cache. I would like to ask if the model CISCO WAE-7371-K9 can also work as a web cache? Thanks in advance for your help. Kind regards Jakub

  • Launch Application APEX of EBS

    HelloI created an Application in the APEX and want to launch from ebs as a form or a page of the OAF is attached. Could someone let me know the steps for it.I need to create a new responsibility for him where it will be attached.I use ebs r12 and APE