LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Front panel design and efficiency

Solved!
Go to solution

Hello,

 

I have developed a imaging program( please find the attachment ). I have everything defined and working fine. How ever, I dont think the front panel design of my VI is very efficient.

 

The following are what concerns me:

 

  1. Defining constants and using local variables everywhere - Is this the most efficient way of doing it ?
  2. The front panel seems too big. Is there any way I can reduce it.

I want to make the front panel look more clean and brisk and neat.

 

Any advise is appreciated.

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 1 of 11
(4,224 Views)

I think you are confusing the front panel and the diagram. The main problem is your block diagram, i.e. the "code".

 

This is programmed like text based code, with local variables acting as variables and sequence frames acting as line breaks. This is the opposite of how LabVIEW is supposed to work. First you break all data dependencies due to overuse of local varaibles, then you need to re-establish correct execution order using sequence structures. Local varables force extra data copies in memory and all these sequences force sequenctial execution where order does not always matter and where thinghs could be done in parallel. You are severly limiting compiler optimizations.

 

I would recommend that you look into state machines architecture. None of your local varaibles are needed.

0 Kudos
Message 2 of 11
(4,216 Views)

Ok. what I understand now is:

 

  1. Extensive use of flat sequence structure hinders parallel execution, BUT, I want certain parts of the VI to run in sequence. for example , move Y motor, move X motor and the CAPTURE DATA and then reverse X and Y to original position. In such cases, I am forced to use sequential structure - OR is there any other efficient way ?
  2. Use of local variable makes copies in memory that can slow down processing speed - AND this can be avoided using State Machine Architecture - Am I Correct ?

Thank you for the advise so far. I would apprecite it if I could get some more tips and designing a professional block diagram and execute with parallel multi core processing .

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 3 of 11
(4,193 Views)

Check out this link here.

 

The main thing is:

"LabVIEW follows a dataflow model for running VIs. A block diagram node executes when it receives all required inputs. When a node executes, it produces output data and passes the data to the next node in the dataflow path. The movement of data through the nodes determines the execution order of the VIs and functions on the block diagram."

 

The easiest way to string up sub-vis is to use the error cluster controls and indicators to force dependencies - the output of the error cluster indicator on one sub-vi goes into the error cluster control of the next sub-vi, enforcing execution order.  For instance, by simply adding them to the MOTOR with BACKLASH FINAL.vi (and hooking them up properly inside the VI), then connecting the error cluster wire into and out of it, you can get rid of that sequence structure frame.

 

 

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 11
(4,173 Views)

You asked for comment on your front panel design. The comments you have received about the block diagram are important.

 

On the front panel:

- You mix multiple styles of controls, at least Modern and Sliver, with no obvious logic to the choices.

- You use very strong colors for labels while leaving the background default, again with no obvious logic to the choices.

- You use a variety of text font styles, capitalization, ..., with no obvious logic to the choices.

- There appears to be a limited amount of functional grouping of controls, but it is not clear to someone new to this what the effects of the groupings may be.

- Some controls are Locked?

- Some objects overlap.  However this may be do to font differences between platforms.

- Some labels may not clearly communicate to the user the purpose of the control. Example: VISA resource name 2 might be better called "Motor Driver" or something more descriptive.

 

 

Consider using a Tab control or subpanels. Most likely the user does not need to see all the controls all the time. A tab for the motor configuration controls would not only group those controls, but could be disabled so the [sic] "Dont Change values" message would not be needed.

 

Also consider whether some of the controls should be in clusters.  Then make the clusters typedefs so that it is easy to put them into subVIs and any changes required later automaically propagate through.

 

Lynn

0 Kudos
Message 5 of 11
(4,150 Views)

Seems that you're meaning to ask about your "Block-diagram" (which has all your program logic), not the Front Panel (which has all those fields to enter values or to read them). I'm basing that on the fact that both of your concerns are related to a block-diagram, not a front panel.  Most default LabVIEW front panel items do not affect the performance of LabVIEW applications but how you design block-diagrams have direct effect on everything.

 

