LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass a refnum along a stacked sequence...

I know that stacked sequences make it difficult to debug code, but in order to conserve VI space it is necessary in my case. 

 

Throughout the sequence there are instances in which I write to a text file, which I identify by refnum. The refnum must be wired from the previous write command (to keep place in the file) - but I can't figure out how to pass it from frame 1 of the sequence to frame 2, etc. Using a sequence local is impractical as I would need one for each frame transition.

 

The frames execute sequentially so I don't see why this shouldn't be possible, somehow. I don't believe there's any way to declare some kind of "refnum local variable" which I could change on each write command.

 

Has anyone ran into this problem, or know a workaround? Thanks in advance.

0 Kudos
Message 1 of 20
(3,127 Views)

You just described the main reason in my opinion to avoid this structure.

 

Replace the sequence with a for loop with a case structure inside.  If you have 5 frames in the sequence, set your N counter to 5 and wire the iteration counter to the case selector.  Create 5 cases and pass your file refnum via shift registers.

 

It would be better to setup a proper state machine but this works just like a state machine, only it's driven by a count value rather than a named state. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 20
(3,107 Views)

I know that stacked sequences make it difficult to debug code, but in order to conserve VI space it is necessary in my case. 

 

Do not create further problems using a stacked sequence, your first statement is already false. If you use properly subVIs, you should have just enough space. Also, have you heard about State Machines? Using a State Machine, you can properly do massive calculations in steps. Intermediate results can be stored in shift registers. For these purposes a State Machine is just superior in any aspects. You can even dynamically reconfigure your calculations, etc, which is not the case when you use Stacked Sequence Structures! 

Message 3 of 20
(3,106 Views)

@VPI001 wrote:

I know that stacked sequences make it difficult to debug code, but in order to conserve VI space it is necessary in my case. as anyone ran into this problem, or know a workaround? Thanks in advance.


Necessary? Stacked or flat sequences are NEVER necessary.

 

If you just want to "conserve space" on your block diagram make a SUB VI.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 20
(3,087 Views)

 

Thank you for the advice to those who actually proposed a solution rather than simply abusing the idea of a stacked sequence. This is legacy code for instrument control which uses complex I/O procedures, and so a state machine solution is completely unworkable unless it were simply sequential. The case structure solution should however meet my needs - 

 

When I try the For loop>Case Structure solution, all of my tunnels break - LabView wants me to wire each and every one of them in every case of the case structure, which is extremely unwieldly. Is there a way to circumvent this behavior? To clarify: the tunnel returns an 'unwired' error unless it is wired through on every case, which seems opposite to the way a tunnel should work.

0 Kudos
Message 5 of 20
(3,075 Views)

@RTSLVU wrote:


Necessary? Stacked or flat sequences are NEVER necessary.

 


I would agree that stacked sequences are NEVER necessary but a case could be made for flat sequences.

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 20
(3,072 Views)

Could you show your code in a form of attached VI, or a LabVIEW snippet ?

It would be easier to help. Also, if you need to deal with lots of wires, clusters (typedef-d!!) come very handy!

 

edit: i also bring your attention to this nice list: http://www.ni.com/newsletter/51735/en/

0 Kudos
Message 7 of 20
(3,063 Views)

@VPI001 wrote:

When I try the For loop solution, all of my tunnels break - LabView wants me to wire each and every one of them in every case of the case structure, which is extremely unwieldly. Is there a way to circumvent this behavior? I just want the tunnel wired straight through to the other side...


If you need to pass a lot a values from one "state" to the next, create a cluster on the outside of the for loop, wire it into another shift register and update the controls as necessary in each "state". This would be a lot easier if you shared a code snippet for us to see.

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 8 of 20
(3,061 Views)

VPI001 wrote:

When I try the For loop>Case Structure solution, all of my tunnels break - LabView wants me to wire each and every one of them in every case of the case structure, which is extremely unwieldly. Is there a way to circumvent this behavior? To clarify: the tunnel returns an 'unwired' error unless it is wired through on every case, which seems opposite to the way a tunnel should work.


Linked Tunnels will help a little, but you will need to make a shift register for each value to keep the latest.  The other option would be to use a cluster that holds all of the output values with a shift register, but I typically try to avoid clusterasauruses.


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 9 of 20
(3,051 Views)

@VPI001 wrote:

 

Thank you for the advice to those who actually proposed a solution rather than simply abusing the idea of a stacked sequence. 


Well without any actual code to look at, that's all we really can do.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 20
(3,039 Views)