Have to look at the LabVIEW novice 5 big mistakes

While NI LabVIEW software has long helped engineers and scientists quickly develop functional measurement and control applications, not all new users follow the best practices for LabVIEW programming. LabVIEW graphical programming is unique because it takes a glance at the user's application and immediately discovers whether the user is following the best method of encoding. Some users make these mistakes because they don't really understand the principles behind the LabVIEW block diagram data flow, while others don't know which features improve the quality of LabVIEW programming.

This article describes some of the most common programming errors experienced by LabVIEW programmers who lack experience, as well as suggestions for using the correct LabVIEW programming method.

Figure 1. Typical "masterpiece" of LabVIEW newbie

Excessive use of tiled sequential structures

Many newcomers to LabVIEW don't fully understand the concepts behind "data flow" execution, which are the foundation of LabVIEW programming. One of the phenomena is that users often overuse tiled sequential structures on the block diagram. Users often rely on a tiled sequential structure to implement code serial execution of the block diagram rather than using data flow and connections between nodes.

Figure 2. Users tend to over-reliance on tiled sequential structures without fully understanding the data flow programming concept.

Data flow programming means that the nodes (subVIs, primitives, structures, etc.) on the block diagram are only executed when the required data inputs have all arrived. This is very useful for programmers who use LabVIEW because independent processes can run in parallel, while imperative languages ​​require additional setup to perform parallel execution. As computer CPUs continue to grow, LabVIEW automatically decomposes parallel processes to improve code performance without requiring the user to write any additional code. Forcing the use of a tiled sequential structure to execute a block diagram not only limits parallel operations, but also loses this advantage. Limiting the unnecessary structure in the block diagram helps to improve overall readability and maintain a more compact block diagram.

Wrong wiring can effectively implement data flow on the block diagram without relying on a tiled sequential structure, and incorrect wiring can also help implement error handling strategies.

When should I use a tiled sequential structure?

Executing block diagrams through a tiled sequential structure facilitates benchmarking of code performance. By using a sequential structure with a time counter within the framework, you can determine how long it takes for code execution between two time counters. This is not possible with general data flow execution.

Figure 3. The tiled sequence structure and time counter VIs help with benchmarking the code.

For more information on data flow programming, visit the "Data Stream" of LabVIEW Core Course 1 at ni.com/self-paced-training. Users who purchase LabVIEW or have a standard service program (ni.com/SSP) membership can participate in online self-study training for free.

Error using local variables

Another common mistake in LabVIEW programming is overuse of local variables. A local variable is an area in shared memory that is used to pass data between different parts of a computer program. Local variables are often used in text-programming languages ​​and have very powerful features, but problems can arise if there are race conditions.

For other programming languages, passing data through variables is required, and LabVIEW provides a data flow method that moves data from one part of the program to another. LabVIEW's inherent parallelism mechanism determines that users cannot overuse variables because there are usually multiple programs in different locations accessing shared memory at the same time. If you use variables excessively, you will get a "competition" for some read/write operations, and "competition" for other operations. The operation of losing data will be ignored, so excessive use of variables in LabVIEW may eventually lead to data. Lost.

There are several ways to safely transfer data from one part of a LabVIEW program to another, including wiring, queues, events, notifications, functional global variables, and more. Each mechanism is designed for a specific situation, but has the ability to eliminate race conditions.

For more information on moving data correctly within a LabVIEW program, visit the Online Self-Study Training (ni.com/self-paced-training) LabVIEW Core Course 1 "Local Variables" and LabVIEW Core 2 "Notifications, Queues, and event".

Ignore code modularity

Often, new LabVIEW users create "write-and-forget" applications to perform simple tasks without considering whether they will be used in the future. As more and more programming work, they will find themselves rewriting the same piece of code over and over again. And if you create a modular subVI that can be reused for other applications while programming, you can save a lot of development time.

If you know that a particular part of your code will be reused in the same application, or if you feel that it might be used in a future application, you should take a moment to turn that part of the code into a subVI. If you want to make a part of the code a subVI, all you need to do is add a document, use the "terminal", and disable some VI properties. One of the easiest ways to create a subVI is to highlight a portion of the code on the block diagram and select Edit>>Create SubVI from the menu bar. This part of the code will be placed in a separate VI, and then use the "terminal". You still need to add a description to the icon, add the document description to the block diagram and VI properties, and then cancel some of the VI settings, but Edit>>Create SubVI helps you get a good idea of ​​the modularity of the code.

