LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fastest way to transfer data from Labview to MATLAB and back for closed loop feedback control

Hi, 

 

I wanted suggestions about the fastest way to transfer data between Labview and MATLAB. 

 

My experimental setup consists of a camera connected to a microscope. I acquire images at 30 Hz - for every image, I have to process it to find the x,y coordinate of a microscopic particle, and then send these coordinates to MATLAB, which calculates the feedback control and sends the controls back to Labview, which then applies it to experimental setup. The feedback control calculation step in MATLAB is done using a compiled mex code for speed - unfortunately, it requires some advanced processing because of which I cannot port it to Labview. I've benchmarked the code in MATLAB and it takes about ~1 ms to execute. Here's a video showing my application: Video.

 

Can I know which option below (or other options not listed here) would be the most optimal for rapidly sending data to and fro? I will be sending 4 DBL values, and 2 16x4 DBL matrices to MATLAB, and reading out 2 16x4 DBL matrices, and I need to do it within ❤️ ms:

 

1. MATLAB script node - this is how I have it setup right now, but I've noticed it slows down the frame rate from 30 Hz to around 15 Hz, hence I was looking for other options. My observation is that initially after starting the program it runs fine with 30 Hz frame rate but eventually slows down to the 15 Hz frame rate.

 

2. TCP/IP (I will be running both programs on the same computer).

 

3. Compiling MATLAB code to a dll and use it as a library - however, I wasn't able to find an example where this was done, so I'll be glad if someone can point it out.

 

Thanks in advance!

 

0 Kudos
Message 1 of 3
(3,326 Views)

LabVIEW is also "compiled, for speed".  Given the small amount of data you are transferring back and forth, and a guess at the Task from watching the Video, I'm pretty sure that LabVIEW would be able to "follow" the two dots in less than a millisecond.  The simplicity of a single program, a single engine, a single piece of code might well overwhelm any slight speed advantage of MEX code.

 

Bob Schor

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

Hi Bob

 

To clarify - in the video, the circles are drawn with their centers on the bright dots, and the squares represent the position where I want the dots to go. Labview is indeed able to find the centers of the dots pretty fast. The controller code in MATLAB isn't making the circles follow the dots - its making the dots move so that their centers are on the center of the square. Those dots are being pushed around using fluid flow, and estimating how much fluid flow is required when the dots are at a given position is being done by MATLAB. Its solving a high-dimensional nonlinear optimization problem in microseconds, which Labview is incapable of, hence the need to use MATLAB.

 

Thanks,

Anish

 

Message 3 of 3
(3,290 Views)