LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need Expert's Advice - How to use LabView Efficiently and to increase Readability

My application is fairly complex. It is a real world testing applications that simultaneously controls 16 servo motors running various stress testing routines asynchronously and all at the same time. The application includes queues, state machines, sub VI's, dynamically launched VI's, subpanels, semaphores, XML files, ini files, global variables, shared variables, physical analog and digital interfaces and industrial networking. Just about every technique and trick that LabView 2010 has to offer and the kitchen sink as well.

 

Still I am not happy with the productivity that LabVIEW 2010 has provided, nor the readability of my final product.

 

Sometimes there are too many wires. Much of my state machines have a dozen or more wires just going from input to output, doing nothing, just because one or two states in the machine need that variable in some state. Yeah, I could spend alot of time bundling and unbundling and rebundling those values, but I don't think that would improve things much.

 

We have had a long discussion about the use or misuse of Local variables in this forum and I don't want to repeat that here. I use them sparingly where I think it is relatively safe to do so. I also have a bug whenever I try and copy some code that contains one or more local variables. On Pasting the code with local variables, the result is something other than what I expected, I am not sure what. I have to undo the paste and rebuild the code one object at a time.

 

I am also having trouble using trouble using Variable Property Nodes. When I cut and paste them, they often loose their reference object and I have to go back into the code and redo the Link To on each one. That wastes alot of time and effort.

 

Creating subVIs is often not appropriate when the code makes many references to objects on the Front Panel. Some simple code will turn into a bunch of object references and dereferences which also tends to take alot of work to clean up and often does not help overall readability in many cases. I use subVIs when appropriate, but because of the interface overhead, not as often as I would like to. My application already has over 150 sub VIs.

 

The LabView Clean Up Diagram function often works poorly. It leaves way too much empty space between objects, making my diagrams 3 to 4 24" screens wide. That is way too much and difficult to navigate effectively. The Clean Up function puts objects in strange places relative to other objects used nearby. It does a poor job routing wires and often makes deciphering diagrams more difficult rather than easier.

 

My troubleshooting strategies don't work well for large diagrams and complex applications. The diagrams are so complex that execution highlighting may take 20 minutes for a single pass. Probes help, but breakpoint aren't of much use, because single stepping afterwards often takes you to somewhere else in the same diagram. I can't follow the logic well doing this.

 

Using structures, I may have Case structures nested 5 to 10 levels deep inside some Event Structure inside a While Loop. Difficult to work with and not very readable.

 

All and all, I can make it work, but I am not happy about the end result.

 

I am hoping to benefit from some expert advice from those that are experienced in producing large complex applications efficiently, debugging efficiently and producing readable diagrams that they are proud of.

 

Can anyone offer their advice on how best to use the LabView features to achieve these results in complex applications? I hope that you can help show me the light.

 

 

Message 1 of 9
(6,239 Views)

dbaechtel wrote:

Can anyone offer their advice on how best to use the LabView features to achieve these results in complex applications? I hope that you can help show me the light. 


I don't have the words to fully express my sentiments, so I'll try to diagram my learning process in terms we all understand:

 

LearningLabVIEW.png

 

 

Spoiler
Yes, the snippet works even with the New Terminal cameo

 

 

Message 2 of 9
(6,228 Views)

It seems that you've discovered that there's a use for Architects in the software development process.  😉  Don't blame yourself or LabVIEW; developing complex applications takes experience.  You'll learn how to do it the same way you learned to speak (listening and talking) and to write (reading and writing).

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 3 of 9
(6,207 Views)

Good Work Jack.

0 Kudos
Message 4 of 9
(6,196 Views)

What happens Friday Nights and where?

0 Kudos
Message 5 of 9
(6,170 Views)
I'm not an expert but I'm charged out as one at work.

Smiley Wink

 

I am off today so I'll share some thoughts that may help or possibly inspire others to chime. I have tried to continually improve my code in those areas and would greatly welcome others sharing their approaches and insights.

 

Note:

I do refactoring services to help customers with this situation. What I will write does not represent what we do in a code review since our final delverable is a complete final design and that is beyond the scope of this reply.

 

I'll comment on your points.

 


@dbaechtel wrote:

My application is fairly complex. ...

 


 

While watching Olympic figure skating competion slow-motion replays, I learned how the subtleties of how the launching skate is planted while entering a jump can make the difference between a good jump and a bad one.

 

In software, we plant our foot when we turn from the design to the development. I have to admit that there where a couple of times when I moved from design to development too early and found myself in a situation like you have described.

 

How to know when design is done?

 

Waterfall says "cross every 't' and dot every 'i' " while Agile says "code now worry about design latter" and Bottom-up "says "demo working why bother designing" (Please feel free to coment on these over-simplifications gang).

 

My answer is not much more helpful for those new to LabVIEW. 

 

My design work is done when my design diagrams are more complicated than the LabVIEW diagrm they describe.

 

 


@dbaechtel wrote:
...

 

 simultaneously controls 16 servo motors running various stress testing routines asynchronously and all at the same time. The application includes ...and the kitchen sink as well.

 


 

Have you posted any design documents you have? These will help greatly in letting us understand your application. More on diagrams latter.

 

Anytime I see multiple "variations on a theme", I think LVOOP (LabVIEW OOP ) . I'll spare you the LVOOP sales pitch but will testify that once you get your first class cloned off and running as a sibling (or child) you'll appreciate how nice it is to be able to use LVOOP.

 

Discalimer:

If you don't already have an OOP frame of mind, the learning curve will be steep.

 


 

@dbaechtel wrote:
...

Still I am not happy with the productivity that LabVIEW 2010 has provided, nor the readability of my final product.

 

