Global Sources
EE Times-Asia
Stay in touch with EE Times Asia
?
EE Times-Asia > FPGAs/PLDs
?
?
FPGAs/PLDs??

Getting the most from LabVIEW

Posted: 01 Aug 2006 ?? ?Print Version ?Bookmark and Share

Keywords:Jack Jakkidi? National Instruments? LabView? programming techniques? spot light?

Poor programming techniques with any design language can negatively affect an application's performance!especially an embedded application. While efficient programming techniques are important for most applications, the resource-starved environment in which embedded applications operate requires special attention to performance and memory management.

This article discusses the LabVIEW Embedded Development Module, a new tool that delivers graphical system design to embedded developers. The tool lets users intuitively design algorithms and interactively debug them. The following are some tips and tricks to help programmers use LabVIEW more efficiently for embedded applications. Many of the practices can also apply to other high-level tools.

Programming techniques
Allocating memory dynamically!Dynamic memory allocation is an expensive operation that engineers should avoid when possible. It is especially detrimental if dynamic allocation occurs inside a loop to store data in arrays. A common way to avoid dynamically allocating memory in a loop is to pre-allocate the memory needed for any arrays before the loop starts execution.

Shift registers vs. tunnels!LabVIEW shift registers and tunnels pass data into and out of loops. Engineers also use shift registers to pass data between each iteration of a loop. When data is passed into a loop using an input tunnel, LabVIEW must copy that data and pass the copy down the wire to be modified. This is necessary to ensure that the original data stays intact for the next iteration of the loop. Engineers can avoid the copy by passing the data into the loop using a shift register. This eliminates unnecessary copying and speeds up the application.

Large constants in loops!A constant placed inside a loop causes each iteration of the loop to make a copy of that data, resulting in increased execution time and memory usage. Engineers can avoid this by either moving the constant outside the loop or by using local variables to pass data into the loop.

Data type coercion (casting)!The LabVIEW development environment automatically handles data-type conflict whenever possible by converting the smaller data type to the larger one. For example, if there is a type conflict between an integer and a floating-point number, LabVIEW converts the integer into a floating-point number and then performs the operation. This conversion is expensive and in many cases, unnecessary. In most cases, an engineer can avoid coercion by using the correct data type for each variable. But if the data must be coerced, it would be more efficient to convert the data before sending it to the operation or function.

Clusters!Clusters, like C Structs, are useful for bundling heterogeneous data into manageable packages. Along with all of the data, however, information about the contents must also propagate with that data. Especially when passing data to subVIs, unbundled elements!rather than a bundled cluster!increase the speed of user applications.

While high-level programming languages like LabVIEW help engineers deploy their applications faster, it is important to pay attention to details that can improve the performance of code. This can help engineers develop an efficient application in a timely manner.

- Jack Jakkidi
Product Engineer, National Instruments




Article Comments - Getting the most from LabVIEW
Comments:??
*? You can enter [0] more charecters.
*Verify code:
?
?
Webinars

Seminars

Visit Asia Webinars to learn about the latest in technology and get practical design tips.

?
?
Back to Top