From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem using DLLs generated by Labview 8 in Matlab R2006b

Hi everybody!
 
I'm trying to create a DLL in Labview 8 so that I can run it in Matlab 2006b. The problem is that some of the inputs of this DLL are 3D-arrays, as well as some of the outputs! When I create the DLL, Labview uses "Array Handle Pointers", that, as far as could understand by reading Matlab Help, cannot be load by the function "loadlibrary"

The manual says: "The MATLAB Generic Shared Library interface does not support library functions that have function pointer inputs". I succeeded creating and running a simple DLL that as two numeric values as inputs and gives the sum of them as an output. In this case, I don't use pointers and everything works fine!
 
Is there any way of creating and passing 3D-arrays in DLLs without using pointers? Any ideas of how to solve this problem are welcome!!
 
Thanks a lot,
Sérgio
0 Kudos
Message 1 of 3
(2,440 Views)
I think you're confusing function pointers with pointers in general. Function pointers are a specific kind of pointer that point to a specific kind of function at a place in memory. LabVIEW does not pass arrays or any other type of data as function pointers. General pointers are a very common way of passing data about. All it means is that instead of passing a complete copy of the data, you are passing a reference to the data so that the function can use the same data in memory instead of a copy of it.

 In fact, it is really quite difficult to get LabVIEW to give you a function pointer for a VI. For any of those interested, someone found an absolutely fabulous solution to this old problem using .NET. Moral of the story, you're definitely not going to have a LabVIEW DLL that inputs or outputs function pointers.
Jarrod S.
National Instruments
0 Kudos
Message 2 of 3
(2,432 Views)

Hi!

Thanks for the tip!

In fact now I am able to pass 1D-arrays using the method "Array Data Pointer" when I create the DLL in Labview. It appears another variable which is the length of the array and everything works fine. In Matlab I create the pointer and I give the size of the array and it works.

The problem is that when I move to 2D or 3D-arrays, when generating the DLL, Labview no longer asks me if I want to pass the table as Array Data Pointer or Array Handle Pointer (if I use the last one, even with 1D-arrays, it does'nt work in Matlab). So I generate the DLL, I load the library into Matlab and when I look the description of the functions inside Matlab indicates that the tables are passes as "voidPtr". I create those pointers in Matlab but it gives an error when I call the DLL. I don't know how to work around on this. If there are someone with some experience on how to solve this problem, please give me some feedback.

Thank you for the help.

Sérgio

0 Kudos
Message 3 of 3
(2,425 Views)