LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control VI from Matlab

I need to control a VI from Matlab (Simulink).

The VI controls the operation of digital cameras, which I would like to trigger from Simulink.
I just need to send a signal to trigger the cameras, but this should be relatively fast.

What's the best way to accomplish this?
The VI and the Simulink model are on different computers on the same network.

Thank you for your help.
0 Kudos
Message 1 of 4
(3,116 Views)
Hello

I propose to use the ActiveX automation server. From Matlab is is very easy to call executable vi and make it do what you want. It is stable, fast and easy.

useful commands are (just coppied from my code - hope you can follow):

If you test it through the development environment you use:

LVapp = actxserver('Labview.Application');

if it is executable you use:

LVapp = actxserver('Your_App.Application');

%call your vi in to memory

viPath = 'Your_top_vi.vi';
vi = LVapp.GetVIReference(viPath) ; % 'Load the vi into memory

% 0 - invisible, 1 - visible
%vi.FPWinOpen = 0;
vi.FPWinOpen = 1;

%if you want to set control values you use:

invoke(vi,'SetControlValue','Your_Control_Label','Your_value');

% if you want to execute the vi you use:
vi.Run;

Hope it helps

Pawel
0 Kudos
Message 2 of 4
(3,106 Views)
Thanks for the code sample.

Can this be used with a VI that is already running on a different machine?
Would the two VI's now have to communicate somehow?
If so, what would be the best way?

Thanks
0 Kudos
Message 3 of 4
(3,091 Views)
I do not think, that you can use ActiveX to call an "ActiveX vi" from another machine. That is because ActiveX is Windows register dependent.
But I am not sure, maybe somebody can do it.

Explain, what do you meen two Vi's and the best way. The best way of what?

Pawel
0 Kudos
Message 4 of 4
(3,083 Views)