LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Some Problems with LabVIEW and Matlab DLLs

As many other LabVIEW users, I wanted to include Matlab functions in LabVIEW by means of a DLL. To achieve this, instead of using a wrapper DLL as I have seen in this Discussion Forums, I created the DLL with Mathworks COM Builder, directly from the '.m' files, that builds and registers the component.

Then I used this DLL in LabVIEW as an ActiveX component, using an Automation Refnum to select the DLL in the Front Panel, and opening the reference and invoking the methods that I wanted to use in the Block Diagram, and after several difficulties (you have to use a 2D array type to obtain an 1D array output parameter; you are not permited to work with complex parameters, you have to use real and imaginary components separately),
I was able to have the Matlab functions doing their job inside LabVIEW without having Matlab running on my PC.

My problem arises when I rebuild the Matlab DLL. From that moment on, when I run again my top VI, a message of 'Class not registered' appears when The Invoke Node is executed. To solve this, I have to open my DLL VI, and reasign the DLL on the Automation Refnum to the same DLL. It seems that each time the DLL is recreated, something related with it changes, and LabVIEW does not recognize the DLL, despite the fact that the name of the DLL is exactly the same.

Does anyone know why is this happening? Any help?

Thanks and have a good day,

spj
0 Kudos
Message 1 of 5
(2,946 Views)
Hello spj

I do not know the problem, but maybe this will help. Did you try to put your library into a directory, which is in the dearch path of the operating system? Then use only the liobrary name (without a path) and write the function name. I have seen it in the most of NI examples using dlls. If it works give a response to this thread.

Pawel
0 Kudos
Message 2 of 5
(2,945 Views)
Hello pawel,

I followed your first tip, but if I move the rebuilt DLL to a directory that can be found through the PATH enviroment variable, the result is the same. Secondly, to choose the ActiveX class for the Automation Refnum, the "Select Object From Type Library" Dailog Box that appears, shows the components registered. You do not have to give the path of the DLL you have created, so it is not possible to try the second tip you gave me.

Thanks for your time,

spj
0 Kudos
Message 3 of 5
(2,945 Views)
Hello spj.

I have taken a look at your issue. It sounds like what is happening could be expected behavior. When you re-build your script into a DLL, as is mentioned in your post, it will re-register the COM object to Windows. Therefore, even though the names and locations are the same, the DLL (really like an .ocx file in this case) has been re-registered and thus will need to be re-linked to the LabVIEW Automation Open function each time.

I hope this helps!
Colin C.
Applications Engineer
Colin Christofferson
Community Web Marketing
Blog
0 Kudos
Message 4 of 5
(2,945 Views)
Hello Colin,

Though I hoped for an answer that showed me a way that did not make necessary to relink the DLL each time I rebuild it, at least it is good to know that I was not doing something wrong.

Thanks for your comment,

spj
0 Kudos
Message 5 of 5
(2,945 Views)