Using local variables all over the map could very possibly cause "race-conditions" where the outcome would be unexpected and difficult to debug. Best way to "store values" in LabVIEW would be to use wires, they also prevent race-conditions (use clusters to keep number of wires to minimum, that way your design is easy to work with.)  State-machines are one of the best/high-performance design structures, with that your entire program could be made into a very efficient program within a small block diagram area.  I have converted a small portion of your design into a state-machine based design (you could use what I have attached to learn and expand to include rest of your design). Start on a small scale by converting little items and testing to ensure your functionality remains the same.  You can use more than one clusters (I prefer to use clusters within a main "local variable cluster" to keep things clean- so that only one wire runs through states). That is also how you would convert your whole design into State Machines (enum-based are best for performance as well as to prevent user-errors). If you're not familiar with Enums, you can read help.  Hopefully this explains what I mean by use "wires" to store values rather than local variables.  Not only that it is more efficient (when compiled), but also very readable/maintainable.

 

You can also use a "while loop" instead of "for loop" in attached VI, and implement the logic to stop the loop when your required feature is done.

 

-BTC

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


0 Kudos
Message 6 of 11
(4,128 Views)

BTC_admin

 

Looks more clean and efficient , could you please explain what you mean exactly by "prefer to use clusters within a main "local variable cluster" to keep things clean- so that only one wire runs through states". I have gone through your example, but I fail to understand how to do this method. and Yeah it only one wire is used for further data handling between cases, which makes it more neat.

 

Thanks ... 

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 7 of 11
(4,113 Views)
Solution
Accepted by topic author abikutn

My bad - I didn't mean anything complicated, I was simply meaning to say that I like to keep one main cluster that contains all variables and then to further organize items, I like to use clusters within that main cluster (take a look at attached image which shows one input and one output cluster within main cluster). To give you a specific example, you have three sections on your Front Panel - "Image parameters, Motor Configuration, and ADC-FIFO Configuration" - if that's how you intend to modularize your design, I would make one cluster for each of those sections and then I would put all three clusters inside the main cluster.  This is very helpful in modularized designs to keep things organized and to keep a track of which functionality you are using from which section of the code. This way you can readily tell which parameter is from which part of your code - "easily readable".

 

I hope that helps, good luck.

 

 

(One tip: Always keep your design simple and organized, because it produces best robust results and takes the least amount of time to test/debug.)

 

-DP

 

BatchTest Corp.

NI Alliance Partner

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Message 8 of 11
(4,096 Views)

Please find the attached example I created based on your advise. Do give me a feed back.

 

Also, would you explain why did you have to use a FOR loop to shift data between cases ? Why not the way I have done. 

 

Thank you

Abhilash S Nair

Research Assistant @ Photonic Devices and Systems lab

[ LabView professional Development System - Version 11.0 - 32-bit ]

LabView Gear:
1. NI PXI-7951R & NI 5761
2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021

OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
MEMORY - [ 16.0 GB RAM ]
GPU - [ NVIDIA GeForce GT 530 ]
0 Kudos
Message 9 of 11
(4,054 Views)

Well, the way you have done is not a state-machine design as you have simply used a stacked structure to sequentially perform each functionality within a loop - so that sequence will keep happening until you hit stop button. Plus you are "sort of" using a cluster wire as a local variable, but your design keeps reinitializing the wire in every loop - that's actually not an efficient way of programming things.  Instead, you can convert your stacked structure into a case structure, and only execute first frame once at the beginning of your application ("Initialize" state in attached vi.)  That will create a much more efficient design. Simply putting a stacked sequence in a while loop doesn't make it a state-machine based design.

 

Look at how I changed your code into a state-machine design (including enum usage which show each case as a name you can define in enum definition - LabVIEW compiler takes care of replacing them with numerics according to representation you specify). Both vi have same the functionality, but my state machine based design goes through about 38 million iterations in 5 seconds on my computer - whereas your design goes through merely 1 million iterations in the same time period. (However, this much higher performance is also due to the fact that I do not call those popup messages functionality in every loop whereas you do).  Run both of the attached vi's on your computer and you'll see what I mean.

 

In commercial business, performance is everything and we like highly optimized LabVIEW applications (especially since a very large portion of our business is in LabVIEW RT/Embedded, every microsecond counts), but perhaps that is not such an important factor in your field (I'm assuming that you're in Research/Academic) as your top priority is probably to put together a simple implementation and get things running quickly. I made my VI in about 15 minutes, but it will probably take you a bit longer in the beginning until you gain experience.  You really should look up examples and take some NI LabVIEW courses for further help.

 

State-machine based designs can be made very simple yet very powerful.

 

-DP


BatchTest Corp.

NI Alliance Partner

--------------------------------------------------------

New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI


Download All
Message 10 of 11
(4,022 Views)