LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Active X connection distribution

Hi,
New to Labview, and am using version 6.0 on Win98 & NT

I have a project that requires the use of an active x control as a device
driver for 2 motion controllers.
I need a way to pass the active x connection between VI's.

I have created a VI that opens the Active X controller and initiates the
driver, the control reference is then passed out to another VI via a
terminal, along with an error cluster.

Thinking about the project, this is probably not the best way to share this
resource.

Should I be;

a) Write a complete vi library that keeps the Active X reference local,
with wrapper functions for the methods and properties of the control?
b) Make the controls reference a global variable, and try and make
connection
s that way. I did try this today, but the Active X invoke node
wouldn't work, when I passed it the reference from the global.
c) Some other way...

I'm sorry if the terminology is messed up, I've only been using Labview for
a few days.

Jason
0 Kudos
Message 1 of 3
(2,626 Views)
jason clark wrote in message
news:8tn8ek$nc3$1@uranium.btinternet.com...

> I have created a VI that opens the Active X controller and initiates the
> driver, the control reference is then passed out to another VI via a
> terminal, along with an error cluster.
>
> Thinking about the project, this is probably not the best way to share
this
> resource.

I dunno- sounds fine to me. What's the problem?

> Should I be;
>
> a) Write a complete vi library that keeps the Active X reference local,
> with wrapper functions for the methods and properties of the control?

Uck, no- that is essentially duplicating the functionality of the Labview
ActiveX stuff, which is itself a set of wrappers to give a unified front
end, I assume.

> b) Make the cont
rols reference a global variable, and try and make
> connections that way. I did try this today, but the Active X invoke node
> wouldn't work, when I passed it the reference from the global.

It should work, but you need to make sure you write the reference to the
global before anything reads it. You also have to be aware that when no VIs
are executing, various internal cleanups take place, in which all open
references are closed. This means that if you manually run one program to
write the reference, then when that stops manually run another to read and
use it, the reference won't be valid.
0 Kudos
Message 2 of 3
(2,626 Views)
[posted and mailed]

jason34@btinternet.com (jason clark) wrote in
<8tn8ek$nc3$1@uranium.btinternet.com>:

>I have a project that requires the use of an active x control as a
>device driver for 2 motion controllers.
>I need a way to pass the active x connection between VI's.
>
>I have created a VI that opens the Active X controller and initiates
>the driver, the control reference is then passed out to another VI via a
>terminal, along with an error cluster.

This should work fine. However on each sub-vi you need to "redefine" the
reference so that it points back to the original control. Right clicking on
the reference should allow you to browse to your AX control type.
Alternatively create your code on the original block diagram and select it
and "Create Sub-vi". This will do the assigning of the refernce for you.

>Thinking about the project, this is probably not the best way to share
>this resource.

Depends on what needs to access the motion controller. If it is just your
LV application then I see no problem here. A well written AX control should
not monopolise system resources to exclude other activity while the motion
is controlled. I have successfully used LV to communicate to an AX control
that controls a complicated serial instrument that has constant chat etc
with the PC. I have made up to four simultaneous connections with 4 devices
and found no problem (ie 4 references to the control).

>a) Write a complete vi library that keeps the Active X reference local,
>with wrapper functions for the methods and properties of the control?

I suggest a state machine. Examples of state machines can be found on the
NI site (Developer Zone), the LabVIEW FAQ describes them (http://www.icon-
tech.com.au) and I think there are other examples on the pica.mil site and
probably the "Moore Good Ideas" site. If you're up to it, you can also
check out OOP for G -> GOOP for short. This will give you a way of defining
the resource and keeping track of it in (IMHO) an elegant way. However it
really is not needed.

>b) Make the controls reference a global variable, and try and make
>connections that way. I did try this today, but the Active X invoke
>node wouldn't work, when I passed it the reference from the global.

It will work after a fashion but make sure the reference is "defined". ie.
of the type of the active X control. However, placing the reference in a
global is poor programmatically because accessing the reference when it may
be "dereferenced" may cause crashes etc.

>c) Some other way...
>
>I'm sorry if the terminology is messed up, I've only been using Labview
>for a few days.

Not bad for a few days and you're already attacking the hardest part of LV
😉 My advice is if you are time rich continue as you are; but if you are
cash rich shell out for the NI motion controller and the LV suit of VI's
that control motion. Just a free NI plug 😉

cheers, Alex.
0 Kudos
Message 3 of 3
(2,626 Views)