f



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 simple systems and only really used LabVIEW 5 extensively - I am currently using V8.2 evaluation LabVIEW to help me make my design decision and would upgrade for this job). 
 
Does anyone have any advice on how I can use C++ for my card interface and display manipulation whilst still using the toolkits on line analysis? If I build dlls from LabVIEW code and call them from C++ will I have any timing issues?
 
Thanks for any help.
0
x9561 (148442)
4/11/2007 11:10:09 AM
comp.lang.labview 35213 articles. 1 followers. vasusachin24 (1) is leader. Post Follow

1 Replies
1186 Views

Similar Articles

[PageSpeed] 37

Hi,
 
I personally would use LabVIEW for the entire project since it seems that a large portion will involve using LV toolkits.  If your C++ drivers are in the form of DLLs, there is a good possibility you can call them from LV using the Call Library Function.  You can also pass pointers to the DLL from LV. For more information on calling external code, refer to LabVIEW Help under Fundamentals >> Calling Code Written in Text-Based Programming Languages. This method will allow you to use the toolkits easily since you are programming in LV. You should also be able to modify the display screen/front panel easily in LV during run-time depending on what you are trying to achieve.
 
However, if you cannot or don't want to use LV for some reason (DLL is incompatible, LV cannot run the hardware DLL functions fast enough, or already have existing C++ code), then you can definitely build DLLs for the portion of your code that uses the toolkits and call that from a C++ program.  I am not aware of any major performance degradation in timing from calling LV DLLs. 
 
Let me know if you have any more questions.
 
Way S.
NI UK Applications Engineer 
0
x9561 (148442)
4/12/2007 3:40:09 PM
Reply:

Similar Artilces:

call c++ with labview
Hello,   I would like to call a  c++ code with Labview . I use Visual c++ 6.0 and Labview.   Here the code below codesource.zip: http://forums.ni.com/attachments/ni/170/233947/1/codesource.zip Hi, Yes I know ,I create my dll but I didn't succed to import in Labview ...

Re : C++ Call to DLL made in LabVIEW Fails the second time it is called
Five years later, I have exactly the same problem&nbsp;with LabVIEW v.6.1 : It is impossible to call a function from a DLL which was loaded in&nbsp;a previous (ended) thread. Do you know if something had been solutionned in&nbsp;newer&nbsp;releases ? &nbsp; Thanks in advance. Yes, this issue has been fixed in LabVIEW 8.0. Now, instead of using the first thread we spawn our own thread to handle the UI message pumping. I also wrote up an article on this with regards to getting the LabVIEW DLL to work in ASP.NET (where you have little control over threading). The same technique could be done by other applications. I'm not certain whether this works with LabVIEW 6.x as it is well before my time on the team...but it's something to try. <a href="http://detritus.blogs.com/lycangeek/2005/05/labview_and_asp.html" target="_blank">http://detritus.blogs.com/lycangeek/2005/05/labview_and_asp.html</a> ...

methods to call matlab in C C++ and call C C++ in matlab
Hi, I am reading the help documents about how to program matlab and C C++ together and my questions are a little bit general. It seems that are several ways to call matlab in C C++ and another several ways to call C C++ in matlab. Please correct me if I am wrong or missing something when I try to list them. To call matlab code in C C++, are there two methods available? The first one is Matlab engine and the second one is to use MATLAB Compiler mcc to create C or C++ shared libraries from your MATLAB code. To call C C++ in matlab, are there also two methods? The first one is to call funct...

Labview from C/C++
Hi 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 -- _________________________________________________ Alain Migeon Please reverse alain and migeon for replying. On Oct 15, 9:20 am, Alain Migeon <migeon.al...@tdcspace.dk> wrote: > Hi > > 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 > > -- > _________________________________________________ > 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...

