LabVIEW¶
LabVIEW can directly import and use .NET assemblies without requiring additional wrapper code.
The BenHW .NET assembly (BenHW.dll) is available as a pre-built package and can be imported into LabVIEW to control Bentham Instruments hardware.
For more information on importing .NET assemblies in LabVIEW, refer to the National Instruments knowledge article: How to Call a .NET Assembly in LabVIEW. See the section “Import .NET Assembly Functions with Constructor Node” for detailed guidance.
Prerequisites¶
Before using the BenHW SDK in LabVIEW, ensure you have:
.NET Framework 4.8 Runtime installed on your system. If you don’t have it, download and install it from: Microsoft .NET Framework 4.8
Installation¶
To use the BenHW SDK in LabVIEW, download the pre-built DLL package from the Bentham server:
Extract the zip file to obtain
BenHW.dll(the .NET Framework 4.8 assembly) and the native BenHW DLLs
Usage¶
Once you have extracted the BenHW.dll assembly, follow these steps to use it in LabVIEW:
Adding the .NET Constructor Node¶
Open a VI in LabVIEW
In the Block Diagram window, open the Functions palette
Navigate to Connectivity -> .NET -> Constructor Node
Place the Constructor Node on your block diagram
Double-click the Node to choose .NET assembly
In the dialog, click Browse and select the extracted
BenHW.dllfileChoose the BenHW constructor function (Note: The first “BenHW” in the list is just the namespace; select the one that represents the actual constructor)
Pass the path to
benhw64.dllas a string constant wired to the constructor node’sdllPathinput parameter
Calling SDK Methods¶
To call methods from the BenHW SDK:
From the Functions palette, add a .NET Invoke Node
Wire the reference output from the Constructor Node to the Invoke Node
Select the method you want to call from the list on the Invoke Node
For detailed information about available methods, refer to the .NET API page.
Using Get/Set Methods¶
The Get and Set methods require hardware tokens as input parameters. These tokens are integer values that identify specific hardware attributes.
To use these methods:
Manually enter the token value as a numeric constant
Refer to the Tokens page for a complete list of available tokens and their numeric values
Pass the token value to the
GetorSetmethod along with other required parameters
Example Workflow¶
A typical LabVIEW application using the BenHW SDK might follow this sequence:
Create a BenHW instance using the .NET Constructor node
Call
BuildSystemModelto load your system configuration fileCall
LoadSetupto load your setup fileCall
Initialiseto initialize the hardwareCall
Parkto park all componentsCall
ZeroCalibrationto perform zero calibrationCall
SelectWavelengthto select a wavelengthCall
Automeasureto perform a measurementProcess the returned measurement value
Clean up by disposing of the BenHW instance when done
Error Handling¶
The BenHW .NET assembly throws SdkException when errors occur. Use LabVIEW’s exception handling structures to catch and handle these exceptions appropriately.
For more information about error codes and exceptions, refer to the Errors page.