LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to eliminate flat sequence/stacked sequence

Hi All,
 
In my applications i have used sequences ... both flat sequence and stacked sequence.
 
I prefer to use flat sequence because it wont hide code.But still in some situations i have to use stacked ones because of the
large size of flat frames(if there are more frames).
 
But when i was referring through posts about sequence,i came to know that its not a good practice to use flat/stacked sequences.
 
Will it slow down the performance?
 
Instead of using flat sequence/stacked sequence how can i acoomplish dataflow?
 
ie,i want step2 to be executed only after executing step1 as step 2 is accepting step1's values.
Then instead of making 2 frames first one for step1 and the second one for step 2,how can i accomplish this
through dataflow concepts.
From where i can get good tutorial materials regarding the above?
 
If flat sequence/stacked sequence is not desirable in programming ,i am wondering what is the purpose of the two easy to use things?
 
Thanks in advance
0 Kudos
Message 1 of 8
(4,334 Views)

One way of doing it would be to make sub VI's for the step1 and step2 sections of the program.

This makes your block diagram more compact and readable

You could use an error in / error out to these sub VI's to ensure data flow direction

I recommend you read the style guide and the LabVIEW Programming Techniques - The Good, The Bad, and the Ugly from the turotials section

Message 2 of 8
(4,324 Views)
Sequences are crutches for people who are LabVIEW challenged...:manvery-happy:...just kidding. Seriously, sequences have their place in LabVIEW programming. Use them only when necessary and let the data drive the rest of your code. Except for LabVIEW FPGA, I've found that I use sequences rarely.

Bill
0 Kudos
Message 3 of 8
(4,322 Views)
Thank u for your reply sir.
 
I have used sub vis in my application where i have to perform subtasks.
 
But still
 
Suppose i have to initialise the an array to  empty at a particular step of my application and then assign values to it(just an example).
In situations like this i usually use flat sequence where my first frame perform all the initialisations and the second frame can be used for assignment of values.
But for this simple task a subvi needed?Is it better?
 
Then how to add error in,error out in subvi do i can ensure data flow
 
Thanks once again
0 Kudos
Message 4 of 8
(4,281 Views)

Hi,

Sequences do have there uses, one of them being to group all those items that need initialising at the start of your application.

But to have nested sequences is not a good practice.

Regards

Ray Farmer

Regards
Ray Farmer
Message 5 of 8
(4,274 Views)


@user_1 wrote:
Suppose i have to initialise the an array to  empty at a particular step of my application and then assign values to it(just an example).

Sometimes it helps to think about the really necessary steps. For example why would you need to initialize an array to empty if you assign values in the next step anyway a few milliseonds later. In this case, you can just assing the values and skip the first step. The final result will be the same. 😉
0 Kudos
Message 6 of 8
(4,271 Views)

Thank u for ur reply.

Suppose i have an array of type integer.The steps being carried out in a for loop.In the first iteration the array is having a lengthof 30 and the second iteration i am going to assign 20 numbers.If i am not emptying the array (b4 the 2nd iteration), in the second iteration also it will contain 30 elements(20 of the current iteration and the next 10 that is not being cleared off from the previous iteration,instead of containing 20 elements))

This is just an example.There may be having better methods other than this.

 

0 Kudos
Message 7 of 8
(4,268 Views)

In this case (and most othere cases!), there are still no sequences needed. You would simply carry your array in a shift register and operate on it at each iteration. You would clear certain elements by replacing a subset with zeroes and repalce with data in the same way. since all operations happen on the same wire, the order of operations in strictly determined by the order you line up the operation along the array wire. No sequences needed!

Of course if you would chop up your code by shuffling the array data via e.g. local variables (breaking all natural dataflow in the process), you would need to artificially restablish execution order with sequence structures. This leads to complex and inefficient code.

The need for excessive sequences is most often an indication of poor program design overall. In >99% of all cases, there is a better way! 🙂

For some related easy reading, see also the following threads: "wire or local variable" and "Stacked Sequence Exterminator" 🙂

0 Kudos
Message 8 of 8
(4,238 Views)