LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview 2017, Loop structure crushs after hours with no message or warning

Solved!
Go to solution

Greetings.

I wrote a subVI and come across a problem. I hope someone will help me. Here is the problem:
I used the the subVI which can be found in the reference, to show DAQ chart.
I used for loop at first, and copied it twice and changed one of them into while loop structure(just for testing).
I run the subVI and press 3 start buttons and the 3 charts run fluently at first. But after hours (8 ,9 or maybe even longer), some of the loop just stop with no message or anouncement. But other loop still run well.

At the same time. The VI seems crush and i can't stop it use the stop button.

I monitored the memory used by the program. And it did not increase while it was running.

Will it be the bug of Labview2017?

Anyone can help me with this, thanks a lot.

0 Kudos
Message 1 of 12
(2,636 Views)

Anyone?

0 Kudos
Message 2 of 12
(2,610 Views)
  1. Do not "bump" your post, it is not polite
  2. If you attach a VI, use regular English characters in the VI name, I could not open your VI, only after renaming it
  3. Your VI does not make too much sense to me.
    1. What is your goal? Why do you use a Timed loop on Windows at all?
    2. You have a FOR loop in the Timed Loop, with a 4 sec delay...why???

Maybe if you describe what you want to do, we can suggest something...

Snippet of your VI below for those who cannot open your VI (False case is empty):

 

problem1.png

0 Kudos
Message 3 of 12
(2,602 Views)

@TEDDD wrote:

I used the the subVI which can be found in the reference, to show DAQ chart.


Whatever you have attached does not look like a subVI. Can you attach the entire project?

 


@TEDDD wrote:

I used for loop at first, and copied it twice and changed one of them into while loop structure(just for testing).


Why don't you attach the actual code. You provide insufficient information on what you changed or why.

 


@TEDDD wrote:

I run the subVI and press 3 start buttons and the 3 charts run fluently at first. But after hours (8 ,9 or maybe even longer), some of the loop just stop with no message or anouncement. But other loop still run well.

 


Which 3 buttons? I only see one button. Which "other loops"?

 


@TEDDD wrote:

 

Will it be the bug of Labview2017?

Anyone can help me with this, thanks a lot.


No, there is probably no bug in LabVIEW. If you want help, you need to show all the code so we can try to reproduce. Also try to do a few more tutorials, your coding shows very little experience, for example: Overuse of local variables for no reason. Virtually all controls have incorrect representation. Your built array before the graph has no purpose. The timed loop makes no sense. Are you sure you selected the correct mechanical action for the button? Your cluster order is incorrect, time should be on top. You should convert x to seconds for simpler markers. etc. etc.

0 Kudos
Message 4 of 12
(2,586 Views)

Sorry. This is the first time i asked a question and I posted the wrong VI.
Forget i said the 3 loop thing. I repost my VI
This part is part of my program. I delated the others just to make it easy to understand. Because , this is the part went wrong after running for several hours.
I wrote the program to show the DATA charts , in which values acquiring from other Loops, which i didn't post.
I used local variables to transmit values between each loop.
You press the start button. U can see what is going on.
My problem is i used Version2017 to run it. After hours, the loop just stop with no warning.


1.I used the timed loop, to start or stop show the chart anytime i want.
2.the 4000 is the Max No. for the array. when the array have 4000 element. I clear it, so the chart clear.

0 Kudos
Message 5 of 12
(2,564 Views)

Thanks for you replying. Sorry for my wrong describtion.

Forget about the 3 loop thing and subVI thing. I posted the wrong VI. 

I repost a part of my program in the reply above . I used the local variables to transmit realtime Value between loops. 

I did not post all the loops. So you may question about the local variables thing.

I tried just this part of the program and it  went wrong.  It just stopped with no sign. After running for hours.

 

 

 

0 Kudos
Message 6 of 12
(2,555 Views)

I strongly suggest to take some basic LabVIEW tutorials/trainings.