Use a wrapper to build a C++ Dll that calls a C++ .lib and Use the Dll is LabView
Hi All, &nbsp; I need to access some functions in a C++ .lib within LabView, but has no source code for the library.&nbsp; 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?&nbsp; I am new to C++, could some one suggest how to&nbsp;use the .lib in Visual C++ 6.0 studio to build the Dll? &nbsp; Thanks for&nbsp;your help. Bryan Hi Emilie, &nbsp; 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.&nbsp; 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?&nbsp; 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?&nbsp; Some of my non labview applications will have their names changed dynamically during execution. I need to know their exact name&nbsp;to access them in a vi.&nbsp;&nbsp; &nbsp; Regards, Bryan&nbsp; BryanL wrote:Hi Emilie, &nbsp; 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?&nbsp; Some of my non labview applications will have their names changed dynamically during execution...

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)? ...

Debugging a C++ dll from LabVIEW
Hello all, &nbsp; What I want to get a feel for is how easy it is to set up the ability to debug code both in labVIEW AND in a C++&nbsp;compiler, say Visual Studio. &nbsp; If we have a situation where we have a c++ dll which we are accessing from labVIEW is it possible to attach the process so that you can set breakpoints in both environments. Hence run labVIEW app and when dll gets called hit a Visual Studio breakpoint? &nbsp; This is a new area to me and I have not found anything regarding debugging. Any comments would be appreciated. &nbsp; Regards &nbsp; Kevin Hi,...

calling a C program from labview
Hi all Please help me regarding calling a C program through labview.I have successfully called a simple c program using a call library function node...making a DLL..but when i call a C program which interns read data through a file..(.txt file)...the labview simply hangs... can you please suggest me some way out... thannks Aparna Hi Aparna, &nbsp; In order to zoom in on the root cause of your problem, it would be helpful to have more information on your application. Have you tried calling your C DLL from any other programming languages? What exactly are the inputs and outputs (along with datatypes) of your DLL? Does LabVIEW give any error message when it "hangs"? I am sure that we can work together to resolve this issue. &nbsp; Regards, &nbsp; Casey Weltzin Applications Engineer National Instruments ...

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, Dan ...

Calling a LabView dll in C++ Builder
I have created a dll in LabVIEW which I have added to my project in C++ Builder.&nbsp; When I run my application it throws the following error:&nbsp; &nbsp; "System error 998 while loading the LabVIEW Run-Time Engine(C:\Program Files\National Instruments\Shared\LabView Run-Time\8.0\lvrt.dll). SHAREDLIB requires a version 8.0 (or compatible) LabVIEW Run_time Engine.&nbsp; Please contact the vendor of SHAREDLIB to correct this problem." &nbsp; C:\Program Files\National Instruments\Shared\LabView Run-Time\8.0\lvrt.dll does exist. &nbsp; Please advise.&nbsp; ...

querry: calling c code through labview
Plz guide me regarding this problem.... I have called a C program using call library function node...that C program reads some data from a file ....on doing so I encounter an error during run time which says debug assertion failed program:\c:\program files\NI\labview7.1\lv.exe File Fclose.c line 58 expression : stream != NULL then i get a message to retry cancel or abort on retrying it shows send error message to microsoft after all this when i try running my C file simply it shows file cannot be opened and now i cant open any file through a C program even those which were running smoothly earlier... Why is this happening and how can this be resolved..... thanks.........aparna Anonymous wrote:Plz guide me regarding this problem....I have called a C program using call library function node...that Cprogram reads some data from a file ....on doing so I encounter anerror during run time which saysdebug assertion failedprogram:\c:\program files\NI\labview7.1\lv.exeFile Fclose.cline 58expression : stream != NULLthen i get a message to retry cancel or aborton retrying it shows send error message to microsoftafter all this when i try running my C file simply it shows filecannot be openedand now i cant open any file through a C program even those which wererunning smoothly earlier...Why is this happening and how can this be resolved.....thanks.........aparna It's very simple. Your C program does an illegal operation that the C runtime libraries report with an exception. This...

