Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

MEX file from Math Interface Toolkit freezes MATLAB when called

I created a simple VI with LabView that inputs a number, converts it to a boolian string, and outputs the channels corresponding to the binary number on a DAQ (PCI-6221).  For example, if I input 8, line 3 (port0) will go high.  Inputting 9 will bring lines 0 and 3.  Inputting 10 would bring lines 3 and 2 high, etc. 
 
This program works in LabView.  I then used the Math Interface Toolkit to convert the VI into a MEX file (dll) to be called from MATLAB.  I named the MEX function DAQtrig, and the matlab syntax is DAQtrig(numeric); where numeric is a number (so like DAQtrig(8);).  Whenver this line is called in matlab, the DAQ responds and brings the right lines high, but then the MATLAB program stops responding.  It will not freeze the computer, but matlab will not longer accept any user input.  The program is listed as "busy" in the matlab status bar. No errors are generated.  I must terminate the thread (ctrl+alt+del -> task list) in order to stop the matlab program.  The lines remain high until I run a LabView program that has access to the DAQ digital I/O lines.
 
Any suggestions?  Any further info you need?

Thanks,

Steve
Department of Biomedical Engineering
UW-Madison
0 Kudos
Message 1 of 3
(2,632 Views)
Steve,

I can't speak much on what is going on with MATLAB as I have no experience working with it and DAQ equipment. But it sounds like the DAQ hardware you have is working as expected. The lines retain whatever state they last called in, unless the board is reset. So that part sounds normal, regardless of what software is calling it. If you would like to post your LabVIEW vi I can look through that to see if there is anything in that code that might be causing that behavior, but this is probably unlikely since it sounds like everything is working. It sounds more like MATLAB itself is doing something that is hanging it up, and if this is the case then the only other suggestion that I have would be to write all the DAQ operations in C and then try rolling that in, via dll or whatever MATLAB likes to see if that works. Ultimately I would suggest keep everything in LabVIEW if you can, since you know it works there. Is there a specific reason you want to call it in MATLAB? Any way, feel free to post your LabVIEW code.

-GDE
0 Kudos
Message 2 of 3
(2,617 Views)
I figured it out.  I had a loop in the labview program that was never finding its stop command when being called via MATLAB.
 
Silly me.
 
 
0 Kudos
Message 3 of 3
(2,604 Views)