LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Shift Register to Stacked Case structure

Solved!
Go to solution

Also, you can now easily see from johnsold's clean-up that you're just doing the same thing over and over.  This is a great place to make a subVI that would have inputs for the prompt, double and the two strings.  The subVI would do the repetitive work and you would only have four or five total subVIs in your main program making it more streamlined and easier to read.  If you put the GPIB Write VI and a delay in there too you could even drop it in a loop, feed in your parameters with indexed arrays and be down to a single subVI in your main.  That is what I meant by modularization.  Then, if you need to add or change the function, you only have to do it once and the change propagates to all the instances.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 21 of 28
(2,378 Views)

johnsold - thanks for that feedback.  Your approach of looping on the GPIB Write has given me good understanding of a more compact approach for repetitive processing.  Is the reason you brought the error cluster through the ES to force the flow?  If that wasn't done, would the program execute the User Prompt first?

 

Nlquist - thank for your feedback is well.  I have a better understanding about modularization.

0 Kudos
Message 22 of 28
(2,358 Views)

I really like Johnsold's solution. Another solution for adding shift registers to a flat sequence structure is to sort of program your own flat sequence structure.

 

This is not very elegant but it is way more elegant than a real flat sequence structure with sequence locals.

Capture.PNG

 

=====================
LabVIEW 2012


0 Kudos
Message 23 of 28
(2,346 Views)

Yes, the error cluster wiring is in part to assure that certain things occur in order.  Also, most VIs from the vi.lib do not execute their internal code if the error in is true.  So, if the prompts generated an error, then the GPIB Write wold not take place.

 

What SteveChandler has shown is similar to a state machine.  State machines are very powerful and very robust architectures for things like what you are doing.  A case structure inside a loop (almost always a while loop) is the basic form of a state machine. The case selector is wired to a shift register with the state.  This is often a typedef enum or a string (considerable controversy; both have their places).  Within each case the value for the next state is chosen and place into the wire going to the right terminal of the shift register.  Look at the examples which ship with LV.

 

Lynn

Message 24 of 28
(2,324 Views)

Shhhh! I didn't want to use the term "State Machine". I was hoping to sneakily get people who use stacked sequence structures for everything to use a state machine without realizing it. Sort of ease them in because that term scares lots of people. Smiley Tongue

=====================
LabVIEW 2012


0 Kudos
Message 25 of 28
(2,304 Views)

Sorry, I did not realize you were whispering.

 

The first program I wrote in LV (LV1.2) had a 27-frame stacked sequence structure.  I survived and learned in spite of that.

 

Lynn

Message 26 of 28
(2,297 Views)

@johnsold wrote:

Sorry, I did not realize you were whispering.

 

The first program I wrote in LV (LV1.2) had a 27-frame stacked sequence structure.  I survived and learned in spite of that.

 

Lynn


Where Shift register available in LV 1.2 ?

 

I ask because FG are sometimes called LV2 globals supposedly becuase that is when they were first available.

 

Re: the sneaky state machine

 

a strategic use of a enum and type casting will give each of those state a human readable name.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 27 of 28
(2,291 Views)

Ben,

 

I had to look it up.  The manual for LV 1.2 (printed on real paper and distributed in two 3-ring binders) shows that shift registers were available. It did not mention retaining values from one call of a subVI to another, so that may have changed between LV 21 and LV2.  It also did not say that the values were not retained.  I did not take the time to look at the LV2 manuals.

 

The only sequence structure was the stacked sequence and what we now call frames were called subdiagrams.

 

Lynn

Message 28 of 28
(2,278 Views)