labview crashing when calling labview-built dll
Hello I need some help with regard to calling a LabVIEW-built DLL in LabVIEW.I have created a vi in LabVIEW. I made the DLL for this vi. I called this VI as a re-entrant in another vi.This vi(calling DLL) has been working fine till yesterday. Since yesterday, it started crashing LV.I need some help in this regard.I am attaching the screenshots of the Application Builder configuration window, the B.D of the vi using DLL and that of the configuration window which pops up when i call the DLL.I made a vi which performs FRA. I built its DLL.I have around 10 inputs. I output 3 one-dimensional arrays, and a string from the DLL.When i build the DLL, the builder defines the outputs 'gain', 'phase' and 'frequency' as arrays of 8-byte double.When i call this DLL in my vi, the configuration window sets them as 'numeric' outputs.Why does this happen? What is the solution to this?When i try to set them as 'array' in this configuration window, i get a warning that i am trying to change the data types which do not match with the data type found in the DLL. Is this the problem with my code or with the Application Builder?Now, after i change the 3 output datatypes to Arrays, and set their minimum length(i assumed that this value means the size of the array ), the vi runs and crashes LV. I am nto sure when it crashes, why it crashes. It runs fine at one time. It crashes at another time. I am nto sure if these arrays are teh reason why L...

creating dll in c++ and using labview to call it
Greetings All, &nbsp; I have created a .dll file in visual C++ 2005 Express... I have attached both the c file and header file I used to create this dll in the .txt files cfile and header file. I have also included the .dll file itself so that you can use the vi. Please let me know if you have problems using it after you have configured the dll to go to the path you store and call the function ReturnMaxVal.&nbsp; The problem is the max value keeps giving me a rediculous number. I did this with a 1-D array and it was no problem. If anyone can help it would be much appreciated. Thanks, Clint helpPlease!.zip: http://forums.ni.com/attachments/ni/170/270523/1/helpPlease!.zip Hey There, I recompiled your c code and go the same results you got.&nbsp;&nbsp;I see that in the below for loop code,&nbsp;"inputaray",&nbsp;has one r.&nbsp; Was it spelled wrong?&nbsp; I tried to fix it but I"m&nbsp; a bit rusty with pointers.&nbsp; What were you doing in this for loop? &nbsp; _declspec (dllexport) int ReturnMaxVal(double **inputarray,long rows,long columns,double *max) { double **inputaray = new double*[rows]; for (int k = 0; k &lt; rows; k++) { inputarray[k] = new double[columns]; } Hello, &nbsp; are you sure, that you want to reallocate inputaray over and over again everytime on calling ReturnMaxVal()? :) Hi kaem, The function should accept dimensions of array "row" and "column" (ie. 8 x 10 ) ...

Re: Calling C++ DLL function in labview
This is an interesting problem. I am writing a dll that calls Matlab API a= nd LabVIEW API using the "Call Library Function". This requires me to set = up the prototype using the configure option in LabVIEW. The types determin= ed by the configure option are <br><br>long BWD_Read(void *Path, LStrHandle= ID_Name, double *ID, LStrHandle Signal_Array_Name, void *Signal_Array, LSt= rHandle Data_Array_Name, Array2DDouble **Data, LStrHandle Units_Array_Name,= void *Units_Array); <br><br>but when I click on the generate .c file I get= a prototype of <br>&...

Problem with lsb: LABVIEW.LIB was not called from a LabVIEW process
I've decided to compile the Zero Phase Shift.vi filter into a dll. This vi relies on IIR.lsb and IIR.c files. There is no problems with running the vi itself. However,&nbsp;using&nbsp; a dll that was built&nbsp;from this vi&nbsp;&nbsp;generates a fatal Windows error message &nbsp; LABVIEW.LIB was not called from a LabVIEW process (for example, if one tries to call the dll from within a VB program) &nbsp; If I remove the lsb reference from the vi, then calling the dll has no problems. I have tried to reference the IIR.lsb explicitly from the Build Shared Lib wizard, that did not work. &nbsp; &nbsp; I used LabVIEW 7.1 &nbsp; &nbsp; Andrew ZeroShiftFilter_Dll_Problem.zip: http://forums.ni.com/attachments/ni/170/234008/1/ZeroShiftFilter_Dll_Problem.zip ...

