CPU utilization while loop

Manual LabVIEW declare a while loop must always contain a "wait for ms" vi to unlock the task for this period.

However, I thought that it the same fate if I use the same timeout ms for the timeout of a structure event inside the while loop

and omit the "wait for ms" vi.

Unfortunately the time-out of the structure of the event does not seem to unlock the task so that the façade reacts very inert in this case, even if it reacts
prompt in either case.

Does anyone have an explanation more in depth of this behavior?


Tags: NI Software

Similar Questions

  • To use or not to use: while loop?

    Being relatively new to LabVIEW and excited by the event programming Structure makes me think that a While loop should almost never be used.

    A While loop uses "polling" to see if a condition is fulfilled or not before you stop the execution, which eats memory. (No pun intended) while event Structures

    don't constantly gobble up CPU memory and waiting for something to happen, and then runs.

    Can someone give me a simple and good example of when it is appropriate to use a While loop? Do not hesitate to talk about certain situations more complicated, requiring a While loop

    which cannot really be addressed with the programming of the Structure of the event.

    While loops and structures of the event go hand in hand. You almost always want to place the structure of the event within a while loop. If you do not you will serve a single event. The while loop will allow you to repair all the events. It is important to note that when there is no event loop will not be doing anything. He will be inactive and essentially no time consume CPU. The structure of the event will have to wait for the next event.

  • Timed loop versus While loop

    Most of the machine control software I design have the following structure:

    1. There's a HAND that takes place inside a TIMED LOOP with synchronization of 50ms and priority of 100. His only job is to read / write data from / to DAQMx IO cards.

    2. the MAJOR can call several SUBs based on the choice of the user, and once a submarine is called FP MAIN is closed and the FP SUB opens. All submarines have a States Queued Machine running within a TIMED LOOP with 50ms timing but with priority to 50.

    3. data transfer between HAND / SUB is through function globals - there are many of them based on past data.

    4. all woks fine so far. No need to any RTOS. and platform of WIN7 is alomost standard. I even ran with a timing of 20ms without anything crashing...

    Problem: When there are a lot of file i/o operations in a SUB partciluar, then I have the chance to see several missed iterations. Perhaps the TIMED LOOP is hogging resources.

    What I want to do: convert both TIMED in asnd SUB HAND loops simple while loops.  But I am concerned by the priority - since the MAIN interacts with HW there priority. But with LOOP WHILE how can I ensure this?

    Or is there any replacement / effective way of doing what I do now?

    Rama wrote:

    .... FGV should be thrown out the window...

    Well used for a while, based on many articles in the KB. One of them is locked... and it does not represent the engine of the Action or of the FGV as a villain to avoid.

    The driving force is one of the largest buildings in LabVIEW.  The FGV who does nothing but Get and Set (or writing and reading) is useless and a waste of resources.  Why?  It does nothing to fix possible race conditions (does not protect critical sections) and it is much slower than just using a global variable.  See this example I put in place to see what I mean: an overview of the race Conditions.

    Rama wrote:

    So in the sample that I had attached, what do you think would happen if I just replaced the two loops with the SAME timed in MAIN and SUB wait value ms. is there a work order then?

    When things are at the same time, there is no such thing as the order of execution.  But as I said, it seems that your loop is quite slow, so it's something I would not worry.  Just make sure that you do not have a loop that uses all the CPU.

  • for loop in while loop

    To all,

    I have a question, I have a loop within a while loop. The loop runs and displays the log data. It seems that, until I have stop the while loop that log data display. It almost seems that the for loop runs until the while loop is stop.

    The following accessory is an example of what I have in my code. But the because the loop runs in this example. My code is the same idea, but the loop seems to run when I start my program with execution of climax. Otherwise, it runs once I left the while loop.

    All entries?

    Thank you

    Cosmica

    I tried your VI and there is nothing wrong the way in which it executes. Nothing happens until the second tab is selected and you press the 'off' button, date on which the loop FOR runs until the indicator shows a "9". In subsequent runs, again, it count up to nine, but it is so fast that you never see. For the observer, the indicator remains at nine.

    Of course you would see things a little bit better if you place the small waiting inside various parts of loops. At present, the VI consumes all CPU do nothing but turn empty loops for always while spending from time to time some nanosecods to iterate through the loop FOR. You also destroy your resource VISA with tunnels of default output, so the fence at the end probably will fail. Overall, the code seems too complicated for what you want to do. Do you really need to link a case control tab structure? Seems unnecessary. The for loop should run when the button is pressed, since this implies automatically that Your ' e on the second tab, you don't need to read the tab control. It's redundant!

  • Very high CPU utilization

    Hi all

    We have several standards work of the Disqualification created to standardize the data from the source systems. Among all, there are 2 positions causing the CPU usage greater than 97% throughout the work. For the jobs of rest with the same logic, but the source systems different data do not take this as the CPU usage.

    Run these 2 high CPU utilization causing positions for 50 k records and also around 1 lakh separately but still the CPU usage remains the same. that is more than 97%. Are there other specific job setting or settings that causes this problem? For the rest, the jobs CPU usage is average only 55%. Performance wise, it is not accepted and PT test sign off is blocked because of this.

    Appreciate your suggestions! @

    Thank you

    Amol 971-505343978

    Hello

    Why do you think the high utilization of the processor is a bad thing? On the contrary, Disqualification treat this work as soon as possible. While other jobs [that run at 55%] are i/o bound and probably run a lot faster if you were to set the I/O bottleneck.

    Kind regards

    Nick

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

  • Retaining the last value without a while loop

    Hello

    I'm using LabVIEW 2013. My VI is attached. I'll send in a 'Curr. Random random numbers TestPlan Row"time. I'm eager to keep his last number, whenever this VI is not called and then reset the value to its new value whenever the VI is called again and a new number has been sent. Also attached is a screenshot at the VI.

    Please note that I can't use a WHILE loop, so it must keep its value in a different way...

    Thanks in advance for any help!

    SM

    Maybe a feedback node?

  • convert loop timed to normal while loop

    How convert a while loop time normal while loop with exact same properties and performance?

    I have donot need to worry about the exact date. But it takes the timed loop time will be run similar to loop.

    And also, is there any issue encountered when we use Timed loop? problems such as that crashing exe?

    Hello

    1 kHz is the used base clock. Then, you decide to use 10 as period (dt) which is 10 ms.

    The clock is selectable in real-time systems, you can use the 1 MHz clock, giving resolution µs

    But for your needs, using 1 kHz clock with dt = 10 and using a ms of waiting with 10 connected to it is exactly the same.

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

  • 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

  • While loop, wait for the function and the stop button!

    Hello

    I have a while loop and a stop button. Inside my While loop - I have a 'Wait (x ms)' function. If I press the stop button, it does not block the program immediately, he expects ms x then stops the program. How can I get rid of this?

    Thanks in advance for the help!


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

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


  • Timeout on while loop

    Hello

    I need to insert a time-out on a while loop to exit this loop in the case of the device is not able to answer.

    How can I do?

    Best regards

    Create a local Variable:

    Locals.StartTime

    In a stage of expression before the while loop set Locals.StartTime = Seconds()

    As part of the condition of the loop While use: (Seconds() - Locals.StartTime)<>

    where X is your timeout in seconds.

    Hope this helps,

Maybe you are looking for