Just some comments:

  1. You misuse local variables. I guess the deleted part of your code contains places where you update those indicators. Do not use local variables, use wires and shift registers to pass data between the main loop iterations!
  2. "I used the timed loop, to start or stop show the chart anytime i want. " Sorry, this does not make sense to me. Do not use Timed loop, use a simple While loop. Since I do not see the other part of your code (where you have HW functions I guess), I cannot recommend more detailed solution.
  3. "My problem is i used Version2017 to run it. After hours, the loop just stop with no warning." I have no idea why your Timed Loop hangs after a few hours. I see lots of bad design in your code, several things can cause this behavior, still I cannot comment further without seeing the whole VI...

EDIT: so stop using Timed Loop, and eliminate the local variables. You should also have a look at the Producer-consumer patterns, and State Machines might help too...

0 Kudos
Message 7 of 12
(2,553 Views)
Solution
Accepted by topic author TEDDD

You need some LabVIEW training.  What you have shown here contravenes a number of programming best practices.  That said,

 

1) Timed loops are intended for applications which require determinism.  On Windows, which is a pre-emptive operating system, you can't count on that anyway.  As such, timed loops provide no tangible benefit over while loops using ms timing functions to determine execution rate.  Also, timed loops necessarily inline any code within them, defeating programmed parallelism.

 

2) LabVIEW uses a dataflow model for code execution and dependency.  Your use of local variables in this VI is bad programming practice.  Local variables are intended to write to or read from controls and indicators when dataflow (wires) cannot be used, such as between parallel loops, and even then, there are often better ways.

 

3) You have a wait function, in a FOR loop, within a timed loop, which makes no sense. 

 

4) You are dynamically increasing the size of four different arrays every iteration of your FOR loop, and recreating those arrays every iteration of your while loop.  Instead, preallocate the arrays outside the loop, and use the replace array subset function to dynamically replace elements without forcing the memory manager to find space every time.

 

5)  You are graphing a discrete length array which you are building each iteration.  Try using a chart instead, in which case you need only wire the latest data point, and can control the displayed history length via the chart properties.

 

6) Your timed loop is attempting to execute deterministically every 10 ms, on a non-deterministic operating system, with contained code which is explicitly delayed by DAQ_Count * a delay value.  Your timed loops are likely all executing late.  Remember that the Windows clock does not provide access to timing at resolutions finer than 1 ms.

 

7) You are overwriting your graph on every iteration of the FOR loop.  Is that what you intended?

 

The most likely source of the problem is the dynamically built arrays.

 

 

Message 8 of 12
(2,544 Views)

Thanks for your patient.  

I wrote the whole program to control a motor and a Hybrid transmission and some testrig equipment. 

according to your sugguestion:

1. I used paralleled loops to achieve different function and use local variables to transmit values between each other.   Sure .Using wires will save memory. But  i got too many subfunction to be complete. For example, Chart,  automatic step, mannual control, warning function,recording function.  And there are too many variables too. I know there are some delays, but use the local variables make it easier to do that and save programming time. And i didn't get other good ways to do so.

2. Thanks for your sugguestion . Acturally, i don't know the difference between with timed loop and While loop added dalay time.  I will try to use While loop next time.

3. I'm trying the same code in Version2012, and it runnng well till now. I  don't know if there is something wrong with 2017.Or, i misinstalled it,  maybe because my version is for 32bit PC, and my computer is 64bit PC. But the 2012version is for 32bit PC ,too.

 

I'm still testing the code with 2012 version to see if it will crush after hours too.  

 

Thanks for your help.

0 Kudos
Message 9 of 12
(2,529 Views)

Thanks for your time and a lot of good advice. For your point, my replies are as below:

1. I will try while loop next time.

2. I have to achieve too many subfunctions. what you see is just a small part of the program which come across the problem i said.

3.the wait function works for the For loop , different from  cycle time of the timed loop.

4. I used array build VI

5. That's a good idea. I will try that.

6.10ms is not the cycle time what I try to run a loop. It just limited the min time for the loop. Because  for time for For loop is way much longer than 10ms. Maybe using the while loop instead can be unstand more easily.

7.right. I just want to show a determined count of data on the chart.

 

Dynamically built arrays sure not a good way. I will try something else.

 

But in this case, maybe there is something wrong with my labview2017.  maybe i did now installed it right, or  compatible problem with my PC system. I'm now testing the same code with labview2012. It is running for 6 hours now, and have not come across the problem. I will test it till tomorrow to get a further conclusion.

 

 

0 Kudos
Message 10 of 12
(2,524 Views)