Showing results for 
Search instead for 
Did you mean: 

Mean PtByPt VI does not work within a sub VI

Go to solution

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.





0 Kudos
Message 1 of 6

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.

0 Kudos
Message 2 of 6

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 5 times, then Method 1 does not work.

Note that I did probe #99 and Array In, all were good, but not probe #97

0 Kudos
Message 3 of 6
Accepted by topic author ngthai

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.

Message 4 of 6

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



Download All
0 Kudos
Message 5 of 6
Accepted by topic author ngthai

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)





Message 6 of 6