02-28-2023 05:27 AM
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?
Solved! Go to Solution.
02-28-2023 06:23 AM - edited 02-28-2023 06:25 AM
02-28-2023 06:41 AM
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?
02-28-2023 07:05 AM
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…
02-28-2023 07:16 AM
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.
02-28-2023 07:25 AM - edited 02-28-2023 08:00 AM
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.
02-28-2023 07:26 AM - edited 02-28-2023 07:31 AM
I must be missing something. Where is this "Reentrant Preallocated" setting?
02-28-2023 07:40 AM
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…
02-28-2023 07:43 AM
02-28-2023 08:35 AM
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?