f



loops in loops

In the attached vi, the one second loop runs at one second and can't be touched.  In the ten second loop, the ten second clock is a stand in for a process that generates a finished signal. The problem is once the process is complete, to start it again, leave the one second loop running, and start an additional process that will take less time than 10 seconds. thanks


internal loops.vi:
http://forums.ni.com/attachments/ni/170/319512/1/internal loops.vi
0
x9561 (148468)
4/28/2008 3:10:06 PM
comp.lang.labview 35213 articles. 1 followers. vasusachin24 (1) is leader. Post Follow

6 Replies
934 Views

Similar Articles

[PageSpeed] 3

Hi exo,
what do you try there? If you start your vi, the value from your stop button will be read and after that, both loops "one" second and "ten" second won�t notice the state change of the stop button. Can you please explain, what you try to do??
Mike
0
x9561 (148468)
4/28/2008 3:10:08 PM
Okay, let me try again.  I need three loops. Two loops start at the same time one runs fast one runs slow. The slow one is probably independent to the problem. When the second loop is done, it needs to restart and start a third loop that takes less than the second.
0
x9561 (148468)
4/28/2008 3:40:08 PM
You have a very basic dataflow problems. Unfortunately, I don't understand your description.
 
I would recommend starting with some basic LabVIEW tutorials.
 
Here are some obvious mistakes:

- Your loop cannot read changes in the stop button, because the terminal is outside the loop.

- You reset "internal loop" to zero in parallel to the loops. You cannot guarantee that this will happen before the locals are read so you might have a race condition.

- The 10second wait runs in parallel to the event structure so the wait times will interact possibly in an unpredictable way.

- Your "internal loop" indicator has the sole purpose to act as a local variable. A shift register is more appropriate, eliminating all the locals. Just hook the indicator to the inner shift wire to see the progress.

- Event structures don't react to programmatic value changes, so your even will never fire!

- Your event structure is completely meaningless, because the "ten second loop" changes with each iteration automatically and since you seem to want to trigger it in this case, NO even structure is needed!
0
x9561 (148468)
4/28/2008 3:40:09 PM
exo wrote:Okay, let me try again. I need three loops. Two loops start at the same time one runs fast one runs slow. The slow one is probably independent to the problem. When the second loop is done, it needs to restart and start a third loop that takes less than the second.


This is all still very vague. You are omitting crucial information.

- Which one is the "second loop". Slow or fast?

- What is the meaning or "probably" in this context?

- Should the first loop continue forever?

- What determines if the second loop is done?

- What does the third loop do during that one second? Is it actually looping many times or is it just executing some code once?

- What should happen after the third loop is done?

It might be much easier if you could describe your problem from a real-world perspective instead of programming terms.
What is it suppused to do? What is is controlling? What behavior should the user see?Message Edited by altenbach on 04-28-2008  08:32 AM
0
x9561 (148468)
4/28/2008 3:40:09 PM
I'm acquiring data for a fixed length of time.  During that time, I have to monitor, at a faster rate, my position. Once the data has been acquired I have to start acquiring more data. At the same time so as not to interrupt the data collection, I have to down load the previously acquired data to a file and update the file's header.
0
x9561 (148468)
4/28/2008 4:10:04 PM
How time critical is the acquisition?  Is it 1000 samples/sec? 100's? 10's? 
Multiple loops is not always the solution.  You need to define the sampling rate, intervals between samples (first set stops / second begins).
Also how is the data acquired?  Is it a DAQ board?  is it buffered?  What is the target PC / OS?  Single / multicore (additional tricks ;) )...
It is important to understall all constraints in order to suggest a better architecture.
RayR
0
x9561 (148468)
4/28/2008 5:10:10 PM
Reply:

Similar Artilces:

