From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Looking for opinion on my VI - New to Labview

Solved!
Go to solution

Hi everyone,

I'm new to Labview and I would like your opinion on my VI, to improve myself and better understand how Labview works.

 

My main goal is to create a test interface where the user can select a test option (A or B) and start a test corresponding to the choice made. I also create a subVI called when test option A is choose. It displayed test instruction to be made before executing the main test code. What I did is only a draft and doesn't include real test, only dummy test in order to practice and progress toward my final goal.

 

Everything worked but I probably made some beginners mistake which could lead to errors hard to troubleshoot with more complex test routine.

 

I'm looking forward to your feedback and they are well appreciated,

 

Thanks!

0 Kudos
Message 1 of 9
(2,757 Views)

Can you backsave to an older version?  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 9
(2,717 Views)
Solution
Accepted by topic author TechBob

A few quick things I see.

 

  1. Numeric seems to be a counter.  You only ever add 1 or subtract 1.  So it should be an integer (blue) rather than a floating point (orange).
  2. Numeric is a control, but you have it hidden which means no user interaction.  So what you seem to have done is create a variable like this was a text based language.  Get rid of that hidden control.  The "variable" in LabVIEW is the data in the wire.  So create a wire that runs through all cases of the event structure and goes through a shift register on the loop.  Then you can increment, decrement, or do nothing with the value on that wire and the shift register will store the value for the next iteration.
  3. Yur disabled property nodes have a coercion dot because you have numeric constants wired into the select function of 2, or 0.  What does 0 mean?  What does 2 mean?  That isn't easy to determine from your code.  Take one of those properties nodes and make a copy.  Right click on it and Pick Create Constant.  Now you'll have a copy of the actual enum that gives you the choices of the states.  Delete all of those 0 and 2 constants and wire in copies of the enum.  Now you can set them to "Enabled" or "Disabled and Greyed" out, now documenting your code properly and those coercion dots will go away since you are now using the correct datatype for that property node.

 

0 Kudos
Message 3 of 9
(2,711 Views)
Solution
Accepted by topic author TechBob

20 second glance before I walk to the bus stop:

 

Test instructions v2:

  • How many instances of the SAME diagram constant (array of color clusters) do you possibly need? One each is enough!
  • Value property nodes are never needed. Locals are more efficient, but stick with a wire if possible.
  • It is extremely annoying if all front panels and diagrams are maximised to the screen. Keep it as window so you can actually look at other things (e.g. this forum page and the LabVIEW help windows you probably need!)
  • Your inner FOR loops are nearly identical. Reuse the code!
  • ...

user interface VI:

  • Create a proper state machine instead of Aztec pyramids of cases inside cases inside cases, etc.
  • Use data dependency instead of sequence structures.
  • Write to the terminals of pass & fail.
  • Remove all "reinit to default" nodes. You use these in parallel of writing to the same terminals and whatever is last wins. No way to tell. Race condition!!!
  • If the "boolean" is false, your toplevel loop spins as fast as the computer allows, burning 100% of a CPU core.
  • None of you local variables are needed.
  • (I repeat!) It is extremely annoying if all front panels and diagrams are maximized to the screen. Keep it as window so you can actually look at other things (e.g. this forum page and the LabVIEW help windows you probably need!)
  • Your shift register probably belong in the outermost loop and should be initialized.
  • ...
0 Kudos
Message 4 of 9
(2,683 Views)

Thank you very much! This is exactly the kind of comment I needed. Really appreciated.

0 Kudos
Message 5 of 9
(2,662 Views)

Yes, here is version save with v15

Thanks,

Download All
0 Kudos
Message 6 of 9
(2,656 Views)

Thank you very much! This is exactly the kind of comment I needed. Really appreciated.

 

I'm gonna have some homework to do 😉

0 Kudos
Message 7 of 9
(2,654 Views)
Solution
Accepted by topic author TechBob

Here's how the subVI could look like. No duplicate code!

(Note that the default is enabled, so use default if unwired tunnels. You can combine multiple properties into one node. etc.)

 

(Suggested improvements: (1) Make it scalable. List files with the given pattern in the desired folder, then iterate over all with the back/next buttons, no matter how many there are. (2) Add error handling, (3) instead of forming the paths, index into an array of predefined paths, etc..)

 

altenbach_0-1576265645278.png

0 Kudos
Message 8 of 9
(2,629 Views)

Great! Thanks again 🙂

 

It gives me plenty of stuff to improve and learn from these suggestions.

0 Kudos
Message 9 of 9
(2,623 Views)