01-16-2019 11:28 PM
I need to save the value of an input from the first time a sub-vi is called, and subtract that value from all subsequent input values. It's a "baseline" of sorts. Will this snippet do this?
Solved! Go to Solution.
01-17-2019 03:21 AM
no, use FGV
01-17-2019 03:31 AM - edited 01-17-2019 03:32 AM
Hi jfalesi,
I need to save the value of an input from the first time a sub-vi is called
When you are uncertain about the behaviour of a VI you should create a small "testbench" for that subVI…
Something like this:
There's a "First Call?" function and you can use it whenever you want to do something at the first call of a VI!
01-17-2019 03:35 AM - edited 01-17-2019 03:57 AM
@jfalesi wrote:
I need to save the value of an input from the first time a sub-vi is called, and subtract that value from all subsequent input values. It's a "baseline" of sorts. Will this snippet do this?
Almost. Show enable terminal and use a "first call?" node on that terminal. See attached VI and test VI.
01-17-2019 03:50 AM
@thols wrote:
Almost. Show enable terminal and use a "first call?" node on that terminal. See attached VI and test VI.
throls, you've written "2012", but VIs in LV 2018.
bthw, GerdW's variant better imho, because no need extra terminals.
01-17-2019 03:56 AM
Hi Artem,
bthw, GerdW's variant better imho, because no need extra terminals.
But I need one more LabVIEW primitive, so I see an advantage for the Enable terminal of the feedback node!
(I hope the compiler will create the same code for both variations…)
01-17-2019 04:01 AM
01-17-2019 09:43 AM
Why would using "first call" have different behavior than wiring the desired value to the "initializer" terminal and setting it to "Initialize on first call"?
01-18-2019 12:33 AM
@jfalesi wrote:
Why would using "first call" have different behavior than wiring the desired value to the "initializer" terminal and setting it to "Initialize on first call"?
Using "Initialize on first call" will still feed each iteration's value into the feedback node. Using the Enable input and setting the value only on the first call will keep the initial value for every iteration.
01-22-2019 09:08 AM
Yes, each iteration's value will be sent back into the feedback node, but iterations don't alter the value. So once it's initialized, the initialized value should be fed back into the feedback node every time the VI is called. I would use a shift register, but this VI is executed only once per call so I don't need a while loop.