LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mean PtByPt VI does not work within a sub VI

Solved!
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.

ngthai_1-1673733413699.png

 

 

 

0 Kudos
Message 1 of 6
(1,236 Views)

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
(1,234 Views)

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

0 Kudos
Message 3 of 6
(1,220 Views)
Solution
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.

 

https://www.ni.com/docs/en-US/bundle/labview/page/lvconcepts/reentrancy.html

Message 4 of 6
(1,198 Views)

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

ngthai_0-1673792554501.png

 

Download All
0 Kudos
Message 5 of 6
(1,150 Views)
Solution
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)

 

altenbach_0-1673801782061.png

 

 

Message 6 of 6
(1,129 Views)