From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Weird behavior of feedback node in sub-vi

Solved!
Go to solution

Hello!

 

I try to implement the low-pass filter sensor reading and it worked well while it was part of main VI. As soon as this part was moved as Sub-VI, the behavor became messy. From what I see, it looks like it has always 0 as previously calculated value instead of remembering.

 

Is there any hint, where to dig to fix it?

Capture.PNG

 

 

 

0 Kudos
Message 1 of 27
(2,097 Views)

Hi Ye,

 

maybe because you initialize the feedback node every time?

 

(Your main VI uses way too many local variables IMHO -  and too many IndexArray nodes…)

 

Suggestion:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 27
(2,080 Views)

What do you mean "initialize every time"? It is set to be initialized at first call.

 

I don't see how your suggestion is different from mine. Or you want to say to return the feedback node to the main vi?

0 Kudos
Message 3 of 27
(2,067 Views)

Hi Ye,

 


@YePererva wrote:

What do you mean "initialize every time"? It is set to be initialized at first call.


But there are several calls of that VI…

 


@YePererva wrote:

I don't see how your suggestion is different from mine. Or you want to say to return the feedback node to the main vi?


My version doesn't need the formula node.

And I would use feedback nodes in the main VI to get rid of all those local variables…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 27
(2,049 Views)
Solution
Accepted by topic author YePererva

The subvi is tricky. Sinve you have a feedback node and calls the VI in 3 places, you'll get the wrong feedbacked value for the next call. It should fix itself if you change it to Reentrant Preallocated mode.

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

Qestit Systems
Certified-LabVIEW-Developer
Message 5 of 27
(2,042 Views)

Needed to edit sub-VI properties:

1. Open Sub-VI

2. Go to its properties (Ctrl+I)

3. Switch to category "Execution"

4. Select  "Preallocated clone reentrant execution"

5. Save

 

After that it worked properly.

 

Regarding the local variables: those are additionally used in other places of VI. 

0 Kudos
Message 6 of 27
(1,949 Views)

I must be missing something. Where is this "Reentrant Preallocated" setting?

0 Kudos
Message 7 of 27
(1,907 Views)

Hi Ye,

 


@YePererva wrote:

Regarding the local variables: those are additionally used in other places of VI. 


Then you should reconsider your overall program design…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 27
(2,015 Views)

It's a kind tip from us that will improve your programming skills to not use (local) variables. Much easier to read the code and less bug-prone. Think dataflow! 

Certified LabVIEW Architect
0 Kudos
Message 9 of 27
(2,006 Views)

Probably, that will be done after introducing all the functionality I need. As of now, this is still a "functional prototype under construction".

 

P.S. Please, explain how does use of local variables compromise the data flow?

As I understood, the main part responsible for dataflow in such application is the state machine and connection between states. In NI course(s) there is a strong suggestion "one state - one function". So, in this case I have several states: "Data acquisition" (reading of 7 sensors, but there will be a few more latter ), "Statistics" and "Data filtration/noise suppression", where extra calculations are made. Usage of local variable seems to be the proper way of passing data between those stages. What is wrong with that?

0 Kudos
Message 10 of 27
(1,900 Views)