Advanced Application Specific Architecture Resources March 12, 2009
Posted by ekerry in Software Engineering with LabVIEW.Tags: Architecture, Control Primer, Design, LabVIEW, Machine Control, open source, Reference architectures
add a comment
About a month ago I wrote a blog on LabVIEW application architectures, but I wanted to supplement that with links to more advanced resources that are specific to certain applications and offer a more holistic insight into the task of designing your LabVIEW applications.
- A Primer for Machine Control – If you’re building a large system for machine control using CompactRIO and aren’t sure where to start, this should help. It includes example applications and insights into networking and how to manage multiple tasks.
- 100+ Open-Source Reference Architectures- our systems engineering group is frequently exposed to common architectural challenges faced by LabVIEW programmers on large applications. To keep from re-inventing the wheel, they’ve been publishing elegant solutions to these recurring problems. Examples include Simple Messaging Reference Library, which offers an alternative to shared variables for network communication, 3D Obstacle detection for machine control applications, and a variety of example application architectures.
- TestStand Architecture Series – as automated test systems are becoming larger and more complex, it’s becoming increasingly important to architect your code to ensure scalability, quality and re-usability. This series of content was written largely by NI Alliance Partners who have extensive experience with applications of this nature. The architecture applications in any language is one of the biggest challenges any software programmer faces.
Compared to the task of designing code, the task of actually developing it is often the easiest par. Without careful consideration, many programmers get the ‘re-factor’ twinge about half-way into the development process. If any of this sounds familiar, spend some time looking through these resources to get some insight into paradigms that might help you and your application succeed.
Architecting an Application to Avoid Spaghetti January 16, 2009
Posted by ekerry in old.Tags: Architecture, design patterns, LabVIEW, performance, quality, software engineering
add a comment
One of the most appealing things about LabVIEW is that you don’t need to be a computer scientist to write fairly large and complex software. For many, their journey with LabVIEW starts in school or at a benchtop with a simple application to quickly acquire some data. Once they’re hooked on the ease of graphical programming, it’s only a matter of time beforethe ideas start flowing, and pretty soon they’re off developing amazing applications like a mind-controlled wheel chair, the world’s largest particle accelerator, or how about a 3D Space Ship that flies through a starflied.
The problem is that the same approach people use when throwing together a prototype or a proof of concept will land them in a world of pain if they don’t ever stop and consider fundamental questions like, “how should I architect this application?” All too often, I see the tangled mess of spheghetti code emerge as the result of thoughtless, or ill-planned development.
For most people, their very first experience with LabVIEW leads to messy, un-readible code. Even LabVIEW gurus have humble beginnings. The expert G developer, D Natt, was kind enough to send me a screenshot of his very first LabVIEW program. Let the image on the right serve as an example of what not to do. If you find yourself wishing you had 8 more screens to see a single block diagram, or if your block diagram looks anything at all like this one, you may want to consider giving more thought to the architecture of your application. As an exercise, see how long it takes to determine what the VI on the right actually does.
It’s important to realize that spaghetti code is not unique to LabVIEW. As someone who started with text-based languages, I’ve seen plenty in all sorts of different languages. The difference is that it’s a lot easier to write graphical code that will run, even if it’s completely illegible. When the result doesn’t work correctly or yields unexpected performance, it can be very difficult to debug and many prefer to point the finger at LabVIEW rather than acknowledge their own lack of foresight or experience.
So lets turn our attention to how we can architect our LabVIEW application. Start with the main problem you’re trying to solve and figure out what the software needs to be able to do in order to be considered ’succesful.’ The criteria that emerges from this assessment will help you make informed decisions about how the code should be structured. This is, in many cases, the product of experimenting, prototyping and developing proof of concepts that highlight the areas of difficulty and help you understand what type of information or data will need to be shared between different ‘pieces’ of an application. At this point, we need to take a step back and make sure we understand design patterns.
A ‘Design pattern’ refers to a template that serves as the building blocks for software. If you have an application that requires a responsive user interface, consider how many other developers have been faced with the exact same requirement. You’re not alone, and there’s no reason you should be starting from scratch. Design patterns are universal to programmers in any programming language. They save you time by helping you avoid reinventing the wheel and give us the solutions to common problems that have evolved over time to be the best, and most appropriate solution. If you’re new to design patterns, check out the File >> New dialog in LabVIEW (show on the left). This is a great place to get started with some basic design patterns that are very specific to LabVIEW. Be sure to read the descriptions to understand exactly what problemsthey can best help you solve.
I also recommend visiting expressionflow.com. Anthony Lukindo wrote an excellent, indepth article on the QSM-PC (Queued State Machine – Producer / Consumer) design pattern, which is a fairly common and very useful pattern for a-sychronous computations in a fairly large application.
For those of you familiar with text-based design patterns, AristosQueue posted a great article filled with examples of how to map classics like the Factory Design Pattern to LabVIEW using object-orientation.
The JKI State Machine also serves as another great template for developing clean code.
Architecting a high-quality piece of code ensures that it’s readible, scalable, maintainable and reduces the chance that errors or incorrect behavior will occur. I’ve focused a lot on design patterns, but don’t lose sight of the fact that just is one small piece of the puzzle. You’ll also want to think about how the application can be modularized and design APIs early on. Oh and of course, documentation is paramount.
One final word of caution: keep it simple and pick the archicture best suited to what you’re doing. But as always, have fun
Great Resource for Learning a Common Architecture for LabVIEW Applications November 24, 2008
Posted by ekerry in old.Tags: Architecture, Design, LabVIEW, scalable, software engineering
add a comment
Anthony Lukindo wrote an excellent article on expressionflow.com that explains how to utilize a queued state machine architecture with multiple producer / consumer loops. The example he uses in this article draws from several of the fundamental design patterns that should serve as the building blocks for almost any new LabVIEW application (see image below).
If you’ve never seen them, make sure you review the design patterns that ship inside of LabVIEW as starting points for your applications – even simple ones. You can navigate several Frameworks for development by clicking File >> New in LabVIEW. The dialog that will appear is shown below. Note the descriptions for each design pattern under the image on the right.
If any of you want to add your own design patterns to this dialog, you can. This is potentially useful for groups of developers who would need to use a common, custom template regularly in their work.
To add a template, follow the pattern used for the existing patterns, which can be found here: C:\Program Files\National Instruments\LabVIEW 8.6\templates\Frameworks\DesignPatterns
This should include a png thumbnail and *vit template file. Don’t forget to enter descriptions in the VI Documentation Property so that users will know what they’re getting themselves into!

