LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

dll, matlab an LadVIEW

Hi,

 

What do you term a "run"?

 

The way I saw it is that in your program, call it Prog, you run it, do stuff, and then quit (where quitting closes everything). In this case, put the initialize at the beginning of Prog, the terminate in the "quit" area, and there should be no problem. This means that in your compiled exe (that I assume closes everything when it quits) everything should work fine.

 

It is true that this method does not work in the development environment because you don't actually quit. I do not know of a method that works in the development environment, but I assume that you want to build an exe at the end, no? Try compiling and checking with the exe of your program.

 

Thanks,

Danielle

"Wisdom comes from experience. Experience is often a result of lack of wisdom.”
― Terry Pratchett
Message 61 of 86
(2,483 Views)

I see, yeah, I do want to call the dll in development environment for multiple times, not just run and quit everything; then open everything and run again. I want to run VI, stop, run VI again

Arnold
0 Kudos
Message 62 of 86
(2,475 Views)

I have a question, it may be dumb, how can I pass my array data from labview to EXE? I know I can do it easily with the dll. I follow this guide: http://digital.ni.com/public.nsf/allkb/5CF9526FF069EA8E862564C400579DBA, but it still doesn't tell me how to interact with labview data, especially numeric type

Arnold
0 Kudos
Message 63 of 86
(2,464 Views)

In that case, you can create two quit events, one for quitting everything and closing, and one for stopping without quitting (for example, q and ctrl+q). In one case call the terminate (before closing) and in the other don't. Then you can start and stop. Just remeber to terminate before closing everything!

 

I didn't really understand the second question, and the link is broken. Could you clarify?

 

Thanks,

Danielle

"Wisdom comes from experience. Experience is often a result of lack of wisdom.”
― Terry Pratchett
Message 64 of 86
(2,457 Views)

Oh, thanks for your answer, that works well for me. My second question is I know using the EXE will not have this "run once" issue, but I don't know how to pass my data into the .exe as the input arguments. Any idea like how to wire a array data to an .exe file in Labview? DLL is very convenient, u can directly wire the labview data to the "call shared library function".

Arnold
0 Kudos
Message 65 of 86
(2,448 Views)

Hi,

 

I think that there might be a basic misunderstanding here of what compilation means. The act of compiling doesn't change the functionality of your program - if it used a dll before it will use it now as well.

 

Add a while loop or event loop to your code, and have a simple GUI where the user inputs the values he wants and presses "Go" (or OK, or whatever). Write it so that the event of "Go" will be to pass the user parameters to the DLL.

 

There are design patterns using Event loop, you can use this as a basis.

 

Or, I still didn't understand your question, and you need to clarify more, sorry...

 

Thanks,

Danielle

"Wisdom comes from experience. Experience is often a result of lack of wisdom.”
― Terry Pratchett
0 Kudos
Message 66 of 86
(2,439 Views)

I enclosed my .exe wrapper VI. In this VI, I call the myemhmm2.exe in the labview environment. I have two data input array Data_x and Data_t. My question is how can I pass them to the myemhmm2.exe as the input argument?

 

I use a very stupid method, first I write them into a file through "write to spreadsheet.vi" Then I build in a data file loader in the myemhmm2.exe. It can load the data through the file. Then after calculation it write the results data to a file called "tempsave". Then Labview read the data through the "tempsave" file to the 2D array output. I feel this may not the be the most effcient way to pass the input and output because it reqires the file I/O. Any idea for improvement on passing data? Because in dll, we can pass data directly.

Arnold
0 Kudos
Message 67 of 86
(2,429 Views)

It kinda seems like there might be a misunderstanding about what Danielle was saying about using an exe (at least from my point of view). I understood that to mean creating an exe out of your program and running it completely independently from the LabVIEW development environment. Just take your program and compile it to an EXE, and stop using LabVIEW. It seems like you've taken a different approach, and created an EXE just out of a part of your program. You've then modified your program to call the EXE. Unfortunately, there aren't a lot of good ways to communicate between LabVIEW and an independent exe that I know of, so your approach is totally reasonable. You can use command line arguments when you call the exe to point it to a file. Another idea would be to set your exe up as a TCP/IP server, and then talk to it through a TCP/IP connection. You could stream information back and forth that way without involving the filesystem, but it's a little more complicated.

 

Anyway, I kinda like your approach because I never thought of doing it that way, but you must have a pretty good reason to want to work from the development environment (maybe the code is constantly changing and it's easier to debug without compiling in between...?). I've had luck working as previously described, i.e., just calling initialize and terminate once per LabVIEW session.

 

If it works, stick with it.

Chris

0 Kudos
Message 68 of 86
(2,417 Views)

I know this is a pretty outdated post, but I still hope you would see my question.

 

I am currently having the same error you encountered at one point : 

Error 1 error C2371: 'char16_t' : redefinition; different basic types. 

 

I did not get how you overcame it. You downgraded your VC? To which version? After that, the error is simply gone? Many many thanks. 

0 Kudos
Message 69 of 86
(1,985 Views)

Hi,

 

this error means that you have the datatype char16_t defined in two different places. I don't think downgrading is the solution. First, check that you are including the correct libraries of matlab in the correct places (usually includes are in .h files). Second, search for the definition of char16_t, see where it also shows up. Most likely you are including the library from two parallel files.

 

Thanks,

Danielle

"Wisdom comes from experience. Experience is often a result of lack of wisdom.”
― Terry Pratchett
0 Kudos
Message 70 of 86
(1,974 Views)