LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best practices: Adjust Reentrancy of VIs with memory

Hello,

 

I am working on a parametrized data processing project with multiple input / multiple output signals, all configurable by user. I want to repeatably use VIs that have their own memory (e.g. filtering or resampling). The problem emerges when I want to use filtering of array of signals inside a SubVI as the actual VI that does the math has memory for only one channel so it mixes up data. This is common concern with classes as you usually have array of objects and one method of its class does the processing on a property. And you want to do the processing on multiple objects.

 

How I usually solve it:

  • Hardcode the number of signals by copying the VI (not the case for objects).
  • Some VIs (Like Resample Waveforms) also accept array of waveforms, which kind of helps but renders unusable if the array is indexed before this VI.
  • Rewriting every needed VI so that all the inner shift registers are outputted on each iteration in a cluster. Then I handle the behaviour myself by putting in the correct memory cluster every time. (Ouch!)
  • Writing the processing alg on my own.

I included a simple illustration of my problem. Top VI:

VitSlaby_3-1666596502267.png

 

 

SubVI:

VitSlaby_1-1666596208078.png

Do you have any other ideas? Is there any approach that should be noted? I feel like classes could theoretically have some kind of behavior that isolates the VIs in their methods so that they are clones for each class instance, but I don't know about such feature in LabVIEW.

 

Thanks

0 Kudos
Message 1 of 3
(928 Views)

Reentrant VI's should not have internal memory for the reasons you've found out.

So:

- "Rewriting every needed VI so that all the inner shift registers are outputted on each iteration in a cluster. Then I handle the behaviour myself by putting in the correct memory cluster every time. (Ouch!)" is a correct solution

- Make it a class so you have your unique memory (i think that'd work)

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 3
(898 Views)

Here's a thread I remembered that discusses the use of VI Server (and possibly also parallelized For Loops) to do this.

 

To make a tidier package with unique parameters per channel, you could make a "channel" class that holds a waveform, a VI ref, and any other needed parameters for processing.  The class would have a "process data" function that would use VI Server to call the function while passing in the waveform and processing parameters that the "channel" object carries.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 3
(853 Views)