LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MATLAB calling subVi

hi,

i want to call a Vi from Matlab via ActiveX. i tried to keep it simple at first. The vi has only one numerical controll called "N".

 

LV = actxserver('Labview.Application','127.0.0.1');

vipath = 'C:\matlabtest.vi';

vi = LV.GetVIReference(vipath);

vi.Call('N',5);

 

i get the following error message:

No method 'Call' with matching signature found for class... 

 

i can't use vi.Run(1); since the vi should be a subVi of a vi which is under execution when the script should be executed.

Using matlabtest.vi as a stand-alone-vi and utilizing vi.Run works fine...

 

Does anybody have an idea?

 

0 Kudos
Message 1 of 6
(7,708 Views)

Hello hkracke,

 

please take a look at the following links:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=233780&requireLogin=False

http://forums.ni.com/ni/board/message?board.id=170&message.id=244029&requireLogin=False 

http://forums.ni.com/ni/board/message?board.id=170&message.id=15913&requireLogin=False

 

I hope this will help you out.

 

If not please provide me with the versions of LabVIEW and Matlab. A small snippet of code (VI + .m-file) would be nice too.

 

With best regards

 

Ralf N. 

Applications Engineering

Germany

Message 2 of 6
(7,671 Views)

hi ralfn,

first of all thanks for your reply. however, the links don't help (i already googled the problem and i knew these links...)

the vi i would like to call is a sub-vi of a Running VI. That's why i can't use the vi.run method!

The "call"-method works only with references. but i don't know how to create a reference in matlab...

 

I'm using Labview 8.2 and Matlab7.4

 

the .m file is the code above.

the vi has only one Numerical control called 'N'. 

0 Kudos
Message 3 of 6
(7,644 Views)

hkracke,

 

The first link that Ralf pointed to contained the solution that should work for you.  The only difference is that you wouldn't need to invoke the Run method, since you already have a running VI.  Something like the following should work:

 

vipath='C:\myVI.vi';

e=actxserver('LabVIEW.Application') 

myvi=invoke(e, 'GetVIReference', vipath);

myvi.SetControlValue('N', 5); 

 

Chris M 

 

0 Kudos
Message 4 of 6
(7,626 Views)

hi cmal,

myVI.vi should be a sub-Vi of a running vi (let's call it mother.vi).

mother.vi uses myVi.vi from time to time. So when mother.vi is running, myVi.vi is "waiting for execution".

i can set control values just like you pointed out but how can i tell labview to execute myVi.vi?

the running vi is not myVi.vi but mother.vi....

 

Perhaps i should give an example of such a situation:

it could be a control program which can query data of several instruments. for all these instruments exists a vi which handles the query process of this specific device.

I want to execute a certain vi of one instrument meanwhile the control program is running!

 

i hope that the problem is now clearly identifiedSmiley Wink

0 Kudos
Message 5 of 6
(7,606 Views)

hkracke,

 

You're right.  In this case, the subVI ('myVI.vi') is waiting for execution as a subVI of 'mother.vi', so it cannot be called as a top-level VI from an external application.  One solution would be to create a third VI, 'external_caller.vi', which would contain 'myVI.vi'.  'external_caller.vi' would be called from the ActiveX client, and it would allow 'myVI.vi' to be called from both 'mother.vi' and 'external_caller.vi'.  Let me know if this works for you.

 

-Chris 

0 Kudos
Message 6 of 6
(7,571 Views)