Any large LabVIEW application should be using well-designed sub vi’s to build reliable, manageable software. To ensure that a LabVIEW sub vi design is consistent across projects and developers, we like to use some standard design principles. This means that when looking at sub vi’s across the entire project, they all conform to a standard design. Thus, making it easier to focus on the specific function.
LabVIEW Sub VI Design – Block Diagram Alignment
I always try to ensure that my input controls and output indicators are horizontally and vertically aligned on my block diagram.
Horizontal alignment of Controls and Indicators, the vertical alignment of similar data types makes for intuitive block diagrams.
Consequently, this makes it easier to open a block diagram and to understand what logic is implemented in that function. If your design principle is aligning inputs on the left-hand side and outputs on the right-hand side, you can immediately see that the logic is occurring in the middle of the diagram.
Vertical alignment of related controls and indicators also makes reading a block diagram much more intuitive. If an error control starts at the middle left, it intuitively should exit at middle right. Small principles like this make it so much easier when you are reviewing your code.
LabVIEW Sub VI Design – Front Panel Design
Following a similar principle that intuitive layout of vi’s is easier to understand, I advise standardised layouts for front panels. This tip originally came from Steve Watts excellent book ‘A Software Engineering Approach to LabVIEW’.
In his book, Steve suggests that decorations should be used on a front panel to identify three distinct areas:
- Data In;
- Local Data;
- Data Out.
A well-designed front panel with areas for Data In, Local Data and Data Out makes it easy to understand.
I don’t always stick to using the decorations, as they sometimes have an annoying habit of being placed in front of controls. Consequently, this makes them difficult to edit. However, I always place Data In on the left-hand side and Data Out on the right-hand side. I also match orientation to that of the connector pane wherever possible.
LabVIEW Sub VI Design – Connector Panes
You can change your local LabVIEW settings so that each time you create a sub vi with connector panels, the ‘Connector pane terminals default to Required’ is set to ‘True’. This means you will, by default, need to wire all inputs into that sub-vi.
Change LabVIEW Settings to Connector Pane Terminals default to Required.
The benefit of this is that you are much less likely to forget to wire up an input terminal when using your sub-vi. The calling vi will have a broken run arrow if any sub vi terminals that have required input terminals, go unwired.
It is still possible to change an input terminal to not required – recommended or optional. You can do this if you really do have a sub vi terminal that is optional.
In this sub-vi, the input DAQ Data is a Required input terminal.
The order of controls and indicators on the front panel should match the vertical order of terminals on the connector pane. This makes it easier and more intuitive to understand which input and output are transferred in and out of a sub-vi.
LabVIEW Sub VI Design – Colours
Finally, LabVIEW is a graphical programming language, so it makes sense to use colour to help distinguish distinct functions.
For our team to use a standardised colour scheme across all projects, we have developed a table of vi icon colours for specific functions.
This makes it clearer when looking at a complex diagram to see which sub vi perform which type of function. It also makes it easier when searching for a sub-vi. If the sub vi you are looking for is related to error handling, from the colour scheme above, you are looking for a bright red icon.
Summary
These tips for LabVIEW sub vi design make our day to day programming and maintaining of code much easier. Consequently, they also make our development team more efficient.