LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fanuc Development (may not need specific Fanuc Knowledge)

Solved!
Go to solution

Hello everyone, I am hoping to get some help with something which I think should be relatively simple in LabView; however, I am having trouble figuring out the correct way to do it.  There are 2 questions that I have that are related to trying to find 2 different ways to achieve the end goal. 

 

Question 1

 

I have used the PCDK to create a .dll in VB.net that I could use in LabView, but I have encountered some problems when I try to get the elements of an array.  LabView receives the .net array and I can invoke any of the .net methods; however, I cannot pass the array reference into a for loop.  I can insert the 6 joint coordinates into an array, but although .net returns an array of doubles LV still sees the contents as of type .net.  As a result, I have to invoke Object.ToString() in LV followed by analyzing the string using %.8p and then I finally get the double I want albeit truncated to only 6 significant figures -- truncation is not a big concern.  This seems very resource intensive and if there are any ideas how to do it more efficiently.

 

Question 2 

 

I have tried to get the current position of the robot in LV in joint coordinates; however, I cannot seem to get LV to create an FRCJoint which I can use to input my Formats(frJoint) returned from the current position into to get the individual items.  I tried using an ActiveX object by opening an Automation Refnum of type FRCJoint; however, when I call the method I can an error about being unable to create an instance of FRCJoint.  Any help is much appreciated.

 

Thank you so much for taking the time to read this and I look forward to any replies!

Message Edited by m4r7in on 08-07-2009 08:56 AM
0 Kudos
Message 1 of 15
(5,714 Views)

First, let me say that I have no Fanuc knowledge, so I can't help you with that. As far as your questions are concerned, though:

 

Question 1: Do you have an ArrayList or an Array class? If you have an ArrayList then you have to use the  Count property to get the length of it, and use that to drive the for-loop. In the for-loop you'd use the get_Item method to get an element, and cast it to a double. Also, which version of LabVIEW are you using? Some versions of LabVIEW have problems correctly interpreting an argument that's an array and automatically providing the correct datatype. Instead, it provides a .NET datatype. 

 

Question 2:  Is FRCJoint an ActiveX control? You may want to peruse this LAVA thread.

0 Kudos
Message 2 of 15
(5,681 Views)

First of all, thanks for the reply.  I'm using LV8.6 and I have an ArrayList that I cast to an Array.  The problem arises when I try to pass the Array reference into the for loop.  The wire becomes broken as the for loop seems to lose the association with the .net reference or won't accept it being passed in.  I've tried casting to cluster then from cluster back to array, but this doesn't seem to work and is a weak hack anyways.  The count is no problem, that wires in fine.  Ultimately, I would like to know how to easily extract the doubles from the .net Array without having to cast them multiple times, if possible.  Any suggestions?

 

P.S. As far as the other thread goes, I've been doing everything in VB and just bringing it into LV and that thread is what inspired me to try it all in LV yesterday.

Message Edited by m4r7in on 08-07-2009 11:28 AM
0 Kudos
Message 3 of 15
(5,676 Views)
If you have an ArrayList class that's being returned then casting it to an Array won't gain you anything because you'll still have a .NET class. You might as well just stick with the ArrayList class. Attached is an example of getting the elements from an ArrayList class.
Message 4 of 15
(5,659 Views)
Thank you very much for that as it solves method 2.  If anyone has any information about method 1 could they please help.  I would like to eventually be able to do everything in LV.  It seems as though I get a COM exception when trying to create an instance of FRCJoint whether I am doing it via ActiveX or .NET constructor.  It gives me an error that after further research seems to indicate that the class is not registered; however, I am not experienced with COM development and so wouldn't have the slightest clue as to how to register the class.  Any information or material I can look into to figure this out would be greatly appreciated!
0 Kudos
Message 5 of 15
(5,649 Views)
In the above I meant to say that solves method 1 Smiley Wink
0 Kudos
Message 6 of 15
(5,638 Views)

m4r7in wrote:
It seems as though I get a COM exception when trying to create an instance of FRCJoint whether I am doing it via ActiveX or .NET constructor.  It gives me an error that after further research seems to indicate that the class is not registered;

If you're dealing with a COM object then .NET is the wrong technology to use for that class. Are you sure that's the class that you're supposed to instantiate? Did you get any examples with this "PCDK"? Do they use that class? The LAVA thread that I had linked to had an example at the end, and they seemed to be creating a different class. 

0 Kudos
Message 7 of 15
(5,630 Views)

m4r7in wrote:
Thank you very much for that as it solves method 2.  If anyone has any information about method 1 could they please help.  I would like to eventually be able to do everything in LV.  It seems as though I get a COM exception when trying to create an instance of FRCJoint whether I am doing it via ActiveX or .NET constructor.  It gives me an error that after further research seems to indicate that the class is not registered; however, I am not experienced with COM development and so wouldn't have the slightest clue as to how to register the class.  Any information or material I can look into to figure this out would be greatly appreciated!

You can probably not instantiate an FRCJoint object as top level object, I think. I have no experience with the Fanuc SDK but usually you would instantiate a high level class IApplication or maybe IRobot and your other objects get derived from that somehow.

 

Rolf Kalbermatter

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 15
(5,600 Views)

The problem is that with the Fanuc SDK the FRCJoint and FRCRobot are sibling base objects and thus I cannot get from the FRCRobot to the FRCJoint except from some sort of function return.  The problem here is that the FRCJoint object gets changed by LV to a variant and not recognized as its native type when it is returned from FRCRobot.CurPosition.CurGrpPosition.Formats -- you can likely see my problem.  I somehow need a reference to a base FRCJoint in order to wire the .Formats return.  Please reply if you have any suggestions.  Thanks.

 

Here is an excerpt from the SDK which may serve some use:

 

"The Robot Server is an Active-X executable program that provides your PC application access to an R-J3 robot controller.  It communicates with robot using TCP/IP (typically over Ethernet) and to your PC application through an object (COM) interface.  

TCP/IP and COM provide you with the maximum flexibility and compatibility.  These protocols integrate seamlessly with the Visual Basic IDE and are launched automatically when your application creates an instance of the Robot Object (FRCRobot).

Each new version of the Robot Server supports all of the previously supported R-J3 controller versions and features.  However, the reverse is not true.  The older versions of the Robot Server are not guaranteed to work with newer versions of the R-J3 controller."

Message Edited by m4r7in on 08-10-2009 06:59 PM
Message Edited by m4r7in on 08-10-2009 07:00 PM
0 Kudos
Message 9 of 15
(5,570 Views)

This is done in LabVIEW using the Variant to data function. You wire up the variant to its input, a refnum from an Automation Refnum set to the desired object type to its type input and then it returns the Automation Refnum of the correct object type if the variant was at least a compatible class object.

 

So no instantiating of your object itself through Open Automation Refnum or something like that but in fact a conversion from the Automation Refnum object wrapped into a variant into its normal Automation Refnum.

 

Rolf Kalbermatter

Message Edited by rolfk on 08-11-2009 07:43 AM
Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 15
(5,558 Views)