while loop in a while loop
Hi all,          I am trying to write a program with a while loop within another while loop. When I run the vi both while loops  run but then only the inner while loop seems to update, I adjust controls and they have no effect on the indicators.   Thanks.. The outer while loop will not update until the inner while loop finishes, at which point the whole dance will start again You need to familiarize with the concept of dataflow programming. Run your VI in "execution highligthing" mode while watching the diagram and you'll get a better feeling on how things work. :)   If both loops need to run in parallel, place them next to each other without data dependency.   Can you explain what you are trying to do? :) So is it a bad idea to have one within the other if I was them to run simultaniously? Should I put the two whileloops side by side? I have attached the block diagram Thanks   Block Diagram.JPG: http://forums.ni.com/attachments/ni/170/319250/1/Block Diagram.JPG sparrowroad wrote:So is it a bad idea to have one within the other if I was them to run simultaniously? Should I put the two whileloops side by side? I have attached the block diagram It all depends what your program should do There are scenarios where stacked loops are appropriate. Typically, one loop is sufficient if you want to run most of the code at 500ms interval, but some p...

For loop while loop
I need to evaluate a function from 0:200 then create an array of every 5th value in the 0:200 array using a for loop then using a while loop. I can't get the for loop to work at all because I cannot use >,< controllers, only an =. So I focused on the While loop: n=0:200;%creates 201 cell array from 0-200 x=n.^2+.25;%calculates x plotcol=(length(n)-1)/5;%=(201-1)/5=40 y=zeros(1,plotcol);%creates 1X40 vector col=1;%used for incrementing in while loop while col<=plotcol; y(1,col)=x(1,5*col); col=col+1; end Unfortunately the output starts at 16 when it should start at 0. It seems like it should work to me, but something is messed up. Any help would be appreciated. "mpl " <mpl@mathworks.com> writes: > I need to evaluate a function from 0:200 then create an > array of every 5th value in the 0:200 array using a for > loop then using a while loop. > > I can't get the for loop to work at all because I cannot > use >,< controllers, only an =. > > So I focused on the While loop: > > n=0:200;%creates 201 cell array from 0-200 > x=n.^2+.25;%calculates x > plotcol=(length(n)-1)/5;%=(201-1)/5=40 > y=zeros(1,plotcol);%creates 1X40 vector > col=1;%used for incrementing in while loop > while col<=plotcol; > y(1,col)=x(1,5*col); > col=col+1; > end > > Unfortunately the output starts at 16 when it should start > at 0. It seems like it should work to me, ...

WHILE LOOP AS FOR LOOP
its possible? For each id in (SELECT * FROM table) INSERT INTO table2(id,fk,nombre) values(1,id,'xxx'); Jessica Gonz�lez (jess.rgm@gmail.com) writes: > its possible? > > For each id in (SELECT * FROM table) > INSERT INTO table2(id,fk,nombre) > values(1,id,'xxx'); > So in SQL, you don't normally code the loops explicitly - the loops are hidden on the inside. Logically, it is an operation of a set. INSERT table(id, fk, nombre) SELECT 1, id, 'xxx' FROM table -- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx thanks.. but SET IDENTITY_INSERT table ON; INSERT INTO table(pk,activo,permiso,rol) SELECT IDENT_CURRENT('table')+1,'S',id, 1 FROM table2 return error Violation of PRIMARY KEY constraint 'PK__table__3213E83F2B947552'. Cannot insert duplicate key in object 'table'. The duplicate key value is (6). only 'id' i need get from table2 Jessica Gonz�lez (jess.rgm@gmail.com) writes: > thanks.. but > > SET IDENTITY_INSERT table ON; > INSERT INTO table(pk,activo,permiso,rol) > SELECT IDENT_CURRENT('table')+1,'S',id, 1 > ...

