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.

Tags: NI Software

Similar Questions

  • 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

  • Stopping at two while loops, running with queuing

    Hi all

    I'm using labview 8.2.

    I have two while loops in my code (called the main loop and the other average loop - seen on the screenshot file).  I just want to stop both the while loop at the same time (it's ok it the average loop takes a bit longer).  I use global variables to stop (as I have tried the local one, but I don't think that LabView sees in the middle of the subroutine).

    Please give me some suggestions on this.

    Is attached a screenshot and my labview code

    Using a ' functional global' is almost identical with a "global" variable Indeed, before the existence of "global variables", a functional overall, it is how people have this feature.

    The usual way to stop a loop containing a "wait for queue ' is to destroy the queue and use the error on the terminal of the 'expectation of queue' directly in the terminal of the judgment. In this way, you don't have to queue up some kind of end the command to stop it.

    Add a queue to destroy after the stops 'main while loop. Delete the global variable and the error from the stop "waiting in the queue" in the loop "average" it is wire terminal.

    General advice, always try to avoid using local and global variables.

  • Two while loops in parallel - 2 does not run

    Hello

    In this simple configuration, there are 2 while loops:

    • 1st - for installation
    • 2nd - operation, where variable X increments

    The problem is: after 1st run variable X is not reset to X 0, if VI stops immediately after it starts.

    The reason - 2nd loop is not executed, X 0 if value is not propagated to X.

    Thanks in advance

    Pavel

    You want to first one case installation and after perform the different number of steps, based on the parameters for installation.

    A perfect place for one State (a single necessary loop usually) machine. You need an idle state when waiting for user input. After that the user starts the initialization state, which calculates the number of steps for other States required. At the end the system automatically moves back to the idle state, and waiting for the user to install and launch another race.

    No need to sequence meal structure at all. With a state machine, you can just do much more (like abandonment of sequence to Midway, is not possible with the structures of the sequence)

  • Problems to use TimerEvent in While loop

    Hello

    I try to use a while loop a TimerEvent. In the example below, I created the function init should loop through values myArray, tracing of each value to every three seconds. It seems, however, that because I am incrementing the value currentNum outside the while loop (from the timerHandler function), the just loop continues to turn until the Flash no longer responds.

    var myArray:Array = new Array ("one", "two", "three", "four", "five");

    var currentNum:int;

    myTimer var = new Timer (3000, 1);

    function init (): void {}

    while (currentNum < myArray.length) {}

    trace (myArray [currentNum]);

    myTimer.addEventListener (TimerEvent.TIMER_COMPLETE, timerHandler);

    myTimer.start ();

    }

    }

    function timerHandler(e:TimerEvent):void {}

    currentNum += 1;

    }

    init();

    I wonder if what I try to do is just simply not possible or if I'm missing something.

    Thanks in advance for any thoughts on the issue.

    This loop will run at the speed of light of the processor.  Put the timer inside it will not slow down it.  Chances are that you do not want to use a loop of any kind other than that which is developed through the use of the timer and the single event handler function.  Maybe together the repeat of the timer value be based on the length of the array.

  • A specific problem with increment in a while loop

    Hello

    I'm pretty new to labview, I would be grateful if someone could help me out on this one.

    I am currently implementing a sweep of the tension, providing a starting Point, point stop and step size. I put in place using a point of loop, where a shift register adds on a step size to the starting point, and when the value is equal to the value of the stop loop breaks.

    The attached VI seems to work with integers for example Start 1, stop 10 and size of step 1.

    However, when I use a start value of 0, level of 0.1 and 1 stop, the loop never breaks. I tried the format & precision of edition but still can't make it work. Could someone please explain why this is happening.

    What I also noticed is that if equal to sign is replaced by a greater than or equal to, then the loop stops at 1.1 instead of 1. If I said the next START of 0, the increment of 0.1 and 0 STOP, the loop stops at 2.

    I have attached the VI (IncrementStepSizeWhileLoop.vi).

    Thank you very much.

    ranveerm

    You can calculate the number of necessary iterations from the parameters, so a loop IS more appropriate and you don't even have a comparison operation.

  • How to upgrade a shift with two independent loops while register?

    Hello everyone, I have a panel with two clusters with indicators control... a left and a right. I have messages from serial port, and I'm currently updating the left and the right within their own while loops. I have a single variable, which must be updated based on updates on both sides. Basically, I need follow the last selection update on each side... If I had 1, 2 and 4 on the left side and 3 on the right side... I would need to follow 4 was the latest updated the register shift variable for uses more in my vi. Can someone give me an idea how to upgrade this a variable based on two while loops that run independently in the same sequence context? Thanks in advance, cayenne

    Thank you both of you for the suggestion.

    I managed to find a way to get the values that I needed without EI... but I read the link to the Nugget in their subject, and I can't expect a use for them in the future.

    Cayenne

  • A result of sending the data to a while loop through another loop of TCP communication

    Hi all

    I have 2 screws

    1 matching model (using the method of Grab) which is put inside a while loop. This VI works correctly and returns a string in a specific format (position and the angle of the object).

    2 TCP server who always listens to a specific port, if it receives a correct command string, it sends the string above VI - 1 (position and angle).

    The two 2 screws works if they are in separate VI. But I want to combine them into 1 single VI and I get the problem: Pattern matching doesn't work anymore (the video has only first frame then stops).

    I tried to put the two while loop in parallel or put the TCP while loop inside while loop Pattern Matching. Nothing has worked.

    Pls see my attached VI and the TCP module.

    What is the solution for requirement?

    Thank you all!

    What I would do, is be your two screws at the same time.  Given that you do not send the last result, store the result in a global variable.  Your comparison models written VI the global variable of the results of each iteration of the loop and the TCP bed module global variable results when it receives the right to order and then send it.

  • 2 while loops can work at the same time?

    I have two while loops in my program; We can read the data and the other does nothing until I hit stop on the first. I want the first and the second to run out of the time constraint, I have for it when I hit the Start button to always run. I use a DAQ and transfer data from one to another while loop. See the attached file.

    Main issues:

    How to tie the Start button?

    How to get the second loop to work with the first?

    Thank you

    Your problem is that the loops are dependent on the data.  If you want to run two loops at the same time, they cannot have wires linking one to the other.  Focus on the architecture of producer/consumer .  It uses queues to send data of a loop to the other.

  • 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

  • Leave a consumer while loop

    Hello

    I've included a little VI which is purley two while loops is a producer and the other a loop of consumer. This example is to show someone this method. What I want to do is produce it at a faster pace than the rate of consumption, and when the loop of consumer sees no more items in the queue to stop the VI.

    My problem is that the parolee receives terminal real output does not appear to do. Can someone have a look I'm sure I did something stupid

    In your background loop, the Dequeue item will wait and wait for an item that does not come. There are several ways to deal with this, but the easiest for this VI is to simply plug a non-negative number on the Dequeue item time-out. Given that your data is sequentially with no break and must never be empty, a timeout of 1 should work. Give it a try.

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

  • a starting after another while loop

    I'm sorry, I'm new to labview, it's probably an easy question, but I didn't really even what to look for. I have two while loops next to each other, control of temperature (left) and the other pumps to control (right). I don't want to start the pumps until the temperature rises to the right value. The<= operator="" in="" the="" while="" loop="" on="" the="" left="" is="" what="" controls="" the="" heater="" in="" my="" system.="" i="" want="" the="" while="" loop="" on="" the="" right="" to="" start="" after="" the=""><= operator="" returns="" false="" for="" the="" very="" first="" time,="" but="" after="" that="" i="" want="" them="" to="" operate="" independently="" of="" each="" other,="" with="" both="" while="" loops="" running="" until="" they="" are="">


  • How to increase code efficiency in a while loop (using PXI5105 for sampling outside signal digitalizer)

    Theoretically, we want the PXI-5105 (digitizer) have 302 record with each record has a 1260 sample (the save operation is inside a while loop) in approximately 30ms, however we have found that for each period (30ms), the PXI5105 only perform about 10 records. It is so wired. I wonder if the operations inside the while loop consume more time (for example 3MS), so that he cannot have 302 records even the PXI-5105 have 60 M/s speed of sampling. Is it true, you can find my labview code and if possible can you give me some suggestion in the most short time of operation of the loop.

    Please find attached labview code.

    Hi g_l_g_s,

    The digitizer PXI-5105 acquires data at the speed that you specify and stores the data in its memory embedded (up to 512 MB). The data is then sent to your computer when the Multi Fetch Cluster.vi is called. In VI that you posted, you are only fetch record during each while the loop iteration. If you want to retrieve 302 records you will need to specify 302 files in the horizontal Timing.vi to configure. For more information about scanners, you might find the DevZone, hereuseful.

    To determine the amount of time it takes for each while the loop iteration, you can consider using the structure of code in the example comparison community calendar, which is located here.

  • structure of the event + while loop

    Hello, I am trying to understand how to unite two while loops in attached VI for half a day

    The first loop creates a state machine solid which reacts on each key and runs one of the structure cases. (that part works very well)

    The second loop, always generates the random number, but it stops the generation during the time where one of the structure cases events are executed. (this is the part ticky)

    Any suggestions?

    If you want your random number to stop so that the user triggered events are running, you should be able to simplify your design a lot.

    It can be done with a loop using the case of timeout.

Maybe you are looking for