Search This Blog

Wednesday, May 11, 2011

Create a DLL in LABVIEW and Using it in VB.NET

Creating DLL in LABVIEW

Step 1: Create a New Empty Project

Step 2: Right click on My Computer icon -> New -> Vi
            New VI file will be opened.

Step 3: Add some Controls as per requirement.
            i.e   2 num controls and 1 num indicator with some mathematic control
            i.e   Addition of 2 numbers

Step 4: In the Front Panel Window, right click on the ICON below the Close button.
            Click on Show Connector.
            Again right click on that and choose the appropriate pattern.
            Now click in the box of pattern and then click on ist control,
            then click on second pattern box then click on 2nd control. Similarly connect all controls with the        pattern box.

Step 5: Save VI file and project.

Step 6: Now right click on the Build Specification in the Project explorer.
            Choose New -> Shared Library (DLL)
Step 7: Click on Information Source , Choose your VI file as Source File.
Step 8: Click on build to Create DLL

Check out other properties like naming the DLL file, how to edit source file again etc.

 Repeating these steps one can add number of VI files. VI file name will be the name of the function or sub.
------------------------------------------------------------------------

VB.NET to use DLL (built in labview)

  'protoptype   MUL_2_NOS is VI files name

    _
    Public Shared Function MUL_2_NOS(ByVal x As Double, ByVal y As Double) As Double

    End Function
or

  Declare Function MUL_2_NOS Lib "DLL PATH HERE" (ByVal x As Double, ByVal y As Double)  As    Double 

   Dim D As Double = MUL_2_NOS(2, 7)

   messagebox.show(d.tostring)

  ------------------------------------------------------------

No comments:

Post a Comment