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.

Tags: NI Software

Similar Questions

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

  • While why broken arrow will not appear for a timed loop

    Hi all

    I need a little clarification relative to normal while loop and timed looping in labview.

    In labview, if I keep a while loop on a block diagram, broken arrow will appear in the upper left corner of the window indicating the error. It displays error because I have not wired conditional terminal of the while loop.

    But same is not the case for a timed loop. Can someone tell me what is the reason behind this...

    If I release the conditional terminal of the timed while loop, it runs in infinfite time like a normal while loop. Then y labview behaves differently for these two types of loops in the scenario above.

    FYI... I'm using labview 2009.

    Waiting for response.

    Thank you

    Herald

    Ruben,

    the reason is quite simple: call loops are mostly real-time and FPGA targets. Since most of the applications on these targets work continuously (at least this is more often the task), it is possible to create a loop that does not end. So the timed loop by default assumes that there is no need of a stop button.

    The 'normal' while loop needs code for termination (conditional terminal) because normal applications on Windows/Linux/Mac are used to be fair...

    hope this helps,

    Norbert

  • While loop inside a timed loop

    Hello world!
    I use:
    -LV 7.1 + real-time;
    -compactFieldpoint;

    When I put some time, I noticed a strange behavior, loop inside a timed loop.  Let's fix loop timed with these settings:

    -Clock 1 kHz
    -1 ms period (Yes, I know it's short...)
    -offset 0 ms
    -Stage 0
    -Take the period of absence (ON) and maintain initial Phase (ON);
    -Timeout:-1.

    So, inside the loo, I put a traditional while loop, waiting (for example) an event will occur, and if this event doesn't happen, my cFP-2020 crashes! I mean, it becomes inaccessible for the debugger, and also, if I run a ping at his address, after a few cycles it becomes inaccessible as ping!

    Obviously, that statement of code lock the fieldPoint, because if I remove the inside while loop all work.

    I know that with 1ms duration, timed loop always the finishing of the delay, but I put the scrapping period missed and timeout-1.
      
    It seems to me that sometimes timed loop add overload heavi programs, I all so that the loop according to the tasks, even if my application has be in real-time!

    Tips welcome! Good day!

    Graziano

    Thank you very much for your answer!
    I'll test the entire application and then look for the best practice... but I still think I'll replace it timed with while loops loops...

    Good day!

    Graziano

  • FPGA: Vs timed loop Timer?

    Hello

    I would like to create a FPGA loop that runs at a fixed rate. Whatever if I use a timed loop structure or a timer loop express VI into a regular while loop? Under what circumstances should I choose one over the other?

    I understand that the timer loop approach can cause the code in the loop run twice before calendar is established (but this isn't a problem for me here). Are there other differences in the two approaches?

    Thanks in advance.

    JKSH wrote:

    But my question was about the differences between the use of "multi-cycle" Timed loops and VI express loop timer.

    In a targeted FPGA VI, all call loops are single cycle timed loops (SCTL).  This means that all the code in a SCTL must run in a clock cycle, so there are a few types of nodes cannot be used in such a loop.  In a used while loop with a timer, you can use a wider range of features, but the loop will generally run much more slowly.

    These documents may be useful to learn how to use loops clocked on FPGA:

    Using loops of Cycle time unique to optimize the FPGA VIs

    Optimization of your screws of LabVIEW FPGA: running in parallel and Pipelining

  • Structure of the event in timed loop

    Quick question on the structures of timed loops\event

    What is a good or a bad idea to use structures of event call loops - as opposed to while loops. ?  I guess I like the idea of call loops - because you can prioritize them - so if there are some important things you need priority of 100% in the background - but for the user interface, you can configure it to run slower\or run to a different priority level.

    I just wanted to check it is not a reason why I shouldn't do that - since all the examples don't do that.

    JP

    I don't think it's a good idea. Your timed loop can stop waiting for an event. There is no advantage of placing the structure of the event in a timed loop. It is possible to assign priorities to other objects outside of the call loops. For example, you can the priorities given to subVIs. I'm reasonably sure that the structure of the event can work at other priorities if you do not the activities of the user interface. Maybe someone of NOR can confirm this.

    But the goal of a timed loop is to have a deterministic periodic job. The structure of the event must be used for asynchronous events. The two disagree with them if they are in the same spot.

  • Timed loop in loop of producer/consumer

    Hello!

    I have a loop of producer/consumer LabVIEW program configuration to allow me to properly capture the images that are large enough (8MP) at about 14 frames per second (FPS). The program works very well when the consumer loop is a while 'loop' (recorded at 14fps without problem), but I wanted to do a loop timed, so that I can vary the FPS as requires it. A curiosity arises when I do that. Anywhere under 12 fps, the loop works very well and the data is saved correctly. However, when I bump it up to 13fps, the calculated consumer FPS goes haywire and starts to jump between 9 ~ and ~ 13fps (processing of data gets bogged down?). When I set the FPS at 14, the loop runs at a constant maximum 7 fps. Is there something I can do to remedy this situation?

    I have attached my .VI

    Thanks in advance!

    Palanski,

    Are you using LabVIEW Real-time? Loops clocked to a windows OS do really increase determinism more than a while loop with a wait until the next timer multiple. Before you change the loop of producer-consumer in order to include a while loop was programming works correctly? You can also vUtiliser the VI analyizer to see how long things take to run. I let the loop of consumer to the producer in the traditional game upward and change the FPS by controlling the timer to wait, after benchmarking your code, it should be done in the same way as you did for the timed loop

  • Sequence structure flat inside the timed loop and execution order

    I have some problems trying to implement a flat sequence structure when you use a loop timed on a target of cRio VI

    I tried with or without the while loop around the structure of sequence flat, and I also tried to replace the 'Non-deterministic loop' with a timed loop

    The problem is that the program seems to run only once, then get stuck somewhere

    I am writing a program that performs the following operations as soon as possible:
    1. read the Pos_MC of entry on the FPGA
    2 send the value of Pos_MC to the VI target (on cRio CPU)
    3. calculate a value of output based on Pos_MC with a PID block ("exit PID')
    4. send 'PID output' to the FPGA
    5 write "PID output" analog output "MOOG".

    In addition, I want the program to return the measured value "Pos_MC" to a host VI for the recording of data

    So that the output of PID is calculated and sent to the FPGA as quickly as possible, I placed a flat sequence structure to ensure that it happens before you send the output to the nondeterministic loop for recording data

    Also, I want the digital input 'Stop' to be able to stop the loop deterministic (the timed loop)

    I read much more entries than that and the help of several PID and exit, but I rewrote the code for a single entry and exit to make it easier to illustrate

    Screenshot of the code is shown in 'target code.png' and 'fpga code.png.

    The VI themselves are attached in the next post (cannot attach files of more than 3)

    Question 1:
    Any advice on how to get this race? Thank you!

    Question 2:
    Is also my correct understanding in that, using this structure, each 0.9ms (fpga loop time) comes the following:
    1. the input ("Pos_MOOG") is read on the fpga
    2. the production of PID is calculated on the cRio with some delay to computation (for example 0.1ms)
    3. the output of PID is then written for analog output "MOOG" in all about 0, 1 - 0.2ms
    4. the FPGA program then waits until 0.9ms spent and repeat the process

    As opposed to the next pass whenever performing a loop is started on the FPGA:

    1. the FPGA reads the input and written on the output (the output of the execution of the previous loop PID)

    2. then the entry is sent the cRio, PID output is calculated and sent to the FPGA

    3. the new release of PID is maintained until the next time through the loop

    Thank you!

    PHG wrote:

    Thanks for the input guys, any advice as to how I could get the feature in scenario 1?

    I still say that the best route is just putting all the logic of the control in the FPGA.

    Other alternatives include 1) the use of DMA FIFO sedn data back or 2) use interruptions so that the FPGA code can not read the output level until the RT.

    DMA FIFOs are usually very limited, and I would not use them in this situation since I belive said it this code to do for the many outputs.

  • Module speed FPGA, speed controller and timed loop speed

    Hello.

    I'm developing an application to acquire an analog signal at 800kS/s. Budget does not seem to be enough buy material excess spec. So I have to be very very accurate on all components. I had a look on the site and selected the following materials.

    9221 8 module capable analog channel on 800kS/s sampling. I don't know if this sampling rate indicated in the specification of the module means that it can acquire up to 800kS/s or is the device samples ADC sampling rate to which the machine don't maybe not to the criteria of Nyquist and the module can perform sampling to 1.6MS / s is necessary which I think is not available?

    9012-400 MHZ controller controller. If I put a while loop inside a VI under the RT target, it runs at 400 MHZ by default provided there is no code inside? Is so I could definitely use loop time express vi for sampling at the required level.

    What of the timed loop? I just developed a project of RT and added vi under the RT target. The timed loop default clock frequency is 1 kHz and I can't select more than 1 MHz?

    9112 chassis. Default clock 40 MHz. same rate issue which concerns the 9012 above controller.

    Kind regards

    Hi AustinCann

    If you need to acquire 800 kech. / s, then the module module-9221 will be able to do this, if you are using only 1 channel, that is.  The module using a global sample, therefore the maximum rate will be distributed on channels that you use.

    If, however, you have to detect the frequency of > 400 then you would need a higher sampling rate to detect these, as you mentioned.

    The controller processor runs at 400 MHz, even though the loops in your code will not run at this pace.  On the target in real time, you can use a timed sources of clock - usually 1 kHz to 1 MHz - and set the period in terms of the chosen clock.  If you need faster line rates, you can still code directly on the FPGA.  The CompactRIO Developers Guide is a comprensive document and deals with most of the concepts of RT and FPGA.

    The best course of action would be to contact your local office, because they have all the resources necessary for the specification of your system.

  • Having a strange action case structure on a timed loop.

    A resolved question yesterday, lead to a new problem. In this VI, I have a timer that triggers an external meter. The counter "counts" from 1 to 24, each with an action at a given time. However, once I got the timer and counter work, I found that the Boolean trigger remained on the hour enitre, and my action was repeated several times instead of only one. So, I changed the counter count 0.1 each interval, rather than 1.0, thinking that it would only allow my State business to operate for a shorter window. However, when I run the VI, the case of the State are active in the meantime, not at the interval. For example, cases of stae 2 is active between 1.5-2.5 iteration and iteration throguh 2.5 3.5 State case 3 is active. Can anyone suggest how to get either 1) better display resolution on the evidence of the State of th or 2) another way to get the Boolean value for just a few seconds?

    Thank you, Lynn.  Yep, I tried that (at least the half of it.)  I opened it in my first version, which is being 8.5.1.  I don't think to check in the dialog changes not saved, however.  I feel kind of sheepish having never tried that before.

    Well, here is my interpretation of what was asked for... I had to make a few assumptions, namely that the 'timed loop' refers to the while loop that runs at a defined interval, and that "triggers" are just the Boolean flags.

    I hope that this at least partially answered questions?

    Jim

  • passing the value and to timed loop

    Hello everyone,

    I'm working on a VI that consists of a timed loop which takes values in a file every 6 ms and writes it to an output file. Inside this timed loop, there is also a MATLAB block that calculates a parameter based on the value. based on this parameter, that a marker is set to 0 or 1 (planned) to operate as a Boolean marker.

    The problem arises when the marker is set to 1. I need an additional structure any that waits five seconds (without stopping the timed loop iterations) and a 'stop' button is not pressed an additional string is placed in the output file. I wish for the marker to get back to 0 if you press the 'stop' button and not string to put in the file.

    The main problem seems to be the use of a structure outside the timed loop. I can't have a while loop or any structure that waits 5 seconds inside the timed loop. And if I let him out he does not have the value of the marker second structure during execution of the timed loop.

    + Any ideas on what the structure to be used during the 5 seconds Timeout? (I tried a while loop)
    + Use a local or global variable for the marker? (I tried briefly, but as a local variable, I couldn't choose a variable defined in the MATLAB block, and I don't understand global variables in LabVIEW)

    I enclose a simplified version of the VI as well as a sample input file in case it can help visualize.

    Thank you
    DAVA

    So far, there are a few problems with your solution, but first of all, I will try to help answer your original question.

    You are right that you can't have a structure inside the timed loop which waits five seconds without blocking execution of the timed for the same period. You are also right that you cannot simply communicate through cables to an external structure. If you exit a loop of wire in the other, which creates a dependency of data flow, which means that the data loop cannot run at all until another loop ends its execution entirely and send data.

    You have two options:

    • Don't actually use a wait function to determine if the 5 seconds elapsed. Use the Express VI of time elapsed (search the palette). He just guard track of how much time has passed since the last reset. It does not wait. If you are safe to use inside your loop timed in a case that is triggered when the marker value becomes 1. Also check the Boolean command in this case Structure to decide if you should output the data in the file.
    • Use an outer loop as in the example you posted, but use screws of the range of synchronization to send data between the parallel loop. Consider a queue.

    But overall, I don't think there is much chance of this work very well. No way, the Matlab Script node running fast enough to run at a time of 6ms. Also no way it works in a deterministic way at all. He needs to communicate with an external program, so its execution time is really unlimited.

  • Leak memory in real time caused by VISA Read and timed loop of data nodes? Is not supposed.

    In collaboration with LV 8.2.1 in real time to develop applications that monitor or emulate computers on bus RS-422.   The following screenshots have been taken an application that monitors a transmission of 200 Hz.  After a few hours, the PXI station would break a range impressive messages angry... most involving something about memory loss.  After much hair pulling and passing money, my partner has discovered while looking at the available memory on the controller of loss of memory occurred at each loop containing a VISA read and propagation of error using the data nodes (see Leak.jpg of memory).  He concluded that if he went to the propagation of the error to the regular old shift registers, then the available memory was rock-solid.  (has the Leak.jpg of No memory)

    Any ideas of what could be the cause?  Do you see not any problem with the way that we code these kinds of loops?  We always strive to optimize the way in which we use the memory on our urgent requests and VISA readings and DAQmx bed give us the heartache more than ever, we are able to allocate memory for these screws some tips?

    Dan Marlow

    GDLS

    Hi thisisnotadream,

    This problem has been reported, and you seem to be exactly reproduce the conditions required to see this problem. This was reported to R & D (# 134314) for further investigations. There are several possible solutions, of which one is the one you have already found the wiring error directly in the loop. Other situations which give rise to no memory leak are:

    1 if the bytes of the property node port is not there and has read lies in each iteration and time-outs resulting are ignored.

    2. If the structure of the deal is gone and just blindly check the bytes to the port and read each iteration.

    3. If the timed loop is transformed into a while loop.

    Thanks for the comments!

    Kind regards

    Stephen S.

  • Timed loop continues to turn after stop

    Only, I have seen this time, but thought I should ask about it.  After pressing the stop button, I was surprised that the diagnostic LED on the front panel of the main vi kept flashing.  With the performance highlighting ONE values showed that the timed loop was still running.  I checked the other 8 loops clocked subvis and they also ran. None of the methods Stop worked. Only stop LV and abandonment of the cRIO eliminated the problem.

    Run LV2014 SP1 on cRIO-9067 with dual-core ARM processor.  Windows 7 x 32.

    BTW: The function of the check LED VI scale does not work on this device.

    You must allow an order any to be able to stop your curls.  A simple global variable would work well here.

  • Not end timed loop

    In the attached VI, I put the loop timed to end once the delay 1 reaches zero. However the timed loop continues to run and stop only if I have OR both 1 and 2 delay delay. (Tried with different schedules for late 2 which are less lag 1, equal to 1 delay and more delay 1 - no chance unless it is also linked to stop)

    What is the reason for this? (The VI is in LV2012)

    And it is protected by word that prevents us from looking into it.

    Is this your VI or did you also?

    Subvi properties seem to show that it is not reentrant.  Otherwise it can only run one instance at a time.  And if happens to store data to leave once it is called to another in the uninitialized shift, running an instance registers is probably interfering with the execution of the other instance.

  • timed loop

    In the timed loop, the entry node was a... of entry... that called "Source name" and says that I can specify the name of the source of synchronization.  What this means and how can I do?  How is it when I put a constant with the same name as the name of the default Source (create > constant > "1 kHz") the loop runs only x times then stops on its own.  Yet when I leave the value by default as is the loop runs until I hit the stop button?

    Hi Clint,.

    Yes, the moment Source.vi create will serve in the same vi. There is actually no difference between the vi and the options on the node of the loop. However the calendar source.vi creation will be used if you want to programmatically select the synchronization source.

    You will find information on the configuration of the source of synchronization in the detailed help, a link to which lie at the bottom of the window context help:

    "Double-click the node entry or with the right button of the structure and select Configure the timed loop to display the Configure the timed loop dialog box, where you can configure the timed loop. The values you enter in the dialog box Configure the timed loop appear next to the input on the entry node terminals. »

    Thank you

Maybe you are looking for