While loops and event structures

Is there a problem using more then one While loop with an internal structure of the event, in a single VI?

In my (only a partially attached printscreen) VI there is more then 2 all in curls with a structure internal even who controls a different devices.

Event structures are being controlled by a box structure.

From time to time the VI gets stuck and resetting local variables.

Hello

Using two while the loop is not a problem, it depends on how you structure the code.

Generally, we use two while loop for Producure-consumer, master - slave structure type of applications. Try to use the structure of State machine inside while loops, see standard state machine examples in the palette of NOR find example.

Tags: NI Software

Similar Questions

  • How to control a VI (with a while loop and a structure of the event) from an another VI

    Hello

    I have the main VI which I want to be driven from an another VI. But I can't do that and I don't know what is happening.

    For example: VI main, I have a while loop with a structure of the event, there is a Boolean controller controlling a Boolean LED, which is inside the structure of the event. And the other VI, there is just a Boolean controller and functions of applications to open the main VI.

    How can I control the Boolean LED in VI main, changing the State of the Boolean controller in an another VI?

    Thank you.

    There are different options, but depending on what you want to do. For this example I can't give you a specific solution.

    I do not understand why you do what you do. Why do you call your 'principle VI' dynamically? What is the advantage to do? There are also other ways to call a VI dynamically, based on real cases (for example the method "call and forget", etc...).

    In you principle VI, control you Boolean ("THATCHER") is not the case of corresponding event. This is not usually a good practice, keep it inside.

    Also, why you try to communicate with the caller and callee VI through such a way to twist? There are better ways to do it.

    In one of my projects, I use the user event to launch orders in case of case of appellant VI.

    some Associates more readings for you:

    http://www.notatamelion.com/2015/03/23/how-to-make-dynamic-subvis/

    http://forums.NI.com/T5/LabVIEW/Dr-Damien-s-development-event-structures-III-communicating-with/m-p/...

  • 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

  • How to stop the While loop in the Structure of the event with the same button?

    Hello

    I have a problem. I want to use a single control to activate an event in a structure of the event and the same control to end a while loop in this case.

    It is possible to use 2 controls to do this, but I need to be alone.

    Thank you

    You should NEVER place while loops inside the case of the event, and it is never necessary to do. Think about it: all you have to do is spin the code. You can easily use the outside while loop for everything. Simply place the code of the loop internal (without the inner loop) inside the case of delay and manipulate the time-out period between a pending finished and the infinite (-1), depending on the State of the Boolean value.

    A very simple example (LV 8.0)

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


  • How to have a while loop inside a structure of matter?

    Hi all

    I would like to know how to control a while loop by using the structure of the case? I would like the person to check if the object has is in its original position or not.

    If this is the case, go...

    The object must then do its job, as mentioned in the while loop... as up and down 10blocks...

    Later, when she returns to its original position, the entire process must stop...

    I checked the forums on this http://forums.ni.com/t5/LabVIEW/How-to-stop-while-loops-inside-a-case-structure/m-p/591259

    It is the closest, I can have... but can someone tell me how to program for this? How logic should be?


  • Two loops of event Structure: hang

    Hello

    I have a wired problem when I try to use two loops with two event structures (see VI below).

    The problem is that you can stop the measurement and close the VI with X but not to stop it only with STOP button: this would lock the façade.

    Here my (rather long and perhaps not quite understandable) description of VI:

    A structure must respond on the user interface and the other a certain action. The first uses only user events: change value button START, PANEL NARROW? and the value enum STATE changes. The second event structure uses those registered dynamically: start the event user & user close event. Action when the STATE changes from button should always be done. When you press start the startup user event disables the START button and activates a loop in the second structure that should make continuous measurement. Now, we can always change the STATUS button and information (this works). The measurement loop should stop if the STOP button is true. Later START is enabled again and we should be able to press START again. It does not work as the front panel is locked. Curiously the last implemented user action works very well: by pressing X of VI, the PANEL CLOSE? is called in the first loop and should stop the two loops: If the measurement loop is running, STOP is True first, stop the loop measurement. Then a secondary structure event waits until the JUDGMENT is again set to False. If the measure is not in the process of running the first loop stops. In both cases, the event close user is sent to the second loop, successfully stop.

    I'm really confused, because I have no idea what is wrong. I would greatly appreciate any help on this.

    Best regards

    Daniel

    Thank you very much! This solves the problem. I did not understand that structures of events queued events even if they are not "active".

    (Finally there is even no need one notifier, you can just change the value of the real STOP button and will raise the event close user, comapare attached, work VI)

    Thanks again,

    Daniel

  • 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

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

  • Change the values of the cluster in while loop and in the face at the same time

    Hello.

    I have a little problem in a test program, that I'm working on. I'll try to simplify as much as possible. I have a cluster control that contains two controls A and B. I want to:

    1. switch to update the value of the command A a while loop
    2. allow the user to change the value of the B control through the face, while the loop is running

    To change the value of order in the while loop, I first get the cluster control cluster, update the value of the control for a way to group by name and finally rewrite the cluster in the cluster control.

    The problem is that if the user changes the value of the B control while control that is in the middle of the update, the new value of B control is lost because it was read before updating in the face. Is there a way to get around this?

    DennisBengs wrote:

    1. switch to update the value of the command A a while loop
    2. allow the user to change the value of the B control through the face, while the loop is running

    Then they do not belong in the same cluster.  They are disconnected obviously enough that they do not go hand in hand.

    Where it can get really complicated, it is that you're talking about the user and code changing the same cluster.  It is very dangerous and very difficult to manage.  You might be able to get there with a driving force.  But walk slightly, my friend.

  • While loop and table

    I'm weak and I can't get up.
    I'm playing a series of clips in order, so movieClip2 does not play until the end of movieClip1 (label = 'end'). I started with a three separate movieClips, each with its own listening port. Because all three looked like, I thought me save time by using a table and while loops. I have a dozen of these total movieClips, then rather than cut and paste each individual listener and if statement, it seems that there is a better way. And you smart people are the people who know. The output I am receving is: TypeError: Error #1006: value is not a function.

    Thanks in advance for any direction.

    I tried to use another method successfully. In my previous attempt, I used too many while and loops enterFrame, which caused problems of circular logic. Using only a few statements seem to solve the problem, as below. Thank you all for taking a glance at the problem.

  • Control 2 while loop and a queue

    Hello Mr President

    I need handel while loopps as they run in order. I can use the structure of sequence, but the question is in my program, I also have one already queued. Please help me how I can handel this question

    Thank you

    You certainly want a State Machine. You can't do what you want using a sequence structure, as you said. If you need an architecture that can operate several different cases in a certain order, but also to repeat the States if necessary.

    The Computer of State Simple model that comes with LabVIEW is really the best way for new developers to become familiar with LabVIEW using a semi scalable architecture.

    Here is a large example of the works of a state machine:

    • States: Init, slowed down, exit, DoThing1, DoThing2, DoThing3
    • Each State contains code that could take some time. Ideally, not too long because this is how long your code might not meet.
    • The idle state contains a structure of event for all of the user interactions.
    • The front panel has a button that says "do the 1 thing.
    1. Loop iteration 0: Application starts, the first State is Init. Init State made the initialization stuff and tells the application to go to the idle state when finished.
    2. Iteration of the loop 1: request goes to the idle state. He's sitting there, waiting for the structure of the event.
    3. Time passes, and then the user presses the button 'do 1 thing ". There is no code or minimal code, within the occurrence of the event. The output of this state of the event tells the application to go to the State of DoThing1.
    4. Iteration of the loop 3: Application passes to the State of DoThing1. Here, there is code that does a few things. The output of DoThing1 State tells the application to return to the idle state.
    5. Iteration of the loop 4: Application goes to a State of rest where he waits again to the structure of the event.
    • Each State can tell the application to go to any State they want. You want to reset? Return to the Init State. You want to put an end to the program? Go to the exit State. You want each State to start another (such as a sequence)? Have DoThing1 out of DoThing2, which DoThing3, which outputs Idle.
  • Why the execution time increases with a while loop, but not with "run continuously?

    Hi all

    I have a problem of severe weather that I don't know how to fix it because I don't know exactly where it comes from.

    I order two RF switches via a data acquisition card (NI USB-6008). One job at the same time can be selected on each switch. Basically, the VI created for this feature (by a colleague) resets all the outputs of acquisition data and active then those desired. It has three entrances, two chain simp0le controls and a cluster table, that contains the list of all the outputs and some practical information to know what is connected (specific to my application).

    I use this VI in a complex application, and I have some problems with the execution time, which increased whenever I said the VI, so I did a test VI (TimeTesting.vi) to determine where the problem came. In this special VI I record the execution time in a csv file to analyze then with excel.

    After several tries, I found that if I run this criterion VI with the while loop, execution on every cycle time increases, but if I remove the while loop and use the funtionnality "Continuous run", the execution time remains the same. In my high level application, I have while loops and events, and so the runtime increases too.

    I someone could explain to me why execution time increases and how can we avoid this? I have attached my VI test and the necessary subVIs, as well as an image of a graph that shows the execution time with a while loop and «run permanently»

    Thanks a lot for your help!

    Your SetReset_DO VI creates a channel whenever it is called.  And that you never delete a task.

    When running continuously, that it's as if it only runs once and LabVIEW has internal mechanisms to close references that will not be used again.  When a VI is used as a Subvi, LV does not know if she will be called again, and lacks these things until the first level VI stops. You have a memory leak.

    Just as you open and close your file outside the loop for, create your channel out of the loop.

    Lynn

  • How to stop a while loop structure in the event of a main vi

    Hello;

    Sorry for my English

    I have to stop to a Subvi my main VI, the Subvi contains a while loop and an event structure, so I need to stop this loop while I tried directly from my main vi, global variable, but it did not work

    any help please or example!

    How about something like this (solution see attachment) using a user event.

    Explore the User Interface--> range of events and dialogue. To display the dynamic event of the terminals in the structure of the event just right click and select 'display the dynamic event posts '.

  • Case of Structure / while loop problems

    Hello

    I am trying to write a code that draws a random number whenever a key is pressed.  The chart must be a random number on the y axis and the number of times that the button is pressed on the x-axis.  I want to draw the last twenty random numbers.  I use a while loop and a box structure.  If the button is pressed, the case structure incruments the number of times where the button is pressed and generates a random number.  I'm using shift registers to track the last twenty numbers generated.  When the key not, registers to shift to day values incorrectly.  My code is associated with this issue.

    I know that the last value of the shift registers of wiring to the structure of the case will change the table across the last value when the button is not pressed.  I know what causes the problem, but I don't know how to fix it.  I would appreciate it if you have a look and give me some tips.

    Thanks in advance.

    Your problem is that the loop runs continuously and your values in the shift register are replaced when you do nothing.

    There are a few ways around this.  It would be simpler to use a Structure of the event.  Another option is to simply store your table in the shiftregister.  Use Rotate 1-d Array and replace a subset of table to update your chart.  It is a little more robust and easier to use than using the history of the shift register.

    But the absolute simplest, based only on what you told us, just use a graphic instead of a graph.  A graph keeps a history.  The length of the default history is 1024 samples, then you want to reduce that to 20.  Then you just wire your random number right in the chart, and everything is done for you.

Maybe you are looking for