LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Improving Performance and Aesthetics of VI

Hello everyone.

I've been modifying existing examples to create a VI (with the help of some very kind members on NI forums) that acquires data (via VISA) from a device and plots the data continously with minimal latency. Unfortunately, I don't have the device at the moment so I can't do proper debugging of my preliminary program.

Anyways, I was hoping some of the more experienced members can give me some suggestions/criticism as to how to improve my code in terms of performance and/or aesthetics. I'm sure that at the moment my code is likely very inefficient and  definitely messy.

Any help is appreciated. It would be good to understand the principles of good code before I continue on further.

Thanks,
Alex
0 Kudos
Message 1 of 10
(3,697 Views)
Hi Alex

Your code is pretty good, it doesn't take up more than a screen, it uses a state machine instead of a sequence and you don't over use local variables etc so you're off to a good start.
I have a few suggestions though.
1. Make use of sub VIs more to neaten your code and add hierarchy
2. Try to straighten wires as much as possible
3. On your front panel it's good to group related controls and make the controls a uniform style. System controls are usually preferred for the main UI.
4. Block diagram needs more commenting, you can also add tips and descriptions to the front panel items

As a functionality thing, you are updating the Results string with information that will be displayed after it is no longer relavant like "Plotting Data... Press "stop acquisition" to stop." will only be displayed after the stop acquisition button has been pressed. To fix it just move the strings into the previous state.

The Style Guidelines Checklist in LabVIEW help is a really great guide to use when reviewing LabVIEW code.
Here is an edited version with some of my suggestions as an example.


_______________________________________
Systems Test Engineer
Certified LabVIEW Architect (CLA)
Message 2 of 10
(3,664 Views)

I preffer using enum instead of a number for state machine.

From state 2 you can not exit the program and continious display initalizing... (which only happens for a moment)

0 Kudos
Message 3 of 10
(3,648 Views)
Thank you for your help!

I will look over this modified code. I'm pretty impressed with it, to be honest. Was this made from some template or did you do this from scratch?

 I even feel a little guilty taking this!
0 Kudos
Message 4 of 10
(3,631 Views)
No problem, feel free to use any parts of it you want. I guess I did get a bit carried away once I started. It was just supposed to be an example of some things you can do to improve aesthetics, everyone has their own style though and as long as it's scalable, readable and maintainable it will be good code.
_______________________________________
Systems Test Engineer
Certified LabVIEW Architect (CLA)
0 Kudos
Message 5 of 10
(3,595 Views)

Hey ap888,

I would recommend you the following book I bought to improve the efficiency, performance and maintainability of my codes. http://www.amazon.com/LabVIEW-National-Instruments-Virtual-Instrumentation/dp/0131458353 It was useful for me.

I agree with the pieces of advice Karissa gave you. They make sense.

To find templates go to file>new and you'll see a list of Vi templates including a state-machine template.

Charly

It's always sunny in California! Certified LabVIEW Associate Developer!
0 Kudos
Message 6 of 10
(3,584 Views)

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.

In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).

Another excellent book is Labview for Everyone.  The author J. Kring often visits this forum.

0 Kudos
Message 7 of 10
(3,578 Views)


JoeLabView wrote:

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.

In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).

Another excellent book is Labview for Everyone.  The author J. Kring often visits this forum.



Excellent suggestion tst! Smiley Happy
 
I read late that it is Joe! LOL!!! Smiley Very HappySmiley Very HappySmiley Very Happy
- Partha ( CLD until Oct 2027 🙂 )
Message 8 of 10
(3,569 Views)

Ray, you're not up to date. The current text is "To learn more about LabVIEW, I suggest you try looking at some of these tutorials.". Smiley Very Happy

Seriously, though, I think other people should also use this. All you need to do is copy it into one of the macros you have in the preferences and then remember to use that macro (there's a drop-down list of macros when you write a post). It's literally two mouse clicks.

P.S. Karissa, that's very nice work and would probably be useful in the future as a good cleanup example. You get 5 stars. Smiley Happy


___________________
Try to take over the world!
Message 9 of 10
(3,554 Views)

Thanks for the update tst.

I will also follow your suggestion about using a macro 🙂

0 Kudos
Message 10 of 10
(3,536 Views)