Fatal Error
After creating an installaion program, I tried testing the install of my app.&nbsp; The application user interface appears with a Fatal Error dialog box stating LABVIEW.LIB was not called from a LabVIEW process. &nbsp; Other information on this forum regarding a LABVIE.LIB error, usually mention some types of .dll calls, I have no such calls in my application so I'm curious if anyone else has a similar problem and hopefully a solution. &nbsp; Development machine and test install system both XP Pro Using LabVIEW 8.0.1 &nbsp; Thanks in advance. &nbsp; Con &nbsp; &...

c++ calling fortran and fortran calling C++
Hi, For my application in C++, I need to call a subtroutine in fortran. This subroutine must call a function of my program. I'm trying to use pointer of my function but I have segmentation fault. the fortran code is: subroutine dlltest [dllexport] (c_msg,e1,e2,e3,i,r,d,str) c implicit none integer i,l,m,length real*4 r double precision d character*128 e1,e2,e3,str,aux,aux2 external c_msg,length c first, write parameters to a file open(1,file='test.out',status='unknown') rewind(1) c write(1,*) 'function pointer: ',c_msg write(1,*) 'integer: ...

Problem for calling a Matlab generated C DLL with Labview
Hello everybody, I am not familiar with DLL and I need help for using a Matlab generated C-DLL with a Labview application. I have created a C-DLL from Matlab compiler version 4.8 and have deployed it on the host PC using MCRinstaller. So far so good. When I used the VI for calling the DLL, I have the choice between 6 functions: - Initialize - InitializeWithHandlers - PrintStackTrace - Terminate - mlf - mlx Do I have to use all of these functions? In a first attempt, I have created a sequential loop in Labview to run the function Initialize then the function mlf and finally the function T...

How to call LabView function with nested structs and arrays from C#
Hi, &nbsp; I've got the following functions defined in a LabView-dll: uint32_t __stdcall VOSC04_General(uint32_t Command, TD18Hdl *Messages);uint32_t __stdcall CheckDiameter(uint32_t Command, TD6 *Parameter); typedef struct {&nbsp;double SP_Diameter;&nbsp;double SP_Tolerantie;&nbsp;double PV_Diameter;&nbsp;} TD6; typedef struct {&nbsp;int32_t dimSize;&nbsp;int32_t Numeric[1];&nbsp;} TD18;typedef TD18 **TD18Hdl; &nbsp; I've got some C#-code (generated by PInvoke-wizard) to call these functions: [DllImport("vosc04.dll")]public static extern uint32_t VOSC04_General (uint32_t Command, ref TD18Hdl Messages); [DllImport("vosc04.dll")]public static extern uint32_t CheckDiameter(uint32_t Command, ref TD6 Parameter); [StructLayout(LayoutKind.Sequential,Pack=4)]public struct TD18{ &nbsp;&nbsp; public int32_t dimSize;&nbsp;&nbsp; [ MarshalAs( UnmanagedType.ByValArray, SizeConst=1)]&nbsp;&nbsp; public int32_t [] Numeric;}; [StructLayout(LayoutKind.Sequential,Pack=4)]public struct TD6{ &nbsp;&nbsp; public Double SP_Diameter;&nbsp;&nbsp; public Double SP_Tolerantie;&nbsp;&nbsp; public Double PV_Diameter;}; The problem now is that when I try to read the Messages-output-parameter, I get wrong values (pointers?). I think that the problem lies in the fact that LabView generated a TD18 AND an TD18Hdl struct. How can I correct this problem? Can anyone give me some advise to correct ...

Labview Dll call library function Causing Labview to unload
I am trying to use the Call Library function in Labview 7.1 to call an Init function for a Zathic Can4USB device. When I run the vi, it complete log LabView out of the computer. Can anyone tell me why the function totally unloads LV without displaying an error? &nbsp; Thanks Either the function has a serious bug or you are calling it with invalid parameters or wrongly setup parameters. The problem happening here is that your DLL passes somehow invlid parameters to a system device driver and that driver causes a protection fault. For device driver execeptions which happen in the privileged...

