Using an ATEasy Exported DLL in LabView

Knowledge Base Article # Q200365

Read Prior Article Read Next Article
Summary This article demonstrates how to export a simple set of ATEasy procedures to a DLL, and use those DLL procedures in a LabView application.
  
Login to rate article

Introduction

ATEasy provides means to create a DLL to export functions written in ATEasy. The DLL can be used within other ATEasy projects, bringing the functionality of the DLL into new ATEasy applications, or they can be used in applications written in different programming languages, such as 'C/C++', C#, Visual Basic®, LabVIEW® and others.  This application note demonstrates how to export a simple set of ATEasy procedures to a DLL and use those procedures in a LabVIEW application.  It will also address areas where special attention needs to be given.

Creating a DLL Project

ATEasy can create a DLL from any Procedure defined in the System module, or any Procedure or IO Table defined in an ATEasy Driver.

Note:  Program module procedures cannot be exported, only driver or system modules can export procedures.

Going forward, the term "Procedure" will be used synonymously to represent either an ATEasy Procedure or an IO Table.  When intending to generate a DLL, an ATEasy project needs to specify if the "Build" will produce an application (EXE) or a Dynamic Link Library (DLL).  The process to build an EXE or a DLL is the same, the difference is whether the project has been configured to produce a DLL.  This can be done either by creating the project using the Startup:Library Wizard (Figure 1), or by setting the project property Target Type to "Dynamic Link Library (DLL)" (Figure 2).


ToolTip  ToolTip
Figure 1:  Startup Library Wizard                                                                   Figure 2:  Project Properties


Note:  When creating a project for DLL export, it is not necessary to include a Program module or a Driver module.  However, both may be included without creating any adverse effects.

It is necessary to also flag which procedure to include in the exported DLL.  This is done by opening the properties dialog for the selected procedure and checking the Export check box.  This is an indication that, when the project is built, to include that procedure, and all procedures with the export check box checked, in the exported DLL.

For this discussion, an ATEasy project was created, and the project target type was set to produce a DLL.  A driver named MyExample was created and four simple procedures were defined to add, subtract, multiply or divide two double precision floating point values, and return the results.  Each of the procedures checked the export check box (Figure 3) in their respective properties.

ToolTip
Figure 3:  Procedure Properties




Note:  When installing ATEasy, two IDE bit-wise versions are included with the installation; ATEasy IDE 32-bit for 32-bit applications (running on 32 or 64- bit Windows), and ATEasy for 64-bit IDE for 64-bit application running on 64-bit Windows. The bit-version version of ATEasy IDE determine the bit-wise of the DLL that is created using the Build command. The generated DLL bit-wise must match the Bit-wise of the LabVIEW - 32-bit or LabVIEW 64-bit.  If you are uncertain which version of ATEasy you are currently using, the "Help:About ATEasy" will identify whether you are running the 32-bit (x86), or 64-bit (x64) ATEasy, as shown in Figure 4.
ToolTip
Figure 4a:  ATEasy 32-Bit (x86)
ToolTip
Figure 4b:  ATEasy 64-Bit (x64)


Building the DLL and Exporting Header File

To compile the DLL, use the same commands from the Build menu that you would use to compile your EXE.  Pay special attention to the Build Log for any errors or warnings.  A clean build should produce a log similar to that shown in Figure 5.  It will list all of the procedures included in the DLL, as well as the DLL name and path.  A good idea is to place the resulting DLL in the appropriate Windows folder for 64-bit DLL's (System32), or 32-bit DLL's (SysWOW64) to avoid potential conflicts.

Note:  When ATEasy builds a DLL, it's possible for some functions to be excluded in the header file.  Excluding functions can occur if some aspect of the procedure you want to export is not supported in the export process.  A common discrepancy is that ATEasy DLL's cannot export arrays to external applications.  If you encounter such error messages, consider using a Variant in your function instead of an array.  Variants can contain arrays, structures, arrays of structures or any other data type defined in ATEasy

Note:  Trial versions of ATEasy cannot compile a project to either an EXE, or to a DLL.  These functions are reserved only for paid license subscriptions.

With a clean DLL compile, the next step is to export a header file (.H) for your DLL so it can be used in applications written in other programming languages.  Select the Active Project you just compiled and select "Export" from the File Menu.  There are two export formats, "ATEasy DLL to C" or "ATEasy DLL to Visual Basic .NET" (Figure 5).  While referring specifically to 'C' and Visual Basic programming environments, that is not to imply that these are the only two languages outside of ATEasy that the DLL or the exported header files can be used with.  This example will use the 'C' header file to facilitate using the DLL within LabVIEW.

ToolTip
Figure 5:  DLL Build Log and Export Header File


Importing the DLL Into LabVIEW

To use the ATEasy DLL in LabVIEW, open your LabVIEW application (32-bit or 64-Bit depending on your ATEasy build) and then use LabVIEW’s Import Shared Library Wizard to import your DLL functions. Please see this ni article Call a Dynamic Link Library (DLL) From LabVIEW© for more details.

Note:  The LabVIEW Import Shared Library Wizard expects a procedure declaration for each procedure you want imported as a vi.  ATEasy v2024 and later include this declaration in the exported header file, while ATEasy v2023 and earlier do not include the declaration.  However, a simple modification to your header file will facilitate the LabVIEW wizard importing your ATEasy 2023 and earlier DLL functions.  Find each of your ATEasy procedure calls in the header file, and for each, copy the procedure call and past a copy of it above the call, appending a semicolon ';' to the end, as shown in the example below:

double MyAdd(double dValue1, double dValue2);
double MyAdd(double dValue1, double dValue2)

The following figures outline the process of using the LabVIEW Import Shared Library Wizard.  These screens were capture from importing the ATEasy DLL created above, using LabVIEW 32-bit.

ToolTip
ToolTip
ToolTip

As an alternative, if your version of LabVIEW does not support the Import Shared Library Wizard, or if you want to use a subset of the functions in your DLL, you can manually import DLL functions into LabVIEW using the "Call Library Function" Node.  Add the Call Library Function Node vi to your LabVIEW wiring diagram and configure it for the return type (if any), and the number and types of parameters in the functions (Figure 6).  The resulting vi's can then be used in your LabVIEW application, extending the functionality of ATEasy into the LabVIEW realm (Figure 7).

ToolTip
Figure 6:  Configuring the LabVIEW Call Library Function Node


ToolTip
Figure 7:  LabVIEW VI's Calling ATEasy Procedures


Summary

The process creating a DLL to facilitate exporting procedures from ATEasy to other programming languages is both straight forward and simple.  Once exported by the DLL, the functionality of the procedure is available outside of the ATEasy.  This includes any resources used by the exported procedure, such as other procedures, variables, forms and instrumentation.  All resources used by the called procedure are embedded in the DLL providing maximum flexibility and utility.

A link to the ATEasy project and resulting DLL's and header file described in this article can be found here: DownloadMyExample Project
Article Date 11/22/2024
Keywords ATEasy, DLL, LabVIEW, Library, Shared Library


Login to rate article

Read Prior Article Read Next Article