LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Code slowing down (how to reset the cache/LabVIEW)?

Solved!
Go to solution

Hello all,

This is what my code is doing. I have data coming from a PSD that comes in every second. This is in the form of intensity that then is put through a lock-in amplifier to remove some of the noise. I set this loop to restart every 2 seconds because I only really care that my data is consistently taken every 1/2/3 etc seconds. I need to run a FFT later so I need consistent time differences.

 

The issue with my code. It runs perfectly for the first few hours but then begins to slow down. I am not sure why this happens if its a memory leak or something is being cached and not removed. Is there an option to reset the program or automatically close/ open the vi? I have looked into it, but haven't found a solution

 

Also, this wouldn't be that big of a deal because I could just end LabVIEW and setup am automation program to restart it. The issue with this, is when I stop the VI it freezes and I have to use taskkill to close LabVIEW . After that, if I try and launch labVIEW it will just hang and never launch. The only option is to restart the computer which would be difficult to automate.

Download All
0 Kudos
Message 1 of 5
(1,092 Views)
Solution
Accepted by topic author kdolghier

You forgot to attach some subVIs so the problem could be e.g. inside "referencebuilder.vi". Sorry, I don't have drivers, so most subVIs are missing.

 

Do you really need to create a virtual channel and configure timing with every iteration, then never close it??? Maybe that belongs before the loop. If you continue to create new virtual channels and never close the old one, you run out of resources!!!! I am sure that's what happening!

 

One glaring issue is also the overuse of express VIs and dynamic data. Look at all these coercion dots! Execution order is fully determined by dataflow, there is absolutely no need for the sequence structure!

 

If you just want to append simple rows to a text file, it is more lightweight to open the file once, then append using simple primitives.

 

Here is a quick draft that might give you some ideas....

 

altenbach_0-1676158627814.png

 

 

Message 2 of 5
(1,064 Views)

Thank you very much for this assistance. As you can see I am definitely a novice here.

I implemented the appending text save method you described and it seems like it works. I also moved the DAQmx Create Channel VI to outside of the loop as you can see. I am assuming that is the vi that you referred to as creating new virtual channels? (I am not absolutely sure that this is the correct vi you were referring to).

 

Also a few specific functions that I couldn't find:

- The function to the left of the "Array to spreadsheet" function. It looks like build array, but I couldn't find it.

- Also, I tried to implement the "In place Element Structure" within the for loop as you showed, but i couldn't fund that array function to the left of it. If I used the Index Array function that I currently have, it didn't work.

- Lastly, I could not find that orange function to the right of the relative seconds vi.

 

I am using labview 2018 SP1, so there is a possibility those vi's aren't a part of this version?

 

Also I replaced the referencebuilder.vi with its subvi's instead.

0 Kudos
Message 3 of 5
(1,034 Views)

@kdolghier wrote:

Also a few specific functions that I couldn't find:

- The function to the left of the "Array to spreadsheet" function. It looks like build array, but I couldn't find it.

- Also, I tried to implement the "In place Element Structure" within the for loop as you showed, but i couldn't fund that array function to the left of it. If I used the Index Array function that I currently have, it didn't work.

- Lastly, I could not find that orange function to the right of the relative seconds vi.


  • Its a plain "build array". If you wire an array and a scalar, it will append. (The look changes automatically).
  • For the inplace element structure, create an "add waveform unbundle/bundle" edge node. (right-click on edge, then pick the [Y] element.)
  • High resolution relative seconds from the timing palette..

 

(Sorry, I am on a different computer, so I don't have the code)

0 Kudos
Message 4 of 5
(1,006 Views)

@kdolghier wrote:

Also I replaced the referencebuilder.vi with its subvi's instead.


A few more comments:

 

  • I think the timing config also belongs before the loop. It only belongs inside the loop if you actually want to change its controls during run. I that case, the "samples per channel" control would also belong inside the loop.
  • If you want the elements in order for "index array", you don't need to wire the indices. Less clutter and less chances to make mistakes. (In contrast, for "delete from array", you need to wire zero to get the first element, else it will get the last element if the index is unwired)
  • What's the point of the dangling Hilbert transform. It is dead code because you never use its outputs.
  • I don't think you need to create the sine wave, you can export it from the single tone detector (See image draft below). I assume the first signal is the excitation. Don't you know that from elsewhere?

 

altenbach_0-1676219334394.png

 

On a side note, please make the front panel a reasonable size and get rid of all that blanks space between the controls.

 

0 Kudos
Message 5 of 5
(992 Views)