Error 1073 when building LabVIEW app which calls LabVIEW dll
I am trying to use application builder to build an application that calls a dll created in LabVIEW. I get an error referencing a vi within the dll (Parse Stored String(multibyte).vi) saying that "This property is writable or this method is available only when the VI is in edit mode." The only option is to Continue which cancels the build. I had sucessfully built this application prior to including vis that call the dll and the program runs fine in the development environment. Do you have any idea what is causing this and what I cam do about it? I have found a temporary workaround i...

Is it possible to call an executable of compiled c code from within LabVIEW?
I can compile 'genesis' (the name of the code we are planning to use) under unix: it produces an executable which can belinked to user-constructed c files which contain specific crossover and/ormutation strategies, so once a user has the executable, it is notneccesary to re-compile the main GA everytime a user mucks around with thecombination rules. I think that a question is, can you call the (or any)executable from within LabView? Thanks &nbsp; Alan Homer ...

Labview Data types and calling 'C' Dlls
I see this question has been posted before, and I have found some answers. But is there a resource that I can reference for more answers? Questions like what is the data type for a Occurrence type? (this appears to be a ULONG32). 'Using External Code in Labview' is helpful but does not have all the answers. Is there anything that can make our lives easier? instead of flattening the data type and guessing? TIA & Happy Holidays!!!!!!! Martin Application note 154 used to have all of these answers. My saved link fails indicating that NI is updating this document. The only idea...

What is the different between c++ call convention and c call convention?
What is the different between c++ call convention and c call convention?Can some give some examples? On Thu, 6 Dec 2007 19:25:57 -0800 (PST), dolphin <jdxyw2004@gmail.com> wrote in comp.lang.c++: > What is the different between c++ call convention and c call > convention?Can some give some examples? Neither C nor C++ define a "calling convention". Particular compilers provide their own "calling conventions", generally based on the underlying processor architecture and usually also on the operating system that the code will run under. If you are interested i...

Web resources about - Should I call C from LabVIEW or call LabVIEW from C? - comp.lang.labview

LabVIEW - Wikipedia, the free encyclopedia
LabVIEW (short for Laboratory Virtual Instrument Engineering Workbench) is a system-design platform and development environment for a visual ...

LabVIEW - Geekosystem
Don we now our gay apparel, and why shouldn’t that apparel be primarily composed of Christmas lights synchronized to flash with music ? Andy ...

National Instruments - LinkedIn
Welcome to the company profile of National Instruments on LinkedIn. It's not what we make. It's what we make possible. National Instruments is ...

Open Directory - Computers: Programming: Languages
about dmoz - dmoz blog - report abuse/spam - help the entire directory only in Programming/Languages Description Top : Computers : Programming ...

Products / Home - g.tec - Guger Technologies
g.tec medical and electrical engineering produces biosignal amplifiers, data acquisition systems, real-time processing systems and EEG Processing ...

School of Electrical & Electronic Engineering - Computing Facilities
In particular, we have technical interests in common with the other Engineering Schools (Chemical, Civil & Environmental, Mechanical and Computer ...

Handy Arduino Uno R3 Pinout Diagram
Loading... « Missed the Maker Faire? Catch the pictures! Music + Floppy = Moppy » The original post from Nick Gammon is old, but I’m pretty sure ...

Curriculum Vitae - Stefano Meroli
Curriculum Vitae - Stefano Meroli

Testing Engineering Supervisor
Testing Engineering Supervisor job. Read the Testing Engineering Supervisor job description and find other Division 10 Personnel jobs at Monster. ...

Knowledge and Content Management: A Foundation for Business Success
Knowledge management and enterprise content management are increasingly at the center of a successful business strategy.

Resources last updated: 3/19/2016 3:42:05 PM