while loop in a while loop
Hi All, I have the following situation: while(rs.next()) { //loop1 while(rs2.next()) { //loop 2 } } It seems like loop 2 is only beeing used once. Should I after loop2 put the cursor back to the beginning? if so, how do I do that? Thanks! -- Posted by news://news.nb.nu Steven wrote: > Hi All, > > I have the following situation: > > > while(rs.next()) { //loop1 > > while(rs2.next()) { > //loop 2 > } > > } > The architypal loop (for a List eg ArrayList of Blah objects) is: for(It...

what diference between timed loop and while loop and for loop
If I want to count 2 second working in the loop and next then going out of the loop I don't know&nbsp;which the loop &nbsp;I can use Message Edited by Jairak on 07-26-2008 03:14 PM Why do you need a loop to count for 2 seconds? To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's <a href="http://zone.ni.com/devzone/cda/tut/p/id/5054" target="_blank">Learning Center</a> which provides links to other materials and other tutorials. You can also take the <a href="http://www.ni.com/academic/lv_training/how_learn_lv.htm" target="_blank">online courses</a> for free. Hi, &nbsp; From the information you have provided, I don't know exactly what you are trying to do. However, if you want a loop to iterate once, wait until two seconds and then exit the loop, use the "Wait Until Next ms Multiple" function, wire in a numeric constant "2000" and wire a boolean true constant to the loop condition of the while loop to iterate once, or use a for loop with "1" wired into the loop count. &nbsp; Perhaps you need to elaborate your question. Plus, check out the context help (press Ctrl + H) for a consice report on each of the loops. &nbsp; Regards, Jairak wrote: If I want to count 2 second working in the loop and next then going out of the loop I don't know&nbsp;which the loop ...

Triple nested loop python (While loop insde of for loop inside of while loop)
try to make my triple nested loop working. My code would be: c = 4 y1 = [] m1 = [] std1 = [] while c <24: c = c + 1 a = [] f.seek(0,0) for columns in ( raw.strip().split() for raw in f ): a.append(columns[c]) x = np.array(a, float) not_nan = np.logical_not(np.isnan(x)) indices = np.arange(len(x)) interp = interp1d(indices[not_nan], x[not_nan], kind = 'nearest') p = interp(indices) N = len(p) dt = 900.0 #Time step (seconds) fs = 1./dt #Sampling frequency KA,PSD = oned_Fourierspectrum(p,dt) # Call Song's 1D FS function time_axis = np.linspace(0.0,N,num = N,endpoint = False)*15/(60*24) plot_freq = 24*3600.*KA #Convert to cycles per day plot_period = 1.0/plot_freq # convert to days/cycle fpsd = plot_freq*PSD d = -1 while d <335: d = d + 1 y = fpsd[d] y1 = y1 + [y] m = np.mean(y1) m1 = m1 + [m] print m1 -------------------------------------------------------------------------------- My purpose is make a list of [mean(fpsd[0]), mean(fpsd[1]), mean(fpsd[2]).. mean(fpsd[335])]. Each y1 would be the list of fpsd[d]. I check it is working pretty well before second while l...

While loop VS for loop
I am enabling the index and getting the values inside both for loop and while loop.Which one do you guys think is efficient and a proper coding style.I maybe wrong but i feel while loop to be much faster than for loop.Is that true? rpr wrote:i feel while loop to be much faster than for loop.Is that true? No, they both run at basically the same speed given the same conditions. If anything, the while loop will run a bit slower because it has a condition to evaluate with every iteration. &nbsp; The basic rule is simple - you use a for loop if you want to run a known number of times. Otherwise, you use a while loop. There is one exception and that's using the conditional terminal on the for loop. You can see some details <a href="http://thinkinging.com/2008/07/07/labview-85-feature-for-loop-conditional-terminal" target="_blank">here</a>. There are two performance enhancments which a for loop can have - because it is run a known number of times it can have the memory for its outputs preallocated (which makes a big difference) and on certain occasions it can be computed before the VI runs. Thanx for the explanation Tst. ...

Loop within a loop ???
Hi, I'm having trouble copying table data to new records. I have two tables as follows: *** Specifications (Table) specification_ID (field) LINKED product_ID (field) specification_header (field) ________________________________________ *** Specification_detail (Table) specification_detail_ID (field) specification_detail_text (field) specification_ID (field) LINKED specification_ID in this table is linked to specification_ID in Specifications. ________________________________________ On a form, related by product_ID, 'Specifications' fills a subform, no problem. When you cli...

Loop-Loop Calculation
Hi &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i have one VI in that i want to do Loop to Loop calculation. In my VI first the inner loop have to execute first . Loop-Loop calc.vi: http://forums.ni.com/attachments/ni/170/302256/1/Loop-Loop calc.vi I think you should explain better what you wean by "loop to loop calculation". What are you trying to accomplish? ...

while loop inside a for loop
Hi, can someone please tell me why "time" (t) is not updated correctly within the while loop? Please run this small code in your machine and you'll know what I'm taking about. What I want is: for t=1 run the "while loop" until iq<=(numberc-1) then t=2 run the "while loop" again until iq<=(numberc-1), and so on. Basically, this code runs through all the nonzero elements of A and attempts to divide them individually into two, once a certain time has passed. Please feel free to ask for clarifications. Many thanks in advance. A=[0 0 0 0 0 0 ...

stop an if loop in a for loop
Hello, I try to find a way to stop an if loop inside of a for loop but keep the for loop going. I tried to use "return" and "break" but they stop the for loop too. Bellow is a simple script to explain what I mean. Using "return", it stops the loop when z = 2 but I would like to find a way to keep the for loop going until z = 3. i = 1; for z = 1:3 i = i+1; if i ==3 return % Stop the if loop else display('Cant do it') end end Thank you for you help Benoit "Benoit " <igneb@iastate.edu> writes: > Hell...

conditional loops (while loops)
I am using a while loop to check a digital input. I would like to send the value to a true or false box to check another digital input. The problem is that the while loop is running continuously but not giving anything out through the connection. I am looking for something like "if this do that conditional". Is there a way to set this up? Hello! The =93if this, do that conditional=94 tools in LabVIEW are the Select function (All Functions >> Comparison subpalette) and the Case Structure (All Functions >> Structures subpalette), depending on the complexity of what you wa...

getElementById in a for loop whose target div id is being looped in that for loop.
Hello! Thanks for reading my question first! I have many divs with an numeral id ,for example <div id="999">...</div>, <div id="1000">...</div> and I wish to do something like this, for( var i = startvalue; i<=endvalue; i++){ document.getElementById(i).style.background="yellow;"; } but after the first changing background, it stops and tell me that the document.getElementById(i) has no properties. And I am sure that those div's exist. What's going wrong? Thanks So Much! Nik said the following on 12/15/2006 12:08 AM: > ...

Comparison in a while loop between a 7th loop valuee and 8th loop value
I have a value (voltage input) in a while loop that changes, maybe not every loop, but every 10 or so. Every loop I have to make a comparison between the previous loop voltage, and the voltage I am receiving from the current loop. If it did not change, then I have to do nothing. If it did change, I have to AO the voltage plus a certain increment. I have no idea how I could do this. Help!!! It worked perfectly, thanks! ...

parfor loop with nested for loop
Hi all, I'm new to this group, but googling my problem always points here so I thought I'd sign up. I'm running multiple iterations of a time-evolving Monte Carlo simulation in Matlab. Since each iteration is initialized randomly at the first time point, the iterations can safely be run in parallel on a quad core PC. I've previously been doing this by simply running 4 simultaneous Matlab sessions on one machine, but I thought I would save my institution some licenses and automate the process at the same time. The problem is that my code essentially has multiple nested for ...

A loop within another loop..
Hi. Hopefully you will see the code and see what I'm trying to do, and see the problem. The loop seems messy, but my method to help with eye strain is to match up the do-end's down an imaginary column... ie: array.each # do # |i| puts i # # <-imaginary column # end # ##### So here's the code. ########### def foo(argument1, argument2) #1 user = [2,5] user.each do |bar| output = [] #2 argument1.each do |i| #3 if i.parent.id == bar.id #4 output << i.parent.name end end ...

break out of a while loop from outside the loop
Hello, I have an application where I have some nested while loops. Is it possible to break the innermost loop from a control that is outside of the inner loop? My inner loop is running a scan and read operation on the serial port and is reading data as it somes in. I need this loop to break when the user presses a button located in one of the outer loops so that another section of the vi can execute. Thanks in advance. Greg Create a local variable to outer control and wire it in the inner post loop. When you set the value of outer control, the local variable accessed its value in the in...

Getting a loop to activate a loop above it
The following code will not work for me: x = 1 while x == 1: print 'hello' x = input('What is x now?: ') while x == 2: print 'hello again' x == input('What is x now?: ') The second loop dose not seem to be able to activate the loop above it.... Proof from my command line: $ python program-that-dose-not-work.py hello What is x now?: 2 hello again What is x now?: 1 hello again What is x now?: So, now I ask you: how do I make it work? Thanks in advance, -- /usr/bin/byte x=1 while not x==3: if x==1: print 'hello' ...

Converting a nested for loop to a while loop.
I am working on a problem where I need to convert a nested for loop to a while loop. I've got the problem partially solved but I was only able to get the code to initialize the first row of the Array. Where am I going wrong? Here is the initial code that I made for the for loop: A = [3 5 4;-8 -1 33;-17 6 -9]; B = zeros(size(A)) for i = 1:1:size(A,1) for j = 1:1:size(A,2) if(A(i,j) >= 1) B(i,j)=A(i,j)+20 else B(i,j)=log(A(i,j)) end end end Here is what I came up for the while loop: B = zeros(size(A)); i = 0; j = 0; while i < size(A,1) ...

Ending a while loop inside a while loop
How do I make a while loop run as long as the while loop that contains it is running? I tried wiring both conditional terminals to a stop button in the outer loop, but that doesnt seem to work? Is there another way? &nbsp; Thanks. It doesn't work because of data dependency. Once you are inside the inner loop the outer loop will not go to the next iteration until the inner loop is done. It sounds to me like you want parallel loops running, rather than one inside the other. If you open the Example Finder (Help -&gt; Find Examples), and search for "loops", open the examples called "Stopping Parallel While Loops". One has a reset, and one doesn't. Message Edited by smercurio_fc on 04-22-2008 04:55 PM Hi Jasonalan, I am not sure what you are trying to implement, but it is true that the loops are not terminating because of data dependency. The stop button in the outer loop will not be read until the inner loop terminates.If you wish to terminate the two nested loops using a single stop button, you should read the stop button inside the inner loop and wire it to the conditional terminals in both the inner and outer loop. Again, there is no point in doing this unless you have some other logic along with the stop button to stop the loops. If only the stop button is being used to stop both the inner and outer loops, the outer loop will only execute once. In that case, you can just use a sequence structure followed by a single while loop. ...

stop while loop when for loop finished
Hi everybody, &nbsp; I have a problem with the communication between a while loop and a for loop. The while loop is for data aquisition, the for loop ist to run a stepper motor. The stepper should move a&nbsp;specific number&nbsp;of steps&nbsp;clockwise and after that same number of steps counterclockwise. The user can determine the number of steps and the number of cycles at the front panel (one cycle consists of a clockwise and a following counterclockwise move). Right now I have a for loop (N is the number of cycles) and a stacked sequence, which contains two while loops again: first sequence with one while loop is for the clockwise move, second sequence with another while loop is for the counterclockwise move. I guess I have to put the VI's from NI Motion in a while loop as the motor doesn't move without it? &nbsp; Problem: I want to stop the while loop (data aquisition) when the for loop finished (when the desired number of cycles is achieved). I also want to stop the for loop when specific values in the while loop are measured. But how can I break a for loop? I have local variables (boolean)&nbsp;for the specific measured&nbsp;values, so I tried to put the for loop into a while loop (and wire the local variables to the stop button), but the for loop doesn't stop when the specific values occur. &nbsp; Can I solve the problem with any other loops? Suggestions are totally welcome! Thank you! &nbsp; &nbsp; &nbsp; Stef...

timed loop inside a while loop
Hi all, I want to ask if I have a timed loop inside a&nbsp; while loop ,&nbsp; the timed loop&nbsp; does a certain task &nbsp;a 100 iteration ( each time loop iteration is 2 second duration)&nbsp;each while loop iteration &nbsp;, at each&nbsp; while loop iteration the time loop writes the actual time spent to a text file for this certain task. &nbsp; for the next while loop, the timed loop contiues&nbsp; to write the time spent from the previous while loop ( ex the first while loop the time loop ends the last results with 200 second for a 100&nbsp; time 2 second duration ), the second while loop&nbsp; the time loop starts 202 and so on) &nbsp; I would like for the second time loop to restart&nbsp; and start&nbsp; again from 2 second and same for the third and foruth time loop ) &nbsp; &nbsp; attached is my program Thanks &nbsp; Maple &nbsp; &nbsp; labVIEW demod.jpg: http://forums.ni.com/attachments/ni/170/227754/1/labVIEW demod.jpg Hello yes , I will thnaks alot &nbsp; &nbsp; Maple Hi Ching let me put my question in this way, &nbsp; I have a timed loop, I want to run this timed loop&nbsp; to perform an action for 2 seconds 100 times, I want to&nbsp; write&nbsp; to a text file the time counter for these&nbsp; 100 action ( i.e.) starting from 2 till 200 , if I will&nbsp; put this time loop in a while loop to do the action twice, the timed loop starts&nbsp; writi...

