LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

General Labview Efficiency and layout question (with example)

Hey all, I'm just curious as to what sorts of fundamental things I'm doing wrong or could do better. I learned Labview entirely from writing an application with it and posting here when I got stuck with something that was either hard to find or not self explanatory, so I know my knowledge is somewhat lacking. (For instance, I know OF state machines and how to make one, but not why or when they are better)

I'll post a program I'm working on, but with all the sub .vi calls removed (and replaced with empty sequences).

If anyone could just glance at the overall layout really quick, I'd be grateful.

Thanks,
-Dobbs
0 Kudos
Message 1 of 11
(3,874 Views)
Here's the example program:
0 Kudos
Message 2 of 11
(3,874 Views)
First of all, nice front panel! I can't even guess the number of times I've seen "hot dog stand" looking interfaces where people get excited about the color picker and insist on using red yellow and green all over the place. You have managed to make it look somewhat professional and I respect that. I would suggest tightening up the panel a bit to eliminate all the space around your tabs unless you want this to be full screen.

Your diagram is functional, but it could use some style guidance. I couldn't fit it all on my screen (and I use REALLY high resolution). It looks to me like you could simply shrink it down bt bringing things close together, but there's a better way. I want to address your questions about state machines. For most unser interfaces in LabVIEW they are simply a must. I see your several case structures here and I'm thinking that they could all be combined into one with a separate case for each change event (I see you're checking for control value changes). You get to name your cases in state machines such that they have meaning. With a boolean case you only get the T and F of it all and it doesn't tell me what your going to do about it.

Towards the right side of your while loop you've got this bundle with all the control values wired up. For my state machine I like to bundle my controls on a shift register too. However, you should note that the property nodes created for each control are not necessary. The bundle you create with the control nodes themselves is sufficient to place back on the shift register. You can use that bundle in your event cases whenever you want to manipulate a value or read one for a calculation or something. There are lots of good state machines out there. I recommen using a while loop with a large case structure inside. Make one shift register for your all you data and one for the error cluster. Use a queue to keep track of your states and wire a remove queue elements output to the case selector. Have a "Main" case set as the default for when the queue runs dry. Place all your user controls in the Main case and do your checking for changes there. Build an array of booleans (change or no change + any boolean controls) and an array of states with which to associate the changes or boolean switches. Search the array for TRUE and get the index, and then choose the element of your state array to be inserted on the state queue.

The state machine has many advantages. It organizes your code and makes it easier to debug. Also, if you use the queue method briefly discussed above, you can take control of your VI with another VI by creating a queue with the same name as your state queue. A parallel VI can add elements and your state machine will pick them off. It's all very cool.

I know some of the other LabVIEW-heads out there have oodles of documentation on thier state machines. There is a good article about them in the LTR as well.

Isn't there a discussion ongoing about LabVIEW stlye guides around here too?

Have fun,

Dan Press
www.primetest.com
0 Kudos
Message 3 of 11
(3,874 Views)
"The bundle you create with the control nodes themselves is sufficient to place back on the shift register. "

I had it done that way originally. The problem is, one of the controls may be modified by the program itself. (You click on a checkbox, it asks you if you're sure, and if not, it change it back) I need the shift register to contain the final data for the loop.

Very cool indeed... I'm working on digesting it all.

And lo and behold someone has an example! Suppose I'll go check it out.

-Dobbs
0 Kudos
Message 5 of 11
(3,874 Views)
I've attached your example modified to be a state machine. IMHO, a state machine offers much greater flexibility and is easier to understand and document. I always use a state machine if I have more than one button on the front panel. The example I did can also handle pull down menu events. Also, the use of queues allows one event to also trigger other states to be performed. Click on the Setup SW Output to see what I mean.
Message 4 of 11
(3,874 Views)
Goodness, how did you go about creating that? Quite a massive amount of wiring to have done. Thanks a lot... now I've just got to figure out how it works so I can do that on my own in the future.

What do you mean by "Pull Down Menu Events", precisely?
0 Kudos
Message 6 of 11
(3,874 Views)
It actually only me about 15-20 minutes to do because I use a state machine template and all I had to do was drag your front panel into it. Pull down menu events are from either the standard LabVIEW menu bar(File, Edit, etc.) or a custom menu that you create. Selecting a menu item returns a string so that string can just be another case in the case statement.
0 Kudos
Message 7 of 11
(3,874 Views)
Dennis,

This discussion has made me curious about your state machine approach.
As an EE I know the state machne ideas, but as a self-educated LabView
user I'm not sure what you are talking about exactly, because I cannot
open your VI.
Could you publish a version readable with labView5 as well?

Thanks & Best Regards
Urs



Knutson wrote in message news:<506500000005000000DC390000-993342863000@exchange.ni.com>...
> It actually only me about 15-20 minutes to do because I use a state
> machine template and all I had to do was drag your front panel into
> it. Pull down menu events are from either the standard LabVIEW menu
> bar(File, Edit, etc.) or a custom menu that you create. Selecting a
> menu item returns a string so tha
t string can just be another case in
> the case statement.
0 Kudos
Message 10 of 11
(3,874 Views)
Unfortunately, the original example used a tab control and that doesn't exist in LabVIEW 5. The state machine architecture that I use was not created by me. If you do a search of NI's Developer Exchange or the Resource Library, you should be able to find several examples. In any event, I can't do an attachment here (a limitation of the Developer Exchange). If you want, you may contact me via private email at dknutson@carrieraccess.com.
0 Kudos
Message 11 of 11
(3,515 Views)
Apologies for pestering you further.

Concerning the Last (Voltage, Current, etc.) controls that you added: I presume their existence is for the purpose of using bundle/unbundle by name, correct?

Also, being somewhat unfamiliar with this more advanced synchronization methodology, how do you ensure that the program does not determine that the max voltage, for instance, has changed on the first iteration? The control called "Voltage Range" is set by the subroutine that is not there yet, but the "Last Voltage Range" is just 0 to start with, correct? Or am I missing something?

Also, this is very cool stuff, I really like it, and I think I've got its functionality down pretty well. Thanks again! It certainly has more finesse than my old way. 🙂

-Dob
bs
0 Kudos
Message 8 of 11
(3,874 Views)