From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Hold last value on unconnected tunnel in case structure

Solved!
Go to solution

I have a true/false case structure as below. I am using it to run some code when an input is true. False condition is empty.

after performing some calcs I tunnel the value out, I wish the false condition to hold the same value, 

how do I achieve this?

Use default if unwired returns a 0 value which I don't want.

Thanks

hold last value.png

0 Kudos
Message 1 of 9
(4,318 Views)

Use a feedback node or a shift register to hold the value.  The value from the FB Node can then go into the structure.  In the false case, just wire up the input and output tunnels.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 9
(4,306 Views)

Can you please further explain.

The while loop is only available in the true case, the false case is empty.

where do I create the shift register?

0 Kudos
Message 3 of 9
(4,300 Views)

You create a shift register on the case structure.

0 Kudos
Message 4 of 9
(4,286 Views)
Solution
Accepted by topic author hydzik

hydzik wrote:where do I create the shift register?

I assume that this is running inside of another loop.  You would put the shift register on the loop.  If not, then use a feedback node.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 9
(4,282 Views)

Why not just use a local variable in the false case?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 9
(4,267 Views)

Hi aputman,

 

in LabVIEW you trust the DATAFLOW! And the wire is the variable!

 

So shift registers (or feedback nodes) are the preferred way to store data from one iteration to the next.

Local variables create data copies (as they don't follow the DATAFLOW) and are prone to race conditions…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(4,260 Views)

@aputman wrote:

Why not just use a local variable in the false case?


Let me go ahead and answer that: There are a few reasons:

  1. Data Copy.  The Local read makes a copy of the data
  2. UI Thread switch. the FBN does not require the use of the UI Thread
  3. Initialization options.  the indicator may not have the desired default value or initialize correctly while the FBN can init on each call or on first call
  4. What other code exists? you could introduce an unexpected race condition if a local write exists elsewhere.

The FBN is the preferable change 


"Should be" isn't "Is" -Jay
Message 8 of 9
(4,256 Views)

I understand dataflow just fine.  However i didn't know that FBN could be used outside of loops.  Makes sense now.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 9 of 9
(4,252 Views)