Sometimes there are too many wires....going from input to output, doing nothing,... spend alot of time bundling and unbundling and rebundling those values, but I don't think that would improve things much.

 


 Full disclaimer:

I used to be of the same opinion and even used performance arguements to make my point. I have since, changed my mind.

 

Let me illustrate (hopefully). This link (if it works for you, use lefthand pane to navigate hierachy) shows an app I wrote from about 10 years ago when I was in my early days of routing wires. Even the "Main" VI started to suffer from too many wires as this preview from that links shows.

 

Clustering related data values using Type Definitions   is the first method I would would urge. This makes it easier to find the VIs that use the Type def via the browse relationships>>>callers. If I implement my code correctly, any problem I believe is associated with a particualr piece of data that is a Type def has to be in one of the VIs that use that type def therefore easier to maintain.

 

When I wrote "related data" I am refering data normalization rules (which my wife knows and I picked-up from her and I claim no expertise in this area) where only values that are used together are grouped. E.G. Cluster named File contains "Path" and "Refnum" but not "PhaseOfMoon". This works out nicely with first creating sub-VI since all of the data related to file operations are right there whe I need it and it leads into the next concept ...

 

When I look at a value in a shift register on the diagram taking up space that is only used in a small sub-set of states, I concider using an Action Engine . This moves the wire from the current diagram into the Action Engine (AE), and cleans up the diagram. The AE brings with it built-in protection so provided I keep all of the opearations related to the the Type def inside the AE I am protected when I start using multiple threads that need at that data (trust me, it may not make a difference now but end users are clever). So that extra wire is effective encapsualted and abstracted away from the diagram you are looking at.

 

But I said earlier that I would not sell LVOOP so I'll show you what LVOOP based LV apps look like to contrast what I was doing ten years ago in that earlier link. This is what the top level VI looks like.

 

2_Init_GUI_Controller.PNG

 

 And this is the Analysis mode of that app.

 

7_Get_Refs_In_Use.PNG

 

I suspose I should not mention that LVOOP has wizards that automatically create the sub-VI (accessors) that bundle/unbundle the clusters, should I?

 

Continuing...


 

@dbaechtel wrote:
...

 

We have had a long discussion about the use or misuse of Local variables...I also have a bug whenever I try and copy some code...


 

If you can simplify the code and duplicat ethe bug. please do so. We can get it logged and fixed.

 

 

 


 

@dbaechtel wrote:
...

 

I am also having trouble using trouble using Variable Property Nodes....

 


 

That sounds like a usage issue. Posting code to illustrate the process will et us take a shot at figuring out what is happening. 

 

 


 

@ dbaechtel wrote:
...

  

Creating subVIs is often not appropriate... My application already has over 150 sub VIs.


"Back in the day..." LV would not even try to create a sub-VI that involved controls/indicators. I use sub-VIs to maintain a common GUI often but I do it on purpose and when I find myself creating a sub-VI that involves a control/indicator, I hit ctrl-z immediately! 

 

I figure a way around it (AE ?) and then do the sub-VI.

 

Judging by your brief explanation and assuming you do a LVOOP implementation, I would estimate that app need 750-1500 VIs. 


 

@ dbaechtel wrote:
...

The LabView Clean Up Diagram function often works poorly.... 


THe clean-up works fine for how I use it. After throwing together "scratch code" and debugging the "rats nest" I'll hit clean-up as a first step. It guess good enough on simple digrams and in some cases inspires me to structure the diagram in a different way that I may not have thought about. If I don't like, ctrl-z.

 

Good deisgn and modualr implementaion led to smaller diagrams that just don't need thrre screens.


 

@ dbaechtel wrote:
...

My troubleshooting strategies don't work well for large diagrams and complex applications....Can anyone offer their advice on how best to use the LabView features to achieve these results in complex applications? I hope that you can help show me the light.

 

 


Smaller diagrams single step faster since the sub-VI run full speed. I cringe thinking about a 3-screen diagram with multiple probes open ( shivver!).

 

Re: Nestested structres

Sub-VIs (wink, wink, nudge, nudge)

 

If it works you have prven the concept is possible. That is the first step in an application.

 

I hope that gives you some ideas.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 9
(6,125 Views)

Thanks for all of the work and comments.

0 Kudos
Message 7 of 9
(6,118 Views)

As projects grow over time, it's normal that you introduce features you didn't think about in the initial design. Hence it is a good thing to step back and refactor the code from time to time. I found this even a time-saver when I was on a thight time scedule.

 

You write that you have 150 SubVIs, that sounds far too less! Proper refactoring will lead you to many more SubVIs, but in this process you will discover that you did use the same code fragment in several places.

 

Creating SubVIs with property nodes/local variables: Don't shy away from it! This is how it is when making SubVIs that handle some GUI features. Bundel them in related clusters. Make the references in the SubVIs as little strict as possible (select the most general VI server class that has all necessary properties) to facilitate reuse of the SubVIs. Local variables are changed into the 'bad' value property nodes. Don't be afraid of the possible performance loss. This is only an issue when you operate with huge arrays or nested array/cluster structures, a simple numeric indicator isn't killing the performance. Also there are situations when performance is a minor issue like the init section of a code.

 

One important issue is to group relatet SubVIs together. Use libraries, LVOOP and/or AEs for this. Make your hierarchy window looking pretty.

 

Felix

Message 8 of 9
(6,076 Views)

@dbaechtel wrote:

I also have a bug whenever I try and copy some code that contains one or more local variables. On Pasting the code with local variables, the result is something other than what I expected, I am not sure what. I have to undo the paste and rebuild the code one object at a time. 


Sound like you're trying copy+paste? That'll create new controls/indicators of the local variables. What you'll need to do is ctrl+drag.

That, or it's a bug. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 9 of 9
(5,772 Views)