3

I have a Labview VI that I intend to run from Matlab through ActiveX. It has one argument (that is, one Labview control), which is of type 1D numeric array.
The method used to call the VI from Matlab through ActiveX is detailed in a previous post.

I am trying to set the value of this array control in Matlab before running the VI (that is, Matlab will pass an argument to the VI and then run it; no action is to be performed manually through the Labview interface).

Getting the value through the GetControlValue method works fine (I get a nice Matlab array). However, when I try to set the value of this same control with SetControlValue using the value returned by GetControlValue, the value of the control becomes empty (as evident from the value Empty matrix: 1-by-0 obtained by Matlab after using GetControlValue again, and in Labview where the values of the control become grayed-out).

The same procedure works perfectly when the control is a single numeric value.
What is going wrong here exactly ?

See the screen capture below:

Setting the value of the 'y' 1D array control doesn't work

Community
  • 1
  • 1
calvin tiger
  • 391
  • 2
  • 7
  • 18

2 Answers2

0

You can compile the VI to a DLL and call your function that way. This abstracts away LabVIEW's typesystem and its COM runtime.

Can you provide more detail about the problem you are trying to solve?

dFlat
  • 819
  • 7
  • 19
  • My problem is quite straightforward: given a VI that has array controls, I would like to be able to set the value of these controls through Matlab before running the VI. As I said in my post, no issues appear when these controls are just numeric. I can use SetControlValue('a', 4) for instance, and the value of the control named 'a' is changed to 4. However, for array controls it just doesn't work.. Which is strange given that GetControlValue used on such a control returns a nice Matlab array.. – calvin tiger Feb 19 '12 at 22:29
  • Did you try compiling to DLL? – dFlat Feb 20 '12 at 04:55
  • No, although I might consider it if it offers speed and memory improvements. I would also like to look into .NET. However, I am interested in making this ActiveX method work because it is very general, and can be used with Python, too.. – calvin tiger Feb 20 '12 at 08:15
  • You are going to hit issues trying to call LV over COM. You essentially end up reinventing the LV RTE wheel. I would strongly recommend encapsulating your code in a DLL... What is it in LV that you can't do it Matlab? Or like you said C#? – dFlat Feb 20 '12 at 08:33
  • Instrument control :) (unless I buy Matlab's data acquisition toolbox.. $$$ !). – calvin tiger Feb 20 '12 at 09:02
  • LV is perfect for instrument control. But if you are good at Matlab you can always write the driver in Matlab... Which instrument are you controlling? And do you know SCPI? If not it is a great command set to understand, nearly all benchtop test equipment speaks SCPI. In my experience teh off the shelve drivers ALWAYS have a few bugs in them and you end up having to extend them to get the job done. – dFlat Feb 20 '12 at 20:54
  • Well, I was just trying to learn the method, but in my case my most likely application will be to send/read analog voltages and digital pulses to/from a NI data acquisition card. I reckon that I don't need arrays for that - however, I'd also like to use previously-written Vis that accept 2D arrays (images) as arguments for instance. I can't really do everything in Matlab because we don't own all the modules (the imaging module for instance), whereas our Labview distribution is quite complete. – calvin tiger Feb 21 '12 at 09:46
0

(Source: 0utlaw on the NI forum).

A useful workaround to this problem is to use a Matrix control in Labview. Matlab can then pass usual arrays, and Labview maps these Matlab arrays to the matrix. Works as expected with 2D arrays as well.

calvin tiger
  • 391
  • 2
  • 7
  • 18