Should I call C from LabVIEW or call LabVIEW from C?
I need to write some software and am trying to choose the best development environment. I currently use Borland C++ Builder to develop most of my software and have also used some LabVIEW occasionally. The new package I need to write has to provide several functions, some of which would be better in C++, some in LabVIEW and I am wondering whether to combine the two. So far, I have had a quick play around and called a very basic piece LabVIEW code, built into a dll, from some C++ code. I am about to try to reverse (create dll in C++ and call from LabVIEW) but would appreciate some advice on the advantages/disadvantages of each method.
Restrictions I have:
1. I will (probably) be using some hardware which will be supplied with C++ driver functions only. My interface with this card is the 'heart' of my system and is time-critical. Also, I need to assign a pointer to pass to this card (could I do this in LabVIEW?)
2. I wish to analyse data from the card using FFT and related functions so would ideally use the LabVIEW Sound & Vibration and Order Analysis toolkits. I need to use these in real-time where the data sampling rate is fairly high (frequency analysis to be done on 4 channels at once with each channel sampled at approx 100kHz).
To add to this, I would like to be able to create/modify the display screen at run-time - something which I am fine with in C++ but understand is very difficult in LabVIEW (I have only used LabVIEW for relatively...Labview from C/C++
My question is about how to call Labview VI/Global variables from C/C++.
We have a cRIO-9012 that runs under the VxWorks operative system.
Up to now, we were calling C functions from Labview, but we also need to
do the opposite.
- Can I call a VI from C/C++?
- Can I access Labview global variables from C/C++?
- Or is there a passive diagram, mapped to a C function, to be placed in
a VI that is triggered by the C function?
Please reverse alain and migeon for replying.
On Oct 15, 9:20 am, Alain Migeon <migeon.al...@tdcspace.dk> wrote:
> My question is about how to call Labview VI/Global variables from C/C++.
> We have a cRIO-9012 that runs under the VxWorks operative system.
> Up to now, we were calling C functions from Labview, but we also need to
> do the opposite.
> - Can I call a VI from C/C++?
> - Can I access Labview global variables from C/C++?
> - Or is there a passive diagram, mapped to a C function, to be placed in
> a VI that is triggered by the C function?
> Alain Migeon
> Please reverse alain and migeon for replying.
The two main methods for accessing the functionality of a Labview VI
from external C/C++ code are ActiveX and Application Builder. ActiveX
is available only on the Windows Platform. Application Builder comes
with the P...Is .NET DLL better to use than C/C++ DLL in labview?
I was wondering which one runs more natively in LabView8.5. C/C++ DLL or DLL by .NET ?Thank you.
You can use either kind, but .NET assemblies are much easier to work with. You can find some tutorials on working with both by searching this site.
...Use a wrapper to build a C++ Dll that calls a C++ .lib and Use the Dll is LabView
I need to access some functions in a C++ .lib within LabView, but has no source code for the library. Can I build a Dll in Visual C++ that calls this library, then have LabView calls the Dll? If so, how different is building this Dll compared to building a Dll from a .cpp file? I am new to C++, could some one suggest how to use the .lib in Visual C++ 6.0 studio to build the Dll?
Thanks for your help.
Thank you for the help. Sorry for the late reply here, got caught into a few busy projects. I do have a difficult LabView problem and hope get some help. I need to move a pop up window by using lvuser32.llb. Are pop up windows from labview or other application such as written by C++ are the same with regular windows? Also, is there a way to find the window names of all open windows including not only labview vi windows but also windows from other applications? Some of my non labview applications will have their names changed dynamically during execution. I need to know their exact name to access them in a vi.
BryanL wrote:Hi Emilie,
Also, is there a way to find the window names of all open windows including not only labview vi windows but also windows from other applications? Some of my non labview applications will have their names changed dynamically during execution...how can i access the C++ DLL source code of labview? how can I creat my own DLL in C++ etc.
I wnat to know how to access the c++ source code of those DLL for
labview? and HOW can I creat my own DLL in C++, or VB and use them in
Well, you don't source code inside a .dll file. You access functions.
All the information about how to access .dll functions, and how to
create your own .dlls so you can access them from LabVIEW, are in the
External Code in LabVIEW</a>
That manual should be included with La...Debugging C vs debugging C++
I was browsing the web pages of les haltton, a software engineering
professor ( http://www.leshaltton.org ) and I found this data in
< begin quote >
Summary of known measurements
� C++ OO systems have comparable defect densities to conventional C or
� Each defect in a C++ OO system takes about twice as long to fix as in
a conventional system.
This is true for both simple defects AND difficult ones. The whole
distribution is right shifted.
� Components using inheritance have been observed to have 6 times the
defe...labview and C++ dll
I have a vi with Call Library Function node call a visual C++ dll. And use this vi in my labview project. Somehow it seems to work for first time only. the next time it get to this Vi, the system seems to hang up. Any ideas?
...C++ DLL in LabVIEW
I have a DLL function call whose definition is
void * OpenComm(Char* device, char autodet, struct settings* setgs);
struct defn is:
how can i configure my Call Library function node for this?
i have used this before, but i have not interfaces with void* and structs!
There's probably another way, but I pass cluster-information as an array (see attached.)
Baud may need the byte-order switched - if your DLL wants it in <a href="http://en.wikipedia.org/wiki/Endianness" target="_blank">Big-endian</a> format.
The Device (char *) input can probably be re-defined as a C-string - then the explicit zero-termination won't be necessary (LabVIEW will take care of it).
As you know, CLF calls can be tricky, hopefully this is at least close to what you'll need. :smileywink:
...debug m-file dll from Visual C++ Studio
I currently use MATLAB 6.5. I made a dll file by compiling an m-file
with mcc. Then I call the dll function from my C program (Visual C++
6.0). It worked fine when m-file was simple, where little parameters
are passed. But as the m-file program becomes more complex, many
parameters are sent and often (almost always) cause errors, probably
mainly the dimension and size mismatches with mxArray variables. I
find it practically impossible to identify the errors with trial and
error approaches. Is ther any way I can use debugger, and set break
points in a displayed dll code?
...Creating a DLL in labview that interacts with a DLL in C++
I?m creating a DLL in LabView that will interact with a DLL created in C++. I don?t have control in the C++ DLL.
Both DLLs would pass a big amount of data as strings between them, for that it is necessary to allocate memory to store information in one dll and read it in the other and viceversa. The first time I will call the other DLL, with this function :
long in texts ( unsigned char *name, void *id)
I would pass them a pointer pointer to an ASCII string (name) and a pointer to an unspecific data structure (id). The id would then be passed to me by his DLL whenever they use one of the functions implemented on my dll.
What I don?t know is what to pass as a void*id? What are they expecting? A number? A cluster?
The other thing I don?t know is how to allocate memory in labview and write there information, such as a string, and then tell the other DLL to look for the information at that DLL, and viceversa. I hope I made my self clear, hope somebody can help me, and please indicate me if you need more information
...C and C++ colloding! // How to debug a DLL?
I have a bigger VC++6.0 project which is successfully compiled into a
DLL. It's compiled with full conformance with the ANSI C standard
(symbol __STDC__). I had to combine this code with my one (C++) which
worked fine for itself. After integrating my code one into one of the
classes the the compiler threw errors. They disappeared after the
compiler option __STDC__ was removed. My code is C++ code (and can't
be rewritten), thus the errors when compiled with __STDC__ activated.
An additional __ANSI_CPP__ is defined in the DLL project as well, but
doesn't seem to harm or benefit ...how to create a .dll file for LabVIEW 8.5 in visual C++ .net 2003
I want to know the detailed procedure for creating a .dll file in Visual C++ 2005 or Visual C++ .NET 2003. I have a C code which i like to compile but all the steps i have followed from the NI site result in some or the other error. Please help me witrh it.
I'm not really familiar with the process (and perhaps the forums at microsoft might be better suited to handling how to build a dll in their environment), but I imagine you were talking about our <a href="http://zone.ni.com/devzone/cda/tut/p/id/3056" target="_blank">Building a DLL with Visual C++</a> article? Are you seeing errors in LabVIEW as you try and use the .dll once it has been built? If so, what are those errors?
...labview vs visual basic vs visual C
I am hoping to get advice about LabVIEW vs Visual Basic/C for developing education software. I have programmed in LabVIEW for test and measurement applications.
I have also programmed a couple of short programs in C , but have never programmed in Visual C or Visual basic. I want to develop software for educational purposes for
students with special needs such as spelling and reading comprehension programs. These programs would involve a lot of displaying text, graphics and
sounds to the students and measuring student inputs via text or clicks on buttons to determine whether they need additional help from the computer to learn the lessons.
I was was wondering if anyone has the knowledge to advise using LabVIEW vs Visual C vs Visual Basicfor such programming tasks?
I am guessing that Visual C and Visual Basic may have more flexibility in displaying text, graphics, sounds etc. since this is mostly what they used for. On the other hand,
I am famliar with the ease of coding in LabVIEW for test/measurement applications but wondering if there might be limitations or difficulties in programming with LabVIEW
for a more general purpose windows application such as the education software I am planning. I would have to learn Visual C or Visual Basic, but if those environments
would be easier or better in ...Error while using LabVIEW 8.2.1 Dll from Visual C++ 6.0
I am getting an error while using a LabVIEW 8.2.1 dll from Visual C++ 6.0 application. This is what I am doing:
1) Created a dll using LabVIEW 8.2.1 (I used a tutorial from NI knowledge base: "Creating DLLs from 6.0i". It is a temperature conversion VI; input DegreeF and get DegreeC out). Instead of LabVIEW 6.0i, I used 8.2.1. It created the dll Convert_Temp.dll successfully.
2) Then I created a Visual C++ 6.0 application (used a tutorial from NI knowledge base: "Calling a DLL from Microsoft Visual C++ that was Generated by LabVIEW 6i). I could build the project and create an executable application F_To_C.exe.
3) Then copied the LabVIEW dll Convert_Temp.dll into the folder where F_To_C.exe resides. Using windows explorer, went into that folder, and executed the application. I got the following error:
System Error 998 while loading the LabVIEW run-time engine (C:\Program Files\National Instruments\Shared\LabVIEW Run-Time\8.2\lvrt.dll).
Convert_Temp requires a version 8.2.1 (or compatible) LabVIEW Run-Time Engine. Please contact the vendor of Convert_Temp to correct this problem.
I checked the folder: C:\Program Files\National Instruments\Shared\LabVIEW Run-Time\8.2\. It has the file lvrt.dll.
So why am I getting this error?
...Is it possible to manipulate and use variables and parametres from a .dll converted progr. (C++) with a labview written progr.
I got a program written in C++ and I want to comunicate with it and use some parametres and variables from it, to handle these with my labview written program.
I just want to be shure if it is possible??
...Using labview dll in C#
I m trying to import a labview dll in C#.
The functions exported by the dll return invalid results when used in
However when the same dll is used in simple C/C++ application, they
return expected results.
Are there any compatibility issues between C# and labview?
Please let me know if there is a solution for the same.
Thanks and Regards,
...calling LabVIEW dll from C#
Could somebody post a fully working C# example of calling a function
from a LabVIEW generated dll with passing strings and integers in and
a couple of strings out?
What should be settings when creating the dll, of course (which
convention, how to pass)?
...C to Labview
I am fairly new to Labview and I have been given a project at work to convert an existing c code to labview. I will provide the section of the code That is giving me problems to see if any of you could assist me in writing it in labview.
void CPokey2Dlg::FindN(unsigned char Channel)
NFrac = FreqOne/(double)2.8e6;
NReg = int(NFrac+.5);
m_EditChannelTwo = NReg;
// if (NReg >= NFrac)
NFrac = (double)262144*(NFrac - (double)NReg);
// NFrac = int((262144*((double)NReg-NFrac))+.5);
if (NFrac <0)
NFrac = int(NFrac -.5);
NFrac = int(NFrac +.5);
// m_EditChannelTwo = NFrac;
NReg = NReg - 32;
iDividend = (int)NFrac;
m_EditChannelTwo = NFrac;
// format for register
SKY72300 = (unsigned char)(NReg >> 8);
SKY72300 = SKY72300 & 0x01;
SKY72300 = (unsigned char)NReg;
SKY72300 = (unsigned char)(iDividend >> 16);
SKY72300 = SKY72300 & 0x03;
SKY72300 = SKY72300 | 0x10;
SKY72300 = (unsigned char)(iDividend >> 8);
SKY72300 = 0x20;
SKY72300 = (unsigned char)(iDividend);
...labview UI in Visual C
I'm in the process of trying to merge a LabVIEW app into a third party application. In order to interact with this other application, I need to create custom COM objects that inherit from their provided classes: no fun, but fine. I'm having trouble getting LabVIEW windows to interact properly with the windows from the main app. In one case, for example, my COM function is passed a HWND from the app that I'm supposed to use as the parent window for a dialog. They of course expect me to derive from CDialog or a property page, but I want to use a LV window. I'm able to create LV windows by calling VIs out of a LV built DLL, but they don't behave properly with the app because they don't insert properly into the app's window hierarchy. Windows that are set to be modal in LV are not modal to the app. Plus, the other app windows don't redraw properly when the LV windows are moved in front.
As a work around, I tried creating a CDialog window in VC, made my LV window a child to it using the SetParent Windows function and then maximized the LV window to take up the bounds of the dialog. This nearly worked since the Dialog behaves properly with the app, but the LV window then fails to redraw itself when things pass in front of it.
I had the idea of trying to embed the LV remote panels activex control, but after reading a...build a DLL in LabVIEW & Use the DLL in LabVIEW
I am trying to build a DLL for the simple vi with LabVIEW and want to use the DLL in LabVIEW. is it impossible?
I wrote a vi and it have 2 terminals. one is the input for numeric dbl data type and one another is the output for numeric dbl 1D array data type.
It was built with the Application builder for LabVIEW 8.0 and DLL was created successfully.
I want to use this DLL in new vi with LabVIEW.
Call library function used. I wrote a new vi to use that DLL.
In config dialog I config each parameter for dll and connected terminals. but it doesn't work
pleas refer to the attatched file and let me know what I missed.
...Calling a LabView DLL from a Labview VI
Hi, I have a vi that is calling a Labview DLL and they both have a same
subVI. If I drop that SubVI into the block diagram first then drop in the
Call Library Function Node, when I run the VI, the DLL would not work and
it did not give me any error. Does anyone know how fix this problem with
Labview? or is there some configuration that I can force the all of that
SubVI points into the DLL.
Thanks for your help,
...[ann] C/C++ interpreter Ch for labview released
Ch is a free C/C++ interpreter.
The source code for embeding Ch into labview is now available from the
More about C/C++ interpreter Ch can be found at
Any comments or suggestions are welcome
That's realy cool
...Visual C++ by-passed when debugging a c++ MEX-file
I used matlab 2007b, vs2003 as compiler and debugger.
I generated my dynamic library(filename.mexw32) for matlab from c++.
It was 'mex -g' compiled successfully, from 2 cpp files and a couple
of headers. I want to debug using visual studio 2003, I followed the
However, every time I set up the breakpoint and debug (F5) from
VS2003, the matlab 2007b got launched and vs2003 (strangely) went out
of debug mode. If I ran matlab routine to call the mexw32' library, it
won't stop at my breakpoint.
This 2007b+vs2003.net method worked fine before, to other projects
(all of which contains only one source code file). I suspect this must
have to do with the project settings. But I cannot seem to find out
what is that. I used the same setting as those successful projects.
Any help will be much appreciated.
I had this problem and finally I remarked there are two
matlab.exe. One in C:\Program Files\MATLAB\R2007b\bin and
the other in C:\Program Files\MATLAB\R2007b\bin\win32. When
I configured my MSVC, I choosed the first one instead of
the second one ... Maybe this is the key of your problem.
Vanderbilt <email@example.com> wrote in message
> Hi all,
> I used matlab 2007b, vs2003 as compiler and debugger.
> I generated my dynamic library(filena...change a LabVIEW array outside LabVIEW and keep updated in LabVIEW
change a LabVIEW array outside LabVIEW and keep updated in LabVIEW
I am Interfacing a FrameGrabber with LabVIEW using a frame grabber
The memory managment of this FG allow you to allocate your own Array
and to give a pointer to this Array to the memory manager.
Then when you acquire with the frame grabber, the acquired image will
be directly accessible in your array.
1.I give to the FG memory manager a pointer to the Labview array
through a SDK Dll function.
2. I run the acquisition
3. I display the array
My problem is that the Array is allways displayed with it initial