From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make my vi less messy

Solved!
Go to solution

Hello,

I feel that there are repetitive patterns in this vi. that I would like to improve.
Please provide some hints and suggestions to help make this vi less messy.

Any feedback or comments on how to optimize the code would be greatly appreciated.


Thank you in advance for your help.


Best,
Plu

 

Ps. I am working with LabVIEW 2015 on Windows 11 with MS office 2019.

0 Kudos
Message 1 of 5
(988 Views)

Disregard, complained about it not opening but it was just off screen.

~ The wizard formerly known as DerrickB ~
Gradatim Ferociter
Message 2 of 5
(954 Views)
Solution
Accepted by PuriK.

In short, leave yourself more space for wiring which you can do by leveraging SubVIs more. Get in the habit of using a Project and organizing groups of functionality.

 

For example, this bit shows two very similar tracks of processing. They could each be replaced with 2 instances of the same SubVI:

Similar code.png

 

Something else you'll want to ramp up on is using clusters to group related bits of data/config. Clusters let you run fewer wires around and pull out or update individual parts of clusters when needed. They become especially helpful when grouping code into SubVIs to pass groups of parameters into the SubVI for processing.

~ The wizard formerly known as DerrickB ~
Gradatim Ferociter
Message 3 of 5
(943 Views)

Hi Puri,

 

from what I see in the image from message before:

Use Autoindexing for FOR loops to reduce wires going all the way…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 5
(916 Views)

@IlluminatedG wrote:

In short, leave yourself more space for wiring which you can do by leveraging SubVIs more. Get in the habit of using a Project and organizing groups of functionality.

 

For example, this bit shows two very similar tracks of processing. They could each be replaced with 2 instances of the same SubVI:

Similar code.png

 

Something else you'll want to ramp up on is using clusters to group related bits of data/config. Clusters let you run fewer wires around and pull out or update individual parts of clusters when needed. They become especially helpful when grouping code into SubVIs to pass groups of parameters into the SubVI for processing.


Not only does making subVIs save you space, it follows best programming practices.  Eliminating duplicate code makes it easier to maintain because, if you need to make a change to the code, you only change it in one place.  You don't risk missing one or more instances and introducing most likely difficult, subtle, and hard to troubleshoot bugs.

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.
Message 5 of 5
(866 Views)