LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create header file

Solved!
Go to solution

Hi, I made a project in LabVIEW and created a dll from it that should be used in another environment (Visual Studio). I made a VI for each function I needed and connected inputs and outputs to the icon as usual. The problem is that the functions declared in the header file of the dll seem to be wrong.

For example, the VI "white_noise" in the attached image has no input and one output (the array), but in the header file I found this:

 

void __cdecl White_noise(double noise_array[], int32_t len);

 

That seems to be a function in which there are two inputs (array and len) and that has no outputs (void).

The same thing happened fot the other functions of my dll... Why? What am I doing wrong?

0 Kudos
Message 1 of 8
(5,052 Views)

I haven't done any DLLs, but comparing to how you have to call DLLs in LV; could it be that you feed the function the array and integer where you want your answers/that you want updated?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 8
(5,032 Views)

I don't understand what you mean...

I think I follwed correctly the instructions from National Instruments:

http://digital.ni.com/public.nsf/allkb/A3804F88FCDB1E6286257CE00043C1A7

Referring to this article, the controls you connect as inputs will be the input parameters of the function in C++, and the indicators will be the values returned from the function.

My array is an indicator and can only be an output, so it should be the value returned from the function, not an input inside the brakets ()

0 Kudos
Message 3 of 8
(5,015 Views)
The parameter IS an output from the dll. Both inputs and outputs will be inside the brackets.
0 Kudos
Message 4 of 8
(5,010 Views)

Ok, I don't create DLLs from my LabVIEW code but I think it has something to do with passing the array by reference. You need to pass in an array of the correct (or sufficiently large) size and the function overwrites the data in the array and returns it and provides a length parameter so you can trim the variable. You can also pass the array variable by 'handle' which will write the data back to the original variable (i.e. a pointer). (I don't think my definitions here are quite 'correct' but it should be close enough to understand).

 

The header information comes from this page that maps the VI to the C-function prototype.

 

2015-10-20_13-10-31.png

 

The function can't 'return' the array because you need to know the size etc. of the array and provide the data space or array pointer so I think it can only 'return' scalar values.

 

 


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 5 of 8
(4,992 Views)

Thank you! So there's no way to obtain an array (of fixed size) of values from a function of a LabVIEW dll and use it in Visual Studio??

0 Kudos
Message 6 of 8
(4,967 Views)
Solution
Accepted by topic author biomed87

Yes you can! You just can't have it as the 'return' value of the function - you get the data by passing a variable as an argument to the function (which the DLL then fills with data).

 

There's a bit more information about it here: http://digital.ni.com/public.nsf/allkb/862567530005F09C8625649700587C37

 

Edit: And here's an example in c++ - http://www.ni.com/example/26518/en/


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 7 of 8
(4,958 Views)
You've created the dll that will return an array.
0 Kudos
Message 8 of 8
(4,957 Views)