LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing issue with while loops.

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

I may not be perfect, but I'm all I got!
Download All
0 Kudos
Message 1 of 13
(3,758 Views)

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

I may not be perfect, but I'm all I got!
0 Kudos
Message 2 of 13
(3,756 Views)

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

Message Edited by GerdW on 12-29-2009 06:18 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 13
(3,753 Views)

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

I may not be perfect, but I'm all I got!
0 Kudos
Message 4 of 13
(3,745 Views)

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

Message Edited by GerdW on 12-29-2009 06:40 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 13
(3,742 Views)

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

I may not be perfect, but I'm all I got!
0 Kudos
Message 6 of 13
(3,736 Views)

Hi V,

 

yes, use the "wait (ms)" function! And don't forget dataflow, so encapsulate it by a single frame sequence and wire the error cluster through the sequence. Or make your own function (as described above). 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 13
(3,733 Views)
Message Edited by VeeJay on 12-29-2009 12:02 PM
I may not be perfect, but I'm all I got!
0 Kudos
Message 8 of 13
(3,731 Views)

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

I may not be perfect, but I'm all I got!
0 Kudos
Message 9 of 13
(3,723 Views)

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 Smiley Wink (first frame: wait 250ms, 2nd frame: do your subtraction)

 

Why shouldn't you use a tickCounter outside the while loop?

Message Edited by GerdW on 12-29-2009 07:09 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 13
(3,716 Views)