LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does one while loop stop after 3-4 weeks?

I have a fairly large vi that has about 16 parallel while loops. These read from serial instruments every 5-20 seconds, write data to log files every few minutes, look for button presses, communicate with a FieldPoint unit, etc. I am using LabVIEW 7 running under Windows XP Professional. One particular while loop, which communicates with a serial instrument, has stopped twice after the vi has been running for 3-4 weeks. All the other while loops continue to execute. The loop that stops has a Boolean constant wired to its loop condition so it should not stop until a different loop halts the vi execution. I am not getting any error messages or other indications of failure. The vi and the system in general are not slowing dow
n or showing any other bad symptoms. The only indication that the loop has stopped is that the reading from one instrument is not changing. The instrument itself seems fine, and I am not getting any communication errors. I could program some kind of watchdog to detect when this loop stops, but I know of no way to re-start the while loop without stopping the vi and re-starting it.
Any ideas on what might be causing this and how to prevent it? The vi is about 2 MBytes, but I can post it if needed.

Rich
0 Kudos
Message 1 of 14
(3,878 Views)
Hello,

There should be some boolean condition at which the loop can stop, once the loop has stopped for some conditon, it cannot start until you start the program again, so you can put all the loops in another main loop

Try to minimize the loops as much low as you can, as it can cause to slow down the PC's performance
preferably put all the code in one loop

I would also be happy to take a look at your existing code and offer further ideas
if you have any more queries you can zip your code and attaache here Have a great day.
Regards
mathews
0 Kudos
Message 2 of 14
(3,878 Views)
Rich -

It is difficult to pinpoint the problem without the exact code, but the development library offers a number of LabVIEW resources which thoroughly discuss loops. Click here to access application notes, tutorials, example code and presentations.

Good luck with your project. Have a great day!

Becky B.
Applications Engineer
National Instruments
Becky Linton
National Instruments
Field Engineer
Office: 734-464-2463
Cell: 248-709-2822
Email: becky.linton@ni.com
0 Kudos
Message 3 of 14
(3,878 Views)
The VI stops after 3-4 Weeks you say? This sounds familiar. Do you have a Timer(ms) function in this VI coupled with the stop criteria of the loop? The ms counter is an U32, which can hold max. 4294967296 ms, which equals 49.7 days. Note that the counter starts immediately when the computer is bootet (if I remember correctly).

This counter will "wrap" every 49.7 days possible causing timing problems with your VI. If you're coupling a Wait(ms) with a check whether a certain amount of milliseconds have passed since the last iteration, this may lead to a condition where your elapsed time is a lery negative number, possibly eliminating the possibility of the VI sending more data.

Again, it depends on how your VI is set up.....

Hope this helps

Sha
ne.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 4 of 14
(3,878 Views)
I am using the "Wait Until Next ms Multiple" to time the loop, and the loop stop condition is a Boolean constant. I remember hearing about some problems with these ms counters a long time ago, but I thought that they were fixed in recent versions. Does the "Wait Until Next ms Multiple" function work properly when the timer wraps? I don't care if the timing is a bit off, so long as it continues to function.

Rich
0 Kudos
Message 5 of 14
(3,878 Views)
Maybe it is time to post an example.

Do have a resonalbe "time Out" specified for your read?

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 14
(3,878 Views)
OK, I have attached a simplified version. The loop colored orange is the one that has stopped twice after running for weeks. Timeouts for the serial reads are 1-4 seconds.
0 Kudos
Message 7 of 14
(3,878 Views)
Hi Richard,

As a quick test to rule out the following, could you pull the serial cable being used by this loop?

Just pull it and verify this loop does not hang.

If it does hang post and I will explain my theory. Its not worth troubling you with the details without knowing the answer to the above.

Trying to help,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 14
(3,878 Views)
No, the loop doesn't hang if the cable is unplugged. The Error LED comes on, but the other loops continue. When the cable is plugged back in again, that loop starts communicating again.

Rich
0 Kudos
Message 9 of 14
(3,878 Views)
Wow!

The only other thing I can think of is way out there.

If there was sufficient noise on the serial line, it could look like a continual stream of data that will prevent your timeout logic from running.

This would show up in your accumulator string indicator.

So, the only thing I suggest at this time is to check the length of the string in the accumulator when it is in the hang condition.

This would also mean that you could "un-hang" the loop by pulling the cable while hung.


Trying hard to help,

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 14
(3,878 Views)