11-05-2010 09:23 AM
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.
11-06-2010 05:07 AM - edited 11-06-2010 05:16 AM
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.
11-06-2010 04:05 PM
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.
11-07-2010 06:12 PM
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
11-08-2010 11:17 AM
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. ![]()
11-08-2010 11:24 AM
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
11-08-2010 11:51 AM
@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
11-08-2010 12:18 PM
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