LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting all data after loop iteration.

Solved!
Go to solution

Hi guys.

I have a problem with my project.

The project is functional and I need to create a .exe.
I would like to set this program that if the exe file is opened by the user, the user will be given instructions by "One button dialog" by pushing button. Everything works OK but ... First time after push "OK" "main part" takes about 22 seconds. Next time push "OK" "main part" takes about 28 seconds ... and more and more and more.
I assume I accumulate data from individual iterations but I do not want it.

When the "main part" is finished, it shows data and graphs on the front panel, but when I start "main part" again I need clear all data from the last run (only my assumption, because I think this slowing is caused accumulate a data).

Thank you very much for your help.
JJ.

0 Kudos
Message 1 of 16
(3,177 Views)

I doubt anyone will be able to help you with this picture and I can't see anything obvious that would cause successive iterations to go slow (such ass accumulating data). If this is issue is present both in Labview and the executable, you can use Tools >> Profile >> Performance and Memory in Labview to see which VIs are taking the most time. This might help you track down the issue. See https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LT1SAM

 

If it only shows up in the exe, you'll have to put your own timing and debugging information in the VI (for instance, you can use High Precision Resolution Relative Seconds.vi to measure the time right before a vi runs and then again right after and subtract the two numbers to find the elapsed time.

 

I would think the issue is with the SubVis and not the top level vis based on the picture. Alternatively, it could be with the hardware if those VIs call hardware in some way. If there is a large amount of memory being accumulated, you would see it in task manager in Windows. However, it would have to be a lot of memory to take seconds. Probably at least 10s of megabytes every iteration.

0 Kudos
Message 2 of 16
(3,133 Views)

Your VI is full of race conditions, so all bets are off. We also cannot tell what's happening in any of the subVIs or in the other cases of the case structures. (Attaching all code would help). There are also coercion dots that should not be there.

 

Implementing a proper state machine would probably be recommended anyway.

 

The first things I see of course are glaring race conditions. All your "reinit to default" nodes execute in parallel to the sequence structure and there is no way to tell what happens last and determines the final indicator values.

0 Kudos
Message 3 of 16
(3,130 Views)

You do realize that the While loop you show is actually running in parallel with the dialog, right?  There is no data dependency.  And then we get into the question of what is happening in the FALSE case and what the mechanical action is of that OK Button.

 

And why do you have an infinite loop?  You should have some way to gracefully stop that loop and shutdown your application.

 

Can't say much more without seeing what all is happening inside of those subVIs and being able to dig around the code.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 16
(3,125 Views)

Hi.

Sorry. Here is all my project.

0 Kudos
Message 5 of 16
(3,121 Views)

Some initial comments:

  • If the OK button is not pressed, your VI uses 100% CPU, spunning the loop millions of times per second and starving all other processes running on the computer (see also).
  • As already  mentioned, there are glaring race conditions.
  • Apparently you are not familiar with autoidenxing (index array wired to [i] Is (almost) the same as autoindexing. (switch control, smaller FOR loop in toplevel, etc.)
  • Do you really need to create new but identical virtual channels over and over and over ...? Do you ever close any of them? (Sorry, I don't have DAQmx installed here). 
  • Can you narrow down where the slowdown is?
0 Kudos
Message 6 of 16
(3,100 Views)

@altenbach wrote:
  • Do you really need to create new but identical virtual channels over and over and over ...? Do you ever close any of them? (Sorry, I don't have DAQmx installed here).

He closes most of them.  But I hold that you should only be opening those tasks once before any testing, stop that main loop when the user is done, and close all of those tasks as part of the cleanup.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 16
(3,090 Views)

Repeatedly creating and destroying DAQmx tasks will leak memory.

 

Are there charts that could be accumulating data?

 

What does Task Manager show about PCU and memory usage?

 

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 16
(3,085 Views)

Hi altenbach.

Thank you for you advice.

 

1) Yes. I know it. I tryed this code with wait 100ms - 1000ms. But there wasthe same problem.

2) I Add "frame structure before" for my nodes. I am using this nodes for clear all indication elements on front panel before next "test run"
and too I add stop button for while loop.

3) My fail :-). I know it but I do not have such an overview and sometimes I make things more complicated. I have labview first semester.

4) I have a 4 test run "in one click START BUTTON". In test run I create needed chanels and at the end i close all chanels (I think).

5) This is my problem. I dont know :-/. I can send you profile performance and memory.

(sorry ... I cant post profile performance and memory here on forum becouse invalid extension, I can give you only screen)

0 Kudos
Message 9 of 16
(3,080 Views)

Hi crossrulz

Hi Ben

 

Thank you.

Clossrulz I think it is very good advice but as you can see I use lots of channels and I'm not sure If it is best way. After every step of  measuring, I always use data for calculation and display and then quit the channel.

I have no idea of the behavior of the program (and all SubVIs) if all of these tasks were start only once outside the main loop.

I hope there will be better way :-(.

 

Ben 

Yes in my program are charts and arrays.
Do you think Is there a right way at every start VI/SubVI clear all every arrays and charts by property node? Or something like that?

When I use a 200ms Wait in while loop my task manager is absolutly OK ... CPU 5-20% , Ram 5-30% ( but I use other applications at the same time).

 

Thank you for your effort!

 

Edit: Or is there different way how to make required interface with the user without this while loop ?

0 Kudos
Message 10 of 16
(3,071 Views)