Figure 4. Modular operation with the right LabVIEW code can help you save a lot of development time.

One setting that must be cancelled when the code is modularized is "Allow debugging." You can find this option in the Executions directory under VI Properties (Files VI Properties). When the code is fully operational and you no longer need to use the debug function such as highlight execution, cancel "Allow debugging" in the execution settings and run the VI again. The advantage of this is that the application may run faster due to optimization during the compilation process, and the physical space of the disk occupied by the VI is reduced because the code for starting debugging is turned off.

For more information on code modularity, please visit the "Understanding Modularity" of LabVIEW Core Course 1 in the online self-study training.

Create huge and cumbersome block diagrams

Many new LabVIEW users will write block diagrams very cumbersome. For some complex applications, we inevitably need to write a large block diagram, but the huge block diagram can also indicate that the program lacks a programming framework. Without a basic architecture, it is very difficult to maintain the program for a long time, and it will be very difficult to add new features in the future. Just as there is only one good framework to build a well-structured house, a good programming architecture can provide a safe and reliable framework for building applications.

Almost all programmers will find software architectures that are very useful in common frameworks. In fact, many of the architectures in LabVIEW, such as producers/consumers and state machines, are very similar to other programming languages.

Understanding LabVIEW's architecture can reduce development time and increase application scalability. LabVIEW 2012 includes templates and project examples to make understanding the architecture easier. Templates explain different architectures and applications. The project example is a larger application based on templates, demonstrating how to use templates to meet real-world challenges. You can add hardware to your sample project, or you can use the project sample as a holistic application when you need it, while the project examples are open and documented, so you can customize them for your specific application.

Figure 5. Templates and project examples in LabVIEW 2012 make it easy to understand the software architecture.

For more information on the LabVIEW architecture, please visit the "Design Mode" of the LabVIEW Core Course 2 at ni.com/self-paced-training.

Do not pay attention to document records

Good code documentation can help others understand the programs they write. Unfortunately, many programmers usually start writing documentation after the end of the development cycle. This makes the time for documenting the code very small. The correct approach should be to take the time to start documenting during the development process. The documentation is also very useful for programmers themselves, especially when they come back to the code for a while but don't remember why they chose some code. Programmers often drink coffee while staying up late to program, which often leads to "temporary amnesia." Documents can help programmers remember.

In general, LabVIEW's graphical features make program reading easier than text-based programs, but efficient documentation reduces the time required to "decode" programs. The easiest way to add document comments to the block diagram is to use free tags. You can double-click the left button in the blank space of the block diagram and enter the text to add a comment. Then, use the arrow markers to point to the specific code referenced by the free tag. If you need to add images, you can copy them to the clipboard and paste them into the block diagram. Both physical system pictures and mathematical formulas help to clearly illustrate the code context within the block diagram.

Figure 6. The well-documented and documented code not only helps others understand your code, but also helps you better understand your code.

Documenting the code is not just for the reuse library, it should be for each program. When a person needs to explain to others, he will have a deeper understanding of the subject. Document records are essentially forcing programmers to explain to help them better understand their code.

For more information on document descriptions, please visit the Online Document Self-Study LabVIEW Core Course 1 "Documenting Code."

LabVIEW is designed to help engineers and scientists more successfully address the world's toughest challenges. The LabVIEW community has a large membership of engineers and scientists, providing an effective platform to share knowledge with others. If you are willing to share a newbie mistake you have made, please post to bit.ly/lvrookiemistakes.

We provide quick-turn injection molding by many types of materials, like ABS,  PA66, PBT, TPU, TPE, PVC, PE, NYLON 6,  PC, silicone, TPE, EPDM, PUR, etc.  Special for some plastic parts. Our advantages in internal prototyping, bridge tooling and short-run manufacturing, which can eliminate the costly and time-consuming for customers a lot.  

After customer approved 3D drawing, we can test it by 3D printer first, then move on for formal tooling once confirmed ok. And all  related materials, logo, color or finishes can be chosed as customers' requirement.

Injection Molding Parts

Injection Molding Parts,Plastic Injection Molding,Low Cost Plastic Injection Molding,Plastic Mold Injection Molding

ETOP WIREHARNESS LIMITED , https://www.etopwireharness.com

Posted on