Slow labview dll

Hi helpers!

I use a very simple VI as a DLL in a c program ++ (using Visual studio 2013).

I'm doing an explicit support for the DLL and create a pointer to my VI via LoadLibrary and GetProcAddress.

My program work, but unfortunately, it is very slow (about 2 seconds to compute 1 + 1 and the output result).

DWORD dw = GetLastError();

typedef double(CALLBACK* LPFNDLLFUNC2)(void);

hDLL = LoadLibrary("SharedLib.dll");

    if (hDLL != NULL)
    {
        lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL, "Vi1");
        if (!lpfnDllFunc1)
        {
            FreeLibrary(hDLL);
            std::cout << "failed to create pointer on function << std::endl;            ExitProcess(dw);
        }
        else
        {
            std::cout << "Function loaded" << std::endl;
            double test = lpfnDllFunc1();
        }    }    else    {        ExitProcess(dw);    }
double __cdecl Vi2(void);

I use the _cdecl convention.

Can somone help me get this call dll faster?

What I am doing wrong?

And what is your "test: xxxxx ' output in the console?

Also, there could be a DLL initialization and interface to be resolved on first call late! Try calling several times and see if the following calls are always too slow than you think it is.

Tags: NI Software

Similar Questions

  • Loop timed in LabVIEW DLL does not close

    Hello!  I have what I think, it is a simple loop timed in LabVIEW that stops after 100 iterations by throwing an error and letting the loop 'stop on error.  It works fine when it is executed in the ordinary LabVIEW environment, however, when compiled as a Dynamic Linked Library (DLL) and called from LabWindows it requires me to put an end to execution, rather than going out nicely.  As well, it seems to leave the real appeal of virtual Instrument very well and go to the next line of code, but when my function main() in LabWindows is completed it must always be something not cleaned which is the cause not come out well.  Any ideas?   I tried to add only a call to QuitLabVIEW and that doesn't seem to do it.

    Thanks in advance - hoping you will notice an error really easy. )

    A photo of the timed loop is attached.

    An excerpt from the code of LabWindows:

    int main)
    {
    CallMyLabVIEWDLL();  This line launches successfully and closed the window for my virtual instrument LabVIEW
    MessagePopup ("' My Title:", "That occurs after the call to your LabVIEW DLL" ");    This popup appears - indicating the call to the DLL has finished

    But after the code has completed LabWindows always shows "running", rather than close.

    return 0;
    }

    Why do you use a loop timed in the windows environment?  They are best used for real-time environments (not windows) and tend to have more support than the time.

    Is there a particular reason, a while loop will not work?

  • LabVIEW DLL called from C

    I would like to create a DLL in LabVIEW which can be called from a C program.

    The purpose of the DLL is to display a dialog box along side a C program user interface and view a picture is updated continuously in the program.

    The LabVIEW DLL would be

    1 would be considered to be a dialog box that opens up along the side of the user interface of the C program.

    2. the DLL would regularly be called with the parameters passed by the C program.

    3. the dialog box would contains a picture that is updated by the parameters of the permanence of program C.

    Is this feasible?  I assume that the DLL has to work like a demon, because the DLL is a dialog that must cover along the side of the user interface of C.  To run a DLL written in LabVIEW, is the needs of PC - the runtime?

    Everything was OK until 5. For 6, you do not get a reference to something C. You simply call the exported function that is the VI 'set params.

    I have included a sample project to give you an idea. The code LabVIEW is written in LV 8.2 and the project with a version of a DLL specification. I used c# for this example, but you can easily translate it c If you wish.

  • Generation of C++ with LabVIEW DLL error

    Hi, I am a student at the UC Irvine, learn how to use LabVIEW.  I'm working on a practice project for which I use a PID system to control the temperature of an object.  Things are starting to be a little awkward with the control statements nested, loops, etc., so I thought I have exported a LabVIEW DLL with all the difficult to encode things like interfacing with my instruments and tracing of data or something else and do the calculation and follow-up of the commands in C++.

    The DLL file I made in LabVIEW exploded without a hitch, as far as I can tell, but when it a link to my C++ test program (which at this point is just including the .h file of the LabVIEW for the DLL and an empty main() function), I get a lot of build errors.  I'm using Dev - C++ that uses g ++ to compile the code.

    Here is a picture of my build errors:

    Normal windows applications are not so forgiving on where you can put your DLL under LabVIEW. You must have a DLL or in the Active Directory where the executable file itself (this is your build directory, not the source directory), windows or directory system or any what directory defined in the PATH environment variable. Anythin else probably won't work, or at least not reliably.

    No need to add the cintools directory to your include paths or paths of the library file. You must only that if you decided to leave native LabVIEW DLL export data types, in which case you would need Manager of LabVIEW to prepare the correct data buffers.

    Rolf Kalbermatter

  • Problem calling LabVIEW DLL with c#

    Dear all,

    I compiled a few DLLs in LabVIEW and called these DLLs using c#.
    I'm having trouble passing in strings and arrays as input and output of the DLL.

    Whenever I try to view the string I have entered in a dialog box (this part is written in LabVIEW DLL), a LabVIEW message dialog box appears and the program just stuck there.

    Whenever I try to enter a string or an array to the dll, Microsoft Visual Studio would display "attempt read or write protected memory. It is often an indication that other memory has been corrupted. »

    I attached the vi and also the c# .sln file.

    Can you guys please advise where am I wrong?

    Thank you very much.

    You must allocate strings and arrays of output!

    private void button1_Click (object sender, EventArgs e)
    {
    output string;
    int [] value;
    StringOutput ("A", "B", exit, 3, value, 4);
    }
    }

    Your variable output and value must be preallocated to ensure storage of 3 items respectively. 4. and since you want to receive the C string that you need to increase this to 4 characters terminated by a NULL value.

    String in c# is also a not a C string of object pointer. You must declare the StringOutput() function as follows:

    [DllImport("SharedLib.dll",CallingConvention=CallingConvention.StdCall, Charset=CharSet.Ansi]internal static extern int StringOutput(StringBuilder A, StringBuilder B, out StringBuilder StringOutput, int sizeString, out int[] output, int sizeArray);
    

    Then call like this:

    StringBuilder output = new StringBuilder(4);int[4] array = new int[4];
    
    StringOutput("A", "B", output, output.Capacity, value, value.Length);
    

    Please note that I'm not a pro in c# and usually do not do much in it. Also that this code has not been tested or updated at all, so probably contains some errors. He however point you in the direction of where to look further.

    What you need to understand, is that the C DLL that you created in LabVIEW has a so-called unmanaged interface. This means c# is not able to know how to manage the memory for the parameters at all and you have to do everything yourself, where the obligation to explicitedly initialize variables output and table with a block of memory préallouée.

  • Get the 1097 error when trying to call a Labview DLL

    I had to write a wrapper DLL to use some functions in the DLL to a third party, and I'm having a few problems. I created an executable to test my code and it works fine, but when I try to execute the same function in the DLL that I created in Labview, I get error 1097. I read through most of the posts on this forum about this issue, but none of the proposed solutions are working for me. I'm sure this isn't a question of transfer settings to COLD LAKE because I changed the function so it only accepts a single entry (a number he obtains from a Subvi, which came from the third-party DLL, this entry is working with a bunch of other functions, so I don't think that is the question).

    I have attached the C code that creates the wrapper, but I don't know how it is useful without familiarity with the functions of the original DLL. I hope that someone can spot something basic I am out of my code, but please let me know if I need to call something else.

    I use a Labview 32 bit version 2012 on a 64-bit Windows 7 computer.

    Thanks in advance for any help!

    You should read the documentation on LoadLibrary() and understand. Essentially if you provide a full path to LoadLibrary() the DLL MUST be present at this place so that LoadLibrary() will succeed. If you pass only the name Windows DLL will ONLY search in these places:

    (1) if the module (the DLL) is already loaded it will return a handle to the loaded module and increment its reference count

    (2) if the referencing module contains a manifest (either incorporated into the image module or in a separate manifest file in the same directory as the executablemodule) specyfying a version number for this DLL will load this DLL with this version of the SxS (side by side) location and failure if it is not present

    (3) if the executable load contains a manifest (either incorporated in the executable file or in a separate manifest file in the same directory as the executable file) number specyfying a version for this DLL, it will load this DLL with this version of the location of SxS (side by side) and fail if it is not present

    (4) it will search for the DLL in the same directory as the directory where the current image of the process is loaded. It is NOT the directory of the DLL loading the DLL, BUT the directory where the EXE file from which the process was created.

    (5) in the system directory

    (6) in the Windows directory

    (7) any directory in the PATH environment variable

    (8) the path of current directory which is a location managed by windows by process and changed the two explicitedly when the application calls the API SetCurrentDirectory() but also implicitedly by things like the file selection dialog whenever it is rejected by other means than the undo operation.

    Essentially putting your dependend DLL in the same directory as the wrapper DLL does NOT work when you use the name of the DLL only UNLESS you place the two DLLs in the same directory as your executable file. If you don't want this restriction and want to be able to move these modules together in different directories, you don't have to create the correct path in your wrapper to LoadLibrary(). Basically, you must have the code to determine the location of your DLL wrapper path and then strip her own name and add the DLL name wrapped in it and then move to the LoadLibrary().

    There are several ways to determine the path of the current module. The simplest if you don't mind having the name hard-coded in your code DLL would be to ask GetModuleFileName (GetModuleHandle ("yourDLLname"), buffer, size).

  • How to pass the Visa Resource Name parameter to labview dll in labwindows/cvi

    Hello world

    I build a dll of labview, the prototype is: double getchannelpower (double f, uintptr_t * VISAResourceName);

    I don't know how to go from VISAResourceName to this function.

    Is it related to the ViPSession paremeter in function viOpen(REES ViSession, rn ViRsrc, ViAccessMode am, ViUInt32 ti,ViPSession vi)?

    BRs,

    lotusky

    Hey, guys:

    I figured out how to pass the parameter.

    In labview, you must replace the control of visa with string control. In this way, the generated dll function at the entrance of the string type.

    I hope this will help others!

    lotusky

  • (UN) Managed Wrapper calling LabView-Dll

    Hello

    I'm focused with a strange behavior that I couldn't explain.

    I had to extend the NI272x in my environment unmanaged c++ to a StepType http://sine.ni.com/cs/app/doc/p/id/cs-11443/lang/de/pdf/yes/pdf that descripes a functional testsystem.

    Provieds let us OR no C Api for this devices. But the LabView drivers were available. So I did LabView Wrapper
    to consume. It worked well.

    Current development of extension is done in c#. During execution, it loads the unmanaged Dll StepType old. If the Dll of LabView is
    used. I'm not able to load the DLL with c# via LoadLibrary SDK to memory.

    To understand what is happening I have provied a small project that descripes the task.

    Concerning

    Jürgen

    I think that the problem is that the dll you load dependent DLLS. The normal behavior of the LoadLibrary does NOT automatically search the dependent DLLs in the same directory as the dll you are loading. You must instead use LoadLibraryEx with the LOAD_WITH_ALTERED_SEARCH_PATH option (it's what teststand uses when loading DLLs with adapter c ++). See info on help from Microsoft on MSDN for details on LoadLibraryEx and LOAD_WITH_ALTERED_SEARCH_PATH.

    Hope this helps,

    -Doug

  • How to use in LabVIEW DLL of the third

    Hi all

    Using maxon EPOS 2 (positioning system easy) to order the EC motor. It comes with Windows 32 - Bit DLL for labVIEW. How to use these anointings of library in labVIEW correctly? When I try to call the function of library in a LabVIEW program, it shows me a warning about a caller and if the Subvi is not executable. Do I have to change the location of files library or make any other change?

    Have you seen the KB: program a control EPOS of Maxon use LabVIEW ?

    Christian

  • TestStand do not call a Labview DLL copied to a new location.

    TestStand v4.2 & v8.6.1 LabVIEW: I have a problem with TestStand calling a Labview project DLL. It will call the DLL successfully if it points its record source (the directory where the DLL was built. However if the DLL is copied to the clients working directory and the appellant TestStand step points to the copied DLL, the problem occurs. The TestStand calls the DLL from the working directory of the client, but does not execute the DLL, simply set the status of the step to "Done" where he clearly didn't.

    The vi named in the DLL has correctly, all handles error clusters such that if there is an error in the vi running, the error would be forwarded to TestStand.

    Any ideas please?

    Update: the original problem was never solved, but another method was used successfully to generate an Excel results worksheet. This used controls Active-X to open a file, import a model, write the data, close the file, and then make the new file read-only. It now everything works fine.

  • Set the string for LabView dll parameter

    Hello

    I created a simple vi LV 2010 (departure vi), which reads the identification of an oscilloscope. Then I take this vi and incorporate it into a dll of LabView. I have test the dll calling LabView (RunFrom dll). Basically, it seems to work, but len and ReadBuffer back empty. It must be in the way I'm configuration configuring the setting for Readbuffer (settings) in the configuration of the dll. I tried several different configurations, but nothing seems to work. Any help is appreciated!

    What is the parameter len?  Normally, you should only set the length of the string, but it seems that you did not do this.  Also, you're passing len by value, and not by reference, so the function is expecting her to be a starter and you will never get return a different value to any value that you provide.

    Do not use a local variable of the ReadBuffer for entry "readbuffer".  You must pass a string initialized long enough to contain the expected quantity of data.  The best way to proceed is to use the array to initialize to create a table of U8, then use the array of bytes to a string.  Set the parameter 'minimum size' to 'len' then run through the length of the string initialized (this is not mandatory but is recommended).  If you need the length obtained output, add another indicator and another parameter to this value.  There might be a way to do it with one by len parameter passing by reference, you need to experiment (it is certainly feasible in C but I don't know if allows him to LabVIEW).

  • Extremely slow LabVIEW 2010 icon editor

    Working on a project of medium size in LabVIEW 2010.  Out of the blue icon editor is slowing down.  So slow that type in a character of text takes 20 seconds.  After closing, the editor he is about 3 to 5 second rule on everything that I do in LabVIEW.

    LabVIEW games restart things back to normal, until I open the icon editor.  No results of Subvi opening in this problem.  And this happens in any project or even if no project is open, and I'm trying to change the icon in a Subvi Untitled 1.

    Anyone else seen this behavior.  I really want to re - install LabVIEW 2010.

    Thank you

    I've not seen this behavior, and I really have no idea what could be the problem. As a solution, we can 'turn off' icon editor and force LabVIEW to use the old classic that is causing the problem to go, in my opinion. To do this, rename the following lv_icon.bak:

    [2010]\resource\plugins\lv_icon.vi LabVIEW

    This will completely ignore the code from the editor of icon and go directly to the editor of classic icons. You will lose a lot of the new functionality of the icon editor, but I'm guessing that this will make the downturn go away.

  • Question about support for LabVIEW DLLS and Unicode

    Hello

    I have a question about LabVIEW and DLL functions calls.

    I use a DLL (sorry, I can't share it) that was written in C. It was written to support Unicode and non-Unicode function calls.

    The Unicode function is valid, then FunctionNameW is called if FunctionNameA is called.

    I am building a few VI to access the library. I have the regular functions of FunctionNameA work.

    My question is, does LabVIEW support versions of function FunctionNameW Unicode, and if so is it necessary Although LabVIEW is already working with the standard function call?

    Am I being redundant or what should I build in Unicode support?

    The first time I tried to test the Unicode functions, I had an error, and I guess this is a system setting.

    Thank you for your time in advance.

    DB_IQ wrote:

    I don't think I have TO implement the Unicode, but I want if I can.

    For what I do, I think almost it is not serious. But I wanted to know if it could be used.

    The short answer is "Yes, you can do it."  However, it may open a new Pandora's box.  If you're not careful, problems and complications that can still spread to other projects that are not using Unicode!  It is better not to summon this monster unless there is absolutely no other way to do the job.

  • Slow LabView 2013

    Hello

    I have ver 13.0.1f2 2013 Labview Professional Dev system SP1 (32-bit) and it's slow when I am developing an application.

    For example, if I have a tab control and I change to another tab, it takes about 2 seconds to change tab after I click on it.

    If I have a new line of wire, it takes 2 seconds to appear this line in the block diagram and so forth.

    I have a new computer Dell Optiplex 7010, 3.40 Ghz i7 processor, 64-Bit, 4 GB RAM, WIndows 7 SP1 enterprice

    If I run the Windows Task Manager it shows that 17 percent of CPU usage and 2.14 GB of memory.

    If I run for example, excel 2013, it seems to slow down.

    Do you have any suggestions?

    Concerning

    EDGAR_PLATRONICS wrote:

    Hi Yamaeda:

    I'm not sure massive compilation. You mean rewriting the code? Or create the test and the exe file?

    At that moment, I checked with a Vi, but it is very large. A lot under the screw and the code.

    In fact, it worked correctly in labview 8.5, but I converted to LV, 2013.

    I do research on the transparent borders overlapping.

    Hi Altenbach:

    17% is global. 3 carrots are % high than others.

    The problem is in edit mode, and also when I run the program.

    Yes, I have several lights on the front panel, but I don't think they have tons of data, but I'll check.

    When I opened my VI in labview it shows 118 MB of memory during execution and 124MB in the editing mode

    Moreover, last week when by mistake I moved a part of the code to a few centimetres below, block diagram has been frozen and has been updated to new position but line-by-line up to complete full-screen. I took about 5 minutes to work normally.

    I use 2 monitors on my PC. One to display the LV Panel and one for the code LV.

    I meant tools-> Advanced-> mass compile and recompile your upgraded code. In the same way as a ctrl + performance table will require recompile your program. It can help. Otherwise you're down for example by using VI analyzer tool to find the culprit, it might be a few VI which is damaged and needs to be moved to a new VI.

    /Y

  • I would like to only convert a c++ for use in labview dll - my camera has no DLLs in labview

    I have a piezoelectric Control Board (Piezomechanik gmbh) that I would use through LabView.  Currently, the company offers no support for Labview.  Windows detect the device (it came with a driver file), but the company only provides for C++ and Visual Basic dll files.  Can I convert these files to a format that can use Labview?  How can I get Labview to communicate with the control of Narcotics (and ultimately the piezoelectric device attached)?  Thank you!

    This will help you only when you have the header for the DLL file, otherwise you have to create manually using the "call library node' and the description of api DLL wrapper or write a header file for the DLL yourself based on the documentation of the api and the wizard.

    Kind regards

    André

Maybe you are looking for