08-19-2009 02:40 PM
An 'iteration' is the number of times that a loop operates.
If the loop runs 5 times, you could say that it iterates 5 times.
The little blue 'i' is the current iteration, just so you can keep track in your code.
Now to do what you described, "saving every n seconds" you will need a little bit of code for timing.
Unless told otherwise, a While loop will run as fast as it can, until the Stop condition is met.
You should put a Wait function in the loop, to control data aquisition timing.
So if you put a Wait in the loop and wire 1000 to it, it will wait 1000 ms (= 1 sec) before taking another data point.
If you wanted to save every 10th point, you would do the code I showed before.
So the data in the file would show 0:10, 0:20, 0:30, etc.
You can change the aquisition rate by changing the Wait time,
and you can change the saving rate by changing the 'Variable' input.
08-19-2009 03:04 PM
Don't stack while loops. The inner whil loop will prevent the outer while loop from spinning.
Just use the elapsed time express VI (configured for auto reset and your desired interval) and connect the "elapsed?" output to a case structure in the big loop.
08-20-2009 11:08 AM
So I moved the while loop (the one inside the large one) outside of the large one, and now the graph moves, but the loop still does not iterate at the proper times.
I have a "wait" VI hooked up to a number control (as shown in my block diagram) but that does not do anything, neither does the Boolean switch I put on there, I ran the VI, and canceled it without pressing the "save" button, but it still saved a new file, so I suspect that the loop iterates one time, no matter what, and that my switches and controls actually do nothing.
Is there a reason my switches and whatnot don't do anything?
08-20-2009 11:19 AM
08-20-2009 11:28 AM
08-20-2009 11:34 AM
The string wire between the two loops forces the the second (logging) to wait until the other loop is done.
Please take a look at the Producer/Consumer design pattern to see how a Queue can be used to pass the data between your loops.
Ben
08-20-2009 11:40 AM
I looked at the consumer/producer page, and I see how it 'works' but I don't really know how I can apply it to my VI, I mean, I see how I could, but I don't know how.
Would I have to esentially start from scratch to make it work?
08-20-2009 11:56 AM
Complete re-write, no.
0) Toss the wire between the loops. It will be replaced by a queue.
1)reate the queue prior to the two lops and pass the queue ref to both loops. The two llops will not start until they get the ref.
2) In the producer use an enqueue function que-up the dat coming out of the Index array".
3) Use a Check queue status in the consumer (logging) and if more han one entry found then use dequeue element to get the data.
Re:#3
If it is not time to log a value then don't do anything with what came out of the queue. If it is time, then log it.
Backup what you have, try what I described and then post back with new images so we can coach you through the next challenge.
Ben
08-20-2009 12:10 PM
08-20-2009 12:13 PM
I didn't really understand steps two and three.
In step two, did you want me to link the data coming out of the 'Index Array' VI into the queue? (Instead of whatever I have)