LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

proper use of stacked sequence structure

Highlighted

Hello

 

I have been reading this forum up and down, trying to figure out what the proper use of a stacked sequence struckture is.

The reason i ask was that almost evryone in this forum thinks it is miss used / and or hides code. And that there is berrer ways of doing it.

 

I ask this question, wondering what is the PROPER use of SSS?

 

attached is the code so you can see what i am doing. As you will see, the code in the SSS are all the same for each frame, only channel number and numeric indicator is different, making upscaling more efficiant.


Faster readings is not an issue since i will be slowing it down later on, so we get a visual value evry 5-10 seconds or so.

 

 

keep in mind i am a novice at LabView, and all input is much appreciated.

0 Kudos
Message 1 of 14
(1,739 Views)
Highlighted

@TorbH wrote:
[...]

keep in mind i am a novice at LabView, and all input is much appreciated.


Let me put it in a clear, short way: There is NO proper usage for stacked sequence structures!

 

Longer explanation:

The stacked sequence structure has some severe disadvantages with the three most prominent:

a) Passing data from "case" to "case" requires sequence locals. This are no-gos for code design.

b) You can see only a fraction of code at one sight on the code. While this is true for other structures (case, event), the SSS does not provide the flexibility and power of the other structures.

c) Speaking of flexibility: The SSS has a strict order of execution. If you want to swap "cases", you often have VERY much to do in the code to make it work. Adding new "cases" is also very often close to nightmare.

 

That being said, the STATE MACHINE architecture is the correct answer to code design for code which *could* use the sss. It provides the flexibility the sss lacks and still ensures proper execution of the application.

 

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 14
(1,724 Views)
Highlighted

Arrays are our friend.

 

r%20read%201ch[1]_BD.png

 

The Computer Scientist types on this forum will suggest there is a use for Stacked Sequence structures, but my eyes start to cross when they talk about it. 😄

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 14
(1,714 Views)
Highlighted

@jcarmody wrote:

 

The Computer Scientist types on this forum will suggest there is a use for Stacked Sequence structures, but my eyes start to cross when they talk about it. 😄



I think there was a thread recently that showed SSS to be faster than SM's in a tight/small framed sequence, which makes sense since you'll skip a comparison step. However, this is a fringe occurance and to be considered the exception to the rule. Just like "When's a good time to use Local variables?" - the general answer is "never". 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
Message 4 of 14
(1,705 Views)
Highlighted

Thanks for responding

 

I tried using array as you showed, but i fail to get it to work properly, well it works as it should but i want it to be able to stop with a button, when i did that only channels 202 - 206 stopped. 201 kept going.

The reason for me to have this opportunity is that later i will connect channels 207-212. and they also will need to be started/stopped seperatly. - Solved with a case structure inside the for loop

 

 

Also, frome here on out, how would i go ahead and use the data? Can i in a "state machine" use several for loops to perform the same tasks as i had in my previous version?

I am not afraid to ask stupis questions, so here goes...How did you get the Raw PT "DBL". (bottom right corner).

 


I appreciate your input

 

0 Kudos
Message 5 of 14
(1,690 Views)
Highlighted

Hi Torb,

 

that button belongs into the loop - THINK DATAFLOW!

 

When you want to "break" channel 201 too you need to add an additional case structure...

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 6 of 14
(1,676 Views)

TorbH wrote:

I tried using array as you showed, but i fail to get it to work properly, well it works as it should but i want it to be able to stop with a button, when i did that only channels 202 - 206 stopped. 201 kept going.

The reason for me to have this opportunity is that later i will connect channels 207-212. and they also will need to be started/stopped seperatly.


Put the stop button inside of the loop.  The button is read with the terminal.  The terminal is read outside of the loop, so it will have the same value for every iteration of your loop.  By moving the terminal inside of the loop, your terminal will be read every iteration and you can therefore abort the loop.

 


TorbH wrote:

Also, frome here on out, how would i go ahead and use the data? Can i in a "state machine" use several for loops to perform the same tasks as i had in my previous version?


A state machine is actually just a single loop.  You can use a state macine with other loops, you just need to be careful of how you pass the data around.

State Machine

Producer/Consumer


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 7 of 14
(1,670 Views)
Highlighted

does this make sense?

I got it working putting a case structure inside the for loop for evry "batch".

It works as i want it to work, but is it a good way of doing it?

0 Kudos
Message 8 of 14
(1,658 Views)
Highlighted

I cant look at the code right now, but from your description i'll ask: Can it be made to a sub-vi so you'll only need to change it once? Can you loop through batches instead of having several?

 

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 14
(1,639 Views)
Highlighted

@Yamaeda wrote:

@jcarmody wrote:

 

The Computer Scientist types on this forum will suggest there is a use for Stacked Sequence structures, but my eyes start to cross when they talk about it. 😄



I think there was a thread recently that showed SSS to be faster than SM's in a tight/small framed sequence, which makes sense since you'll skip a comparison step. However, this is a fringe occurance and to be considered the exception to the rule. Just like "When's a good time to use Local variables?" - the general answer is "never". 🙂

 

/Y


Yes there was a recient CS type discussion on the SSS, I started it.  I'm not really a CS guy.  The SSS performance was debunked to a large degree in the uNuggets thread.  in summary:  See what Norbert said.  There is no "proper" use case for a SSS.

"Should be" isn't "Is" -Jay
0 Kudos
Message 10 of 14
(1,637 Views)