07-13-2015 02:28 PM
Hello,
I am relatively new to Labview so I'm not able to tell if I'm overcomplicating my programs or making my block diagram too cluttered. I was wondering if there were some ways to tell whether I could simplify my programming just by looking at it (perhaps only experience helps for these things) ?
I have attached my VI here. Currently, it has the capability to monitor the voltage and current from two motors. On display, you can see a indicator with the voltage and current values and there are charts toward the bottom that can display waveforms from different motors with a drop down menu.
The front panel is rather clean in my novice opinion, but the block diagram seems messy to me, just at first glance. I foresee a problem occuring in the future however. In the future, I will have to scale the VI to monitor 50 motors. All the programming will be the same as the one I have now, except it will have 50 indicators and unfortunately 50 times pretty much everything. I would like to avoid this, but I'm not sure how I could.
I am using a USB 6009. I am using its four differential inputs to monitor the voltage and current of two motors. In the future, I will be getting more DAQ units (25 total because 2 motors can be monitored for each DAQ). The new DAQs will help will help with more resource space, but I think complicate things with the additional potential of 24 more DAQ Assistants (as used in my code).
Thanks for any help you might be able to provide!
Solved! Go to Solution.
07-13-2015 02:54 PM - edited 07-13-2015 03:03 PM
It usually is mainly experience that will teach you the best methods to make your code look pretty. I don't know anyone who is proud of their first from-scratch application. There are a few resources out there to help with best practices, like this group on ni.com, but you'll learn the most from your own development.
Your front panel looks great. FPs in general are really up to you. You can make it look as ugly or pretty as you want. When you have some duplicate controls and indicator groups, you should utilize clusters and arrays to simplify. You could use a little bit of cleanup in that regard, but not much. Also, personally, I hate reading red text unless it's a warning of some sort.
Your block diagram could use some cleanup in a modularity sense. You have a lot of repeated code, which you could consolidate in to a subVI that is used in multiple locations, or in a For loop. A general rule of thumb is to keep your block diagram within a single monitor. You shouldn't have to scroll. Your application is pretty simple, so it's hard to mess it up ![]()
Here are some specifics about your block diagram:
There are free intro videos you can watch to learn what NI would suggest in terms of coding and teach you some of the basic features and such. Here's a three hour course, and here's a six hour course.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
07-13-2015 03:06 PM
Thank you for the reply. The multiple indicators are so that all the values can be viewed together and I figured they aren't too big to present a problem (although with more values to monitor, I guess it could present a problem).
I figured no scrolling on the block diagram would signify good code, but are there any instances where that's not possible? My guess would be that you can always break up the code into SubVi's to avoid too much code on one page, but like I said, I'm new to Labview so I'm not sure. Could you expand a little bit on what you mean by using subVi's for repeated code. I've heard of it, but I'm not exactly sure how to works and where it could be applied. I'll be sure to look up resources on this topic as well.
07-13-2015 03:07 PM
Oh whoops, you included specifics. Not sure how I missed that. Thanks
07-13-2015 03:16 PM
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
07-13-2015 04:03 PM
@James.M wrote:
Hehe, yeah, sorry. I went back and edited the post to add the specifics. That's the only thing I don't like about this forum, there's always new info or someone else posts while I'm typing up a response.
The easiest way to create a subVI is by selecting the code you want, right-clicking, and selecting Create SubVI. SubVIs are another file that you have to save with your code, so make sure you keep it all together.
Really, you should watch some training videos to get a better grasp of LabVIEW's functionality.
This is the easiest, but (at least from a block diagram cleanliness perspective) not usually the best way to create a subVI. This creates an ugly gap in your block diagram and you have to shift stuff around to fill up the hole. The best way is to have in mind the subVIs to begin with. (Think about each paragraph of a requirement to be a subVI, for instance.) Create them and drop them onto your block diagram. I think it was Altenbach that gave me the idea to use a one-frame flat sequence structure to attach all the input and output wires of your "proposed" subVI, select the flat sequence structure and create the subVI from that. (Don't forget to eliminate the flat sequence structure from your SubVI!) That way the hole will only be as big as the flat sequence structure. Create your code inside the newly created subVI.
It's easier to start and maintain a clean block diagram than it is to let it get messy and then try to clean it up all at once.
07-13-2015 04:07 PM - edited 07-13-2015 04:08 PM
@billko wrote:
This is the easiest, but (at least from a block diagram cleanliness perspective) not usually the best way to create a subVI. This creates an ugly gap in your block diagram and you have to shift stuff around to fill up the hole. The best way is to have in mind the subVIs to begin with. (Think about each paragraph of a requirement to be a subVI, for instance.) Create them and drop them onto your block diagram. I think it was Altenbach that gave me the idea to use a one-frame flat sequence structure to attach all the input and output wires of your "proposed" subVI, select the flat sequence structure and create the subVI from that. (Don't forget to eliminate the flat sequence structure from your SubVI!) That way the hole will only be as big as the flat sequence structure. Create your code inside the newly created subVI.
It's easier to start and maintain a clean block diagram than it is to let it get messy and then try to clean it up all at once.
Well put. I've been using flat sequence structures to do that for a while and I'm glad to hear I'm not the only one.
My initial suggestion to make a subVI that way was intended for a newbie to understand their purpose. I don't think I understood what a subVI was (long ago) until I was looking at my block diagram thinking "where can I shrink this code I already made too big", just like OP is thinking.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
07-13-2015 04:15 PM
It's easier to start and maintain a clean block diagram than it is to let it get messy and then try to clean it up all at once.
Perhaps, but cleaning it all can be therapeutic, kind of like cleaning the kitchen or your room. Maybe that's just me
07-13-2015 08:22 PM