01-08-2006 09:15 AM
01-11-2006 03:40 AM
A Multi-threaded DLL is the best solution for this, yes.
I am not familiar with mathlab, so I have no example for that, but lets say "traditionally" you would do something like this:
mexFunction()
{
LoadPanelEx(...);
RunUserInterface();
........
}
As you said, now mathlab waits for the end of the function, so you would have to quit your User Interface (QuitUserInterface) that mathlab continues working. Do the following instead:
mexFunction()
{
LoadPanelEx(...);
CmtScheduleThreadPoolFunction(DEFAULT_THREAD_POOL_HANDLE,MyFunction,NULL,NULL);
........
}
int CVICALLBACK MyFunction(void *functionData)
{
RunUserInterface()
.......
}
This Version will start a new thread, and returns to mathlab immediately. In the new Thread you can call the RunUserInterface() function, so this thread will run until the UI is closed via QuitUserInterface().
Hope this helps!
01-16-2006 10:09 AM
Hello ANdre,
Thanks !
However, I got new challenges (read: problems to be solved) and got stuck by my lack of experience. It seemed as if I had to build a kind of DLL data server that exchanges data from/to matlab and from/to the GUI that I wanted to build.
So: I decided to limit myself for the time being to 1) define a NIDAQmx task in Measurement&Automation, and 2) build a DLL with the (single) function mexFunction that loads and executes this task and returns the data as a #channels * #samples back to matlab. So for the time being, I cannot change the task from the matlab script. But after interactive setting/changing the task with MAX, I can retrieve new data repeatedly. Not fancy but easy working!
I still have to do some debugging and verification of input parameter 'TaskName', but the first version works.
For other people who try this: I got stuck in the beginning because the NIDAQ had installed a CVI runtime engine version 7.x where I build the DLL with CVI version 8.0. I only copied the DLL to the matlab working directory. Wrong wrong wrong !!! I needed also the newest runtime engine.
Thanks, Jos
01-16-2006 10:47 AM
10-25-2006 08:46 AM
10-26-2006 01:21 AM
Hello Befaiz,
My advise is to start in new post in forum for Labview.
As my solution (Measurement & Automation task from matlab without any GUI) worked fined for my requirements (data retrievel after A/D task with multi A/D interface by National Instruments), I have worked not further anymore on this subject.
Regards, JGS
11-16-2006 08:34 AM
Hello Jos ,
i want to call my Simulation GUI.VI from Matlab.It is possible?and how?.
Does you have a simple example ?
Thanks
Befaiz
11-16-2006 12:59 PM
Hello Befaiz,
If have halted my exercise for an interface towards matlab incl. GUI.
I have limited myself with a matlab so-called mexfunction wich is a DLL with one interface. I use this function to call a task that I have previous defined with Measurement and Automation for an NI multi I/O interface that is supported by NiDAQmx. And I return only a - multiple column - array with results from A/D conversion.
So I have no experience with labview nor with interfacing a GUI towards matlab.
Sorry I cannot help you, Jos