01-14-2023 03:59 PM
Mean PtByPt VI, when wired with a Control Sample Length, does not work within a sub VI
In the pic below, both method of Mean PtByPt would work if I run this subVI directly (i.e., do not call it from other callers).
However, If I call this Cal_CountNoises.VI (attached) from other callers, the upper method (in pic) with probing #97 does not work (the array out is exactly the same as Array In).
Please help? I do not want to use the 2nd method when my Sample Length input can have many more possible values.
Solved! Go to Solution.
01-14-2023 04:03 PM
Please note that when calling from other callers, I probed #99, and in my example, probe #99 value is 7, and probe #97 gave me exact value as Array in.
01-14-2023 04:21 PM
I found out that if I call that sub VI from Caller 1.VI, Method 1 still works.
However, in my program, Caller 3 called Caller 2.VI, then Caller 2.VI called Caller 1.VI, In Caller 1.VI (attached) called Calc_CountNoises.vi 5 times, then Method 1 does not work.
Note that I did probe #99 and Array In, all were good, but not probe #97
01-14-2023 04:54 PM
You need to make the SubVI that uses PtByPt functions pre-allocated reentrant. VIs like PtByPt maintain internal state and when called in a SubVI from different callers will of course mix all the values together.
https://www.ni.com/docs/en-US/bundle/labview/page/lvconcepts/reentrancy.html
01-15-2023 08:23 AM
Thank you very much.
But, It does not work yet.
I changed to pre-allocated reentrant
But the Sample Length will only take on the initial value, and from then on, if I change Sample Length, it will not take effect on Method 1.
Please find attached
01-15-2023 10:34 AM - edited 01-15-2023 10:56 AM
You can open the ptbypt VI to see what it does. You will notice that the sample length will only be read in the init case.
So if you change the sample length on the fly, you also need to init again whenever that happens:
(Yes, the ptbypt VI could be enhanced to do that automatically, but that would add more overhead)