LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pass value through cases in cases structure

I'm wondering... if you have a value, say a numeric indicator in one case of a case structure, but you want to use it in the next case.... are your only two options either making a local variable or using the "value" property node?  And if so, is either of these better than the other?  The pic attached shows me using the property node to pass the value to the next case....

 

 Thanks,

M.

 

 

0 Kudos
Message 1 of 16
(2,983 Views)
Why don't you just put your indicator outside the case structure?  You can pass data into and out of a case structure much more efficiently than you can to a local and several orders of magnitude more efficiently than you can with a property node.
0 Kudos
Message 2 of 16
(2,979 Views)

Well, I need the value that I calculate in the first case... I'm going to need that value in the next case to calculate something else... basically I need the effect of passing my value on to the next case.

 

several orders of magnitudes worst?!  Are property nodes better to avoid?

 

Thanks

0 Kudos
Message 3 of 16
(2,968 Views)
The correct way is to use a shift register.
0 Kudos
Message 4 of 16
(2,964 Views)
But shift registers aren't available for case structures.... are they?
0 Kudos
Message 5 of 16
(2,961 Views)

Monse wrote:
But shift registers aren't available for case structures.... are they?

The shift register (or feedback node) goes in the surrounding while loop!

 

 

In addition to my answer above, here are some more concerns:


Monse wrote:

...either making a local variable or using the "value" property node?  And if so, is either of these better than the other?


Local variables and value proprty nodes should be used sparingly, and you need to be careful about race conditions. If you MUST use one of the two, use a local variable. Value properties are orders of magitude less efficient because they must execute synchronous. A race condition can happen if you read a local variable before another part of the program has a change to update it with the expected value.


Monse wrote:

I'm wondering... if you have a value, say a numeric indicator in one case of a case structure, but you want to use it in the next case....


 

Unlike sequence structures, there is no valid definition of a "next case", because the cases can execute in any order, purely depending on the code (or state varaible in your case). This means that you constantly need to remain on your toes to prevent race conditions. For example a race condition would happen if you would later decide to change the execution order and case 2 would be first to execute. Now you would read a potentially unexpected value.

 

Can you explain in a few more words what you are trying to do. Maybe there are much better solutions. For example have a look at action engines.

 

Message Edited by altenbach on 09-03-2008 09:08 AM
Message 6 of 16
(2,950 Views)

ok, basically I am running a state machine, where I record some value from a DAQ and then take that data and compute a big array of test points from it.... after I have those test points I would like to move on to the next state in my sequence.  In this state I will have 2 nested for loops that take the data and create a very large 2d array from the points.  That 2d array goes out to a spreadsheet file.

 

So my problem is that I have my array of test points, and now I want to go to the next state (or case) in my state machine... and bring my array with me. 

 

Would sending this array out of my while loop through a shift register be a better solution than a local variable? Its feeling like there aren't many options here...

 

 

Much Thanks for your help

0 Kudos
Message 7 of 16
(2,936 Views)

To pass a value, an array,... to the next state of a state machine, a good and easy solution is to use a shift register, like altenbach wrote.

You have the solution in your picture already: You use a shift register to pass a value [1] from state '0' to state '1'.

0 Kudos
Message 8 of 16
(2,924 Views)

Monse wrote:

Would sending this array out of my while loop through a shift register be a better solution than a local variable? Its feeling like there aren't many options here...


Nothing goes "out of the while loop". A pair of shift registers is typically a single memory location that persists unless you change it's data in one of the cases. In all cases where you don't want to change the data, wire it straight across.

 

Yes, a shift register is the correct way. A local variable will create another datacopy in memory and requires an indicator, way too much baggage to just keep some persistent data.

0 Kudos
Message 9 of 16
(2,922 Views)
ok, I'll try that, much thanks
0 Kudos
Message 10 of 16
(2,918 Views)