Motor Control LabVIEW Driver

Chris Mullin, Ph.D, Principal Automation Systems Scientist, Data Science Automation, Inc.

NI Product(s) Used:
LabVIEW 2020, including Unit Test Framework

Driver Development

The Challenge
A leading manufacturer of motor controllers needed an update of the LabVIEW API to their control software via .NET framework, that included an easy path to update the driver for future .NET updates.

The Solution
Data Science Automation developed a scripting tool to automatically generate the majority of the wrapper functions needed to access the .NET assembly, as well as tools to update typedefs and the text in the icons and descriptions of all the VIs. The VIs are organized into palettes that appear in the Instrument submenu of the LabVIEW Functions palette. The tools automate the process of updating the wrappers when new versions of the .NET assembly are released.

Data Science Automation (DSA) is a premier National Instruments (NI) Alliance Partner that specializes in automating and educating the world leading companies. Clients choose DSA because of DSA’s deep knowledge of National Instruments products, disciplined process of developing adaptive project solutions, staff of skilled Certified LabVIEW Architects and Certified Professional Instructors, and unique focus on empowerment through education and co-development.

Embarrassed by an Old LabVIEW Driver
Our customer has a functioning LabVIEW driver for a line of motor controllers, but the driver did not work for more recent controllers, nor had it been updated to match more recent controller software for the line it was originally designed for. Each function was constructed by hand, so with the burgeoning number of functions available in each controller, updating the LabVIEW driver was too burdensome to maintain.

Scripting to the Rescue
DSA used LabVIEW’s scripting capability to automate the creation of VIs and Controls to match a new LabVIEW driver with the functions and properties of the .NET assembly of motor drive functions.  In particular, the block diagram of a template VI was traversed to find the property node of Commands type (Commands being on object in the .NET assembly). See Figure 1. The AllProps[ ] property of the Commands property node returns a list of the possible selections of the Commands property node.  The script can then step through each selection and obtain a list of the methods available in an invocation node from where the selection is wired. For each method, the template VI is saved after creating the appropriate input and output controls for that method. If more than one input control is required, the controls are bundled into a cluster, so that the connection diagrams for the various methods are consistent. The functions were also filtered so that a single option of each overloaded method is exposed in the LabVIEW driver, according to an XML document that the customer provided. The XML document also provided a description appropriate for each method, so that the documentation of the LabVIEW driver matches documentation for drivers in other languages.

Figure 1 – Template function whose Commands property node can be set to 11 kinds of commands, and whose following Invoke node is changed to execute each method available

A number of functions that were not part of the Commands object were created by hand.  Scripting was used to import an Excel document and fill in the description of each hand-made VI with an entry from the document. Scripting was also used to update type definitions of various status clusters. In that case, a distinct .NET constructor was wired to a property node, and creating a control from the property input created a cluster that could replace the type definition that is used elsewhere to interpret the numeric result of a status request. See Figure 2.

Figure 2 – A VI whose property nodes can be used to create control enums  that are saved as TypeDefs.

Icons for each VI were constructed programmatically using the LabVIEW Icon API library. Layers with the banner, a frame and background, and three text lines were combined and applied to each VI touched by scripting. See Figure 3.

Figure 3 – Use LabVIEW Icon API library to create an icon with border, background, banner, and text desired.

The final tool in the updating procedure is a set of unit tests that exercise each of the hand-made functions and a subset of the Commands methods, to assure the customer that the scripting tools create functional code. The unit tests were created in LabVIEW’s Unit Test Framework.

The Takeaway
The end product is not only an updated LabVIEW driver for our customer’s motor controllers, but the tools needed to update that driver as the controller evolves. The tools take less than 30 minutes to execute if the underlying functions, clusters, or documentation changes.

Leave a Reply

Your email address will not be published. Required fields are marked *