Synchronization of multiple While loops

Hi all

I work with 4 all in curls that are independent from each other that is, there is no data flow in one loop at the other.

I noticed that every while loop takes different time to iterate.

However, I want to while loops to begin and end at the same time after each iteration.

How can I synchronize their?

Thank you for your response.

Concerning

Aveo

Hi Aveo,

You can use a few 'occurrences', 'Notifier', or "Rendesvouz" to synchronize your loops.

Or use timed while loops - they can work in harmony...

Tags: NI Software

Similar Questions

  • HAVE multiple AO-synchronization-2 multiple while loops

    Hi all

    I want to characterize my RF circuit by using an additional narcotics control and map PXI-6229. I wrote a simple VI in Labview, which is almost similar to the example, multiple-HAVE-AO-synchronization, seen in LABVIEW. According to my VI, 4 analog outputs with different offsets dc, amplitudes and phase values must be generated to my RF circuit and 2 analog inputs must be acquired by this circuit simultaneously and continuously. But the problem with my VI is that I try to observe two diagrams at the same time to see the changes in signals generated and acquired. However, I don't see the two signals simultaneously. The second while loop, which belongs to the acquisition of analog signals, does not start while the first loop generates analog signals continuously. How can I synchronize these two while loops in order to observe the two parties in the diagrams?

    I have attached my VI.

    Thanks in advance.

    T. Eray

    Hi Eray,

    I will be brief and I'll keep it simple. If I understand correctly, you have trouble with the data stream in LabVIEW. When you work in LabVIEW, you must understand the order in which the blocks (functions/nodes/structers) are run in LabVIEW - stream. Each block can be executed just at the moment where there values on each entry. This means that if the 2 blocks are connected with a wire, the 2nd block waits until the first ends its execution.

    In your case, that means, this 2nd loop does not execute before the first loop (with the DAQ Assistant) ends its execution, because the son comes from the inside of the first loop, then they go to some DAQmx features and then DAQmx features they go to the 2nd loop.

    In principle, what you could do is to put the content of the first loop, where you prepare the signal generated in the 2nd loop. Good course without the DAQ Assistant. Instead, you can use DAQmx writing in the 2nd loop.

    Kind regards

    Martin

  • Stop the multiple while loops in the acquisition of Vision

    Hi, I want to close multiple while loops with a STOP. I use the software for the Acquisition of the Vision for the recording of multiple cameras and I would like to finish this record from all cameras simultaneously. I don't know how to do this since I am knew to LABView. I would add my VI here and maybe someone can help me.  Thank you!

    A local variable should be sufficient for your application. Read the following article:

    Parallel stop, while loops in LabVIEW with a stop switch

  • start stop multiple while loops

    I have a fairly large VI that works while several loops with the strutures case inside.

    I would like to be able to close and on all looped programmatically according to events. (complete cycle or cycle started)

    I need to store my data in a table, but whenever I turned off the while loop data I gathered is lost.

    It goes like this-measure analog voltage - put it in a digital indicator... now I want to put it in a table only once by my machine cycle.

    If the opeator push the reset button, the table is available for acquisition of report generation.

    Any help would be appreciated.

    Thank you

    It's here.

  • Sharing data between multiple while loops, competitor rates

    Hello

    I am trying to Exchange data between competitor while loops running at different speeds.  What is the recommended way to do this?    In practice, I have 12 indicators and 3 cards I would update (on screen) in the slower loop, although the data acquired and stored on disk in the fastest loop.  The image below is a simplified version of what really works my candidacy.

    I currently use local variables and shared to achieve this.  I heard however that local variables are evil because of their use of memory (data are copied instead of who passed by reference).

    Thanks for your suggestions,

    Adam

    Hi Adam,.

    Yes, here you go.

    Mike

  • Judgment of multiple while loop running at different rates to stop using the single Boolean stop button

    Hello

    I'm on the block diagram of 4 loops, do different tasks. They are independent of each other, but need to see the unique front panel - some of the wonders of labview!

    Now, I want to have a unique stop button which will in fact be a back button to return to the main screen by stopping all four loops on the block diagram. I used the stop button (switch released) with local variable to stop the three other loops. He stops the vi but it is not a good stop vi to stop properly and the grid on the performance of the front panel. Now all loops run also at different rates, so it is not necessary that all loops are stopped immediately when one of the loop is stopped. Can't really think of a better way. All the ideas!

    Kind regards

    Austin

    Variables local is ok in this case, but you will need to keep the control in switching mode (no lock).

    A better solution would be to have all the loops as a structure of event all listening value stop change. Or have the Stop value change event generate a user defined output event or similar.

    /Y

  • 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

  • While loops inside while loops, how to stop?

    Hey, I'm confused with a simpler question to multiple while loops. My goal: stop or pylone2, just jump out of the small loop and stay in the big one. and if I click on stop 3. the entire program would cease... How can I do this? The following script does not at all... Thanks in advance!

     

    Yes you are completely right Mike... now, I solved the problem with another structure of the event and the Boolean variable local... Thank you very much!

  • Control and Simulation in a loop / while loop with TCP/IP reading / writing of synchronization

    Hello, I have a problem with reading TCP/IP and written in two loops. The problem is NOT to get the two loops to read and write to and from the other. This has been accomplished. My problem is when I run control and the loop simulation on my laptop and the while on a RTOS remote on the controller on-Board of LabVIEW in a remote PXI chassis, the while loop the remote system running on four 4 times faster than the loop control and simulation on my laptop. In other words, for each iteration of the loop control and simulation on my laptop, there are 4 four iterations of the while loop on the remote system. I need to know how to get a degree of kinship (1:1) with these iterations of the loop. When I run a longer simulation in real time, say 10 seconds, the control and Simulation loop begins to slow, i.e. the simulation time slows down until it is no longer in real time and the "Late Finish"? Parameter is set to true and the LED lights and continues to stay lit. At this point, the system destabilizes due to what I believe is being well sampling rate too discreet and I have to end the simulation. How can I get a ratio of one to one between the loops and also to avoid slowing the loops causing destabilization?

    To give an overview of my application, I implement a control system in a network, seen in "image2.png". This is achieved using my laptop as a subsystem 1. Reference signals are generated from the laptop and the error signal is produced. Control measures taken and the control signals are sent via TCP/IP to the remote system. Position feedback is returned, and the process repeats. My system has Core I7 Procs w / 3 GB of RAM, up to 1 GB/s speed via ethernet and LabVIEW 2011 installed with all necessary modules and networking tools. The attached VI Custom_Wireless_Controller works on my laptop. The remote system I'm working on that has the 7830 NI R Series with FPGA card. OTN runs on the PXI chassis with an enbedded controller that has networking capabilities of up to 100 MB/s via ethernet. I use the FPGA for the acquisition of data and apply control signals to my plant. The plant is the PCE twist connected to the FPGA through the cable of the ECP - RIO of NOR. Subsystem 2 is this side of the CNE. The FPGA collects position, he sends to the controller via the network, receives signals from the network drive and writes signals to the plant power amplifier that operates the plant. This process is repeated and the VI and is titled Custom_Wireless_Plant.

    I appreciate the help really and look forward for her and for any question!

    Well, the first step is to understand what you have set up right now. Your control and Simulation loop on the side of the controller is configured as 'Runga Kutta 4' and you have a loop timed on the other side. In addition, you have the primitives of TCP/IP on the control and the Simulation diagram and means he will perform (a message) on the size of each minor step, which in your case is 4.

    So, you have two options:

    1. replace the Solver side controller Runga Kutta 1 (this must synchronize loops)

    2. hold RK 4, but create a Subvi around two primitives of TCP/IP and configure from the VI to run than the major (continuous) step-size. If you do it right, you should see a 'C' on the upper right part of the VI you have created.

    Please let me know if what I said is not clear...

  • What is the best way to run multiple instances of the class containing infinite while loop?

    Hello

    I have a several instances of the class (say a, b, c,...) that have the same parent and I want to run the same methods overridden to all instances in parallel.

    For example:

    a.init ()-> a.run ()-> a.stop ()-> a.run ()-> a.stop ()->

    b.init ()-> b.run ()-> b.stop ()->->->

    c.init() ->           ->             -> c.run() ->               -> c.stop()

    ...

    See the attachment for more details.

    The problems are now:

    1. the 'run' - method does not return until it receives the external trigger

    2. everything to run methods return in a different time

    1 chip means I can't use autoindexed for loop because in this case b.run () will have to wait before the end of a.run (), right? Is it possible to run to the loop in parallel?

    2 chip means that an object must be able to run and stop independently from others.

    What is the most elegant solution? The solution copy - paste in the attachment works for 3 instances, but there are currently 10 and more is coming.

    Juha

    In fact, what I wanted to know was "how to add the 'P' loop '... Easy, after you ask the right question.

    In the attachment, there is a test.vi that has two numerical indicators in a certain time-infinite loops. If I leave the parallelism, the two digital are incremented infinitely. If I don't allow parallelism, only the first is incremented (he never leaves the infinite while loop).

    To solve my original problem, I can make an init-start-stop branch within a loop-parallel-indexing for and make sure that there are the same number of instances of loop as there are objects in my array of objects (object array is an autoindexed in the loop for).

    Also good point about the vis environment. I should also add that.

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

  • How to coordinate DAQmx sampling with TDMS in while loop?

    I tried to connect the functions DAQmx data to the conventional method of flow TDMS a while loop. The problem is that I can never synchronize the sampling frequency of DAQmx data and the function of the elapsed time. In fact, change the sampling clock service rate does not affect the sample rate in the PDM. The data saved in the TDMS file remain at a constant speed.

    This causes me a massive problem when come to process the data.

    I join the labview code and one of the data.

    Can someone tell me what I did wrong here?

    tonger wrote:

    Thanks for the reply, Norbert.

    Reading in the 1 d waveform can save only 1 channel data. Potentially, I would like to save the data of multi and accelerometer strain gauges at the same time.

    Also, I can not always change the sampling frequency...  I think that it is still in 0.000620, which is not good for the subsequent analysis of the data.

    Is there another way to solve this problem?

    This statement on the record only one channel is absurd. And your solution two loop is just as wrong. A 1 d waveform contains so many channels that you specify and it has a current timestamp inside - not number asychronous since a different loop.

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

  • do not shutdown of while loop

    Hello

    I'm LabVIEW and motion controller software OR hardware PCI-7332/UMI-7774 and control a stepper motor.

    My question is:

    When flipping enc = 5 whereas the loop stops

    but with the rest of the value of 20 to 500.

    Why isn't rest zero.

    When the indicator test installation is checked

    the while loop does not stop.

    Please see the attached code.

    Thank you

    The rest would have to do with what happens inside the Subvi, which was not included. The output value of is not stop to an exact multiple of 4095. The question is why that is the case.

    Mike...

  • Display a message to a user in a while loop

    Hello.  I've been using Labview for about 4 days and I have this preface saying that it is a homework problem, I'm not looking for an exact solution just someone to point me in the right direction.  I need to display a message to a user.  The problem is that, since it is within a while loop, when the condition is met for the notification to display, it just returns to the top and never let the user change the values to correct the problem.  It should be pretty obvious that the vi is supposed to do by looking at, and everything else works fine, until I put the message in it.  As an aside, I know that there are probably much better ways to accomplish the tasks that I decided to do about it, but as I said, I am completely new to LabView, so I apologize for the most elegant programmers out there for my brute force programming!  I searched the forums and found a few things about statements of case and registers at offset, but I have no idea how to use.  I have on this part of the problem, worked for hours now and make me nowhere, so any help will be really appreciated.

    Welcome to the Forums!

    First of all, thanks for pointing out that this is a homework problem. We mind helping people learn LabVIEW but oppose when someone is trying to put his homework for him.

    Statements of case and shift registers are probably what you need to learn next. Specifically, a state machine is probably well suited for this type of program. I think that your LV version came with a template or design for a state machine model. Look under the menu file > New... (No new VI) and see if you can find a state machine model.

    Other comments:

    -If you don't use a structure of the event, and then put a (ms) waiting inside the loop so it doesn't turn thousands of times per second that does exactly the same thing each time until the user changes a control.

    -In line and force? will make the comparison and select lower left and upper right part of your VI.

    -Force the amount entered for the multiple of 5 cents is OK, but can be confusing to the user trying to get 3 cents. A note on the Panel or a bunch of advanced control may be useful.

    Lynn

Maybe you are looking for