04-10-2017 12:26 PM
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.
04-10-2017 12:36 PM
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.
04-10-2017 12:37 PM
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!
04-10-2017 12:48 PM - edited 04-10-2017 12:49 PM
@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.
04-10-2017 01:00 PM - edited 04-10-2017 01:05 PM
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.
04-10-2017 01:02 PM
@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.
04-10-2017
01:06 PM
- last edited on
12-16-2024
12:17 PM
by
Content Cleaner
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/
04-10-2017 01:08 PM
@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.
04-10-2017 01:13 PM
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.
04-10-2017 01:27 PM
@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.