For loop and while loop. which one is faster?
For loop and while loop. which one is faster? I see many articles fighting over it and different people come up with different results. mgcclx@gmail.com wrote: > For loop and while loop. which one is faster? > I see many articles fighting over it and different people come up with > different results. Unless you're designing a compiler, don't worry about that. Worry about the algorithms instead. That said, the only possible difference between a for loop and a while loop is the jump prediction in your architecture's code instruction set. e.g. the processor can suppose t...

"While" loop not looping
Hi there. Here is a snippet of code that creates binary matrices and checks to see if they have an inverse that is also binary. I use "ismember" to verify that each element in the inverse is either 0 or 1. Unfortunately, the "while" loop exits immedeately. Why? set=[0,1]; a=round(rand(7,5)); inverse=pinv(a); while ismember(inverse,set)~=ones(size(ismember(inverse,set))) a=round(rand(7,5)); inverse=pinv(a); pause(0) end a inverse TIA majb bourassa <bourassa-m@rmc.ca> writes: > Hi there. Here is a snippet of code that c...

Web resources about - loops in loops - comp.lang.labview

iPhone, iPad, Mac, Apple opinion and news - The Loop
The Loop provides comprehensive and insightful news, editorial, and commentary on iPhone, iPod, Macintosh, associated third-party software and ...

Eschborn-Frankfurt City Loop - Wikipedia, the free encyclopedia
The Eschborn-Frankfurt City Loop (until 2008 Rund um den Henninger-Turm , sometimes called the Frankfurt Grand Prix in English; in 2010 Rund ...

Apple’s March 21st ‘Let us loop you in’ event is official: 4-inch iPhone SE + 9.7-inch iPad Pro & much ...
Apple has officially announced its upcoming spring event ( via @tim ) scheduled for March 21st in Cupertino at Apple’s 1 Infinite Loop campus ...

Big rig rollover backs up East Loop SB before Port of Houston
An accident involving a jackknifed 18-wheeler has backed up traffic on the 610 East Loop southbound before the Port of Houston.

Apple plans to 'loop you in' at March 21 event with expected new 4" iPhone, 9.7" iPad
Apple Insider Apple plans to 'loop you in' at March 21 event with expected new 4" iPhone, 9.7" iPad Apple Insider Apple on Thursday officially ...

Let us loop you in: What to expect from Apple’s March 21 event
Apple CEO Tim Cook takes the stage at the company's September 2015 product event. (credit: Andrew Cunningham) Apple's having an event next Monday. ...

David Beckham has spent his retirement watching ‘Frozen’ on a loop with Harper
While David Beckham has never made my Top-Ten Crushes, I’ve always sort of liked him. I like him even more these days, as we get to see him more ...

Apple sends invites for March 21 event with clue 'let us loop you in'
A 4-inch iPhone and an updated iPad are among the new products expected to be announced.

Apple’s March 21 event promises to ‘loop you in’
Apple has confirmed the date of its next keynote event, which will take place on March 21 in Cupertino, California. Invitations to the event ...

Loop.pH's colour-changing BMX installation reflects air quality
Conceived as a pair of "lungs" connected by two looping cycle tracks, Loop.pH's VeL02 lighting installation changes colour according to air quality. ...

Resources last updated: 3/19/2016 10:51:09 AM