12-29-2009 11:06 AM
Hi Guys,
Off late, I have been experiencing problems with nested while loops. My inner while loop (basically a wait funtion plus a time difference calculator between current and previous iteration) waits for atleast 250ms to allow the processing of functions on the outer while loop. So, my excel file that has the end details of the program has a "Time interval" column that must have a constant 250ms or 0.25s value. But, what I notice is that occasionally, there are values above 250ms like 300ms 313ms and so forth. These appear as spikes (on the y-axis) on my waveform.
The computer we use for the instrumental setup was a slow one, so we formatted it and added an additional 0.5GB RAM totalling it to 1GB. But, the computer is still slow to start LabVIEW and other programs. Now, would you think that the processing speed and the memory availability of the PC will affect LabVIEW in anyway? Is the reason I am not getting constant time intervals is because LabVIEW hangs up for a while due to inadequate resources on my PC? I would like to hear you opinion on this. I am attaching 2 excel files with data. Please refer to the Time interval column.
Thanks!!
V
12-29-2009 11:13 AM
Oh! And one Excel file shows wait time as 250ms and the other shows wait time of 100ms. Thats because I had varied the wait times from 50ms to 1s to see if there are any additional spikes.
V
12-29-2009 11:16 AM - edited 12-29-2009 11:18 AM
Hi Veejay,
instead of showing timing results it would be far more interesting to see your waiting loop construct...
So attach your vi (or a stripped version)!
When your vi runs on a standard Win OS you will never get exactly the timing you want - it's up to the OS to ensure processing time for all tasks!
You may also try the timed while loop or the standard timing functions of LabVIEW...
One more hint:
Using simple text files would save a lot of bandwidth, when you only want to show that timing column. Zipping xls files may work too...
12-29-2009 11:32 AM
Agreed ! 🙂 The vi is too big to attach, I want it to be focussed. Hence, I am attaching the part that has the waiting construct. Please let me know if this info is useful. I am trying to debug this large program written by another person and it has just been a while since I have started on LabVIEW.
Thanks!
V
12-29-2009 11:39 AM - edited 12-29-2009 11:40 AM
Hi V,
OMG!
Why not simply replace the whole while loop with a "Wait" function set to wait for 250ms?
Remarks:
- The whole loop is running as fast as possible just to check the current time... It wastes CPU power without any reason.
- It does exactly what the comment says: waiting atleast 250ms!
- Make your own Wait function with an error in/output, so you don't need to place a single frame sequence around it to ensure dataflow...
And again:
On WinOS (and others) you will not get exact timing. It depends on what other tasks are running in the background...
12-29-2009 11:46 AM
I know. This seems futile. I have tried removing the while loop inside the flat structure sequence, but maybe I did it wrong. The reason I left it is because there is a "subtract" function that calculates the time difference inside the loop. Do you think I can use the "wait (ms) " function under Time category instead of the while loop? Or am I missing something here.
Thanks!
VeeJay
12-29-2009 11:49 AM
12-29-2009 11:52 AM - edited 12-29-2009 12:02 PM
12-29-2009 12:01 PM
Sorry! I was typing the next message while your reply came in. Anyway, I understand now, but the only thing that bothers me is the Tick counter outside the outer while loop. Can I still use that?
VJ
12-29-2009 12:08 PM - edited 12-29-2009 12:09 PM
Hi V,
use a sequence with several frames instead. It's the best you can do using the standard timing functions, but you already know my remark on making own versions with error in/output (first frame: wait 250ms, 2nd frame: do your subtraction)
Why shouldn't you use a tickCounter outside the while loop?