Here where I work we use motion controllers to control our machines. Currently we are using Galil Motion Controllers (www.galilmc.com).
Anyways I was talking to their tech guy the other day and he suggested I use the new API, because the stuff I am using is no longer updated.
He told me it was now COM and not the typical DLL like their old stuff.
I have never tried to use COM before, but it seemed pretty straight forward in PB9. So I generated the code with the PB COM Browser looked at some examples and tried to make a small sample program that would connect to the controller and message me back the value of a variable on the controller.
I connected fine, but it seems any method with arguments does not work correctly.
Below I have an example of me connecting to the controller (Galil.address = "" just brings up a list of available controllers). Then I attempt to get the value of a variable called CONFIG on the controller, but I receive nothing back even though I know I am connected because I can view active connections in GalilTools.
I know most of you are not familiar with Galil, but I was wondering if someone would take a look my code and see if anything looks wrong or out of place.
Include File for COM (I ended up trying Jose's TypeLib Browser 4.0.11, with same results):
My test code:
Anyways I was talking to their tech guy the other day and he suggested I use the new API, because the stuff I am using is no longer updated.
He told me it was now COM and not the typical DLL like their old stuff.
I have never tried to use COM before, but it seemed pretty straight forward in PB9. So I generated the code with the PB COM Browser looked at some examples and tried to make a small sample program that would connect to the controller and message me back the value of a variable on the controller.
I connected fine, but it seems any method with arguments does not work correctly.
Below I have an example of me connecting to the controller (Galil.address = "" just brings up a list of available controllers). Then I attempt to get the value of a variable called CONFIG on the controller, but I receive nothing back even though I know I am connected because I can view active connections in GalilTools.
I know most of you are not familiar with Galil, but I was wondering if someone would take a look my code and see if anything looks wrong or out of place.
Include File for COM (I ended up trying Jose's TypeLib Browser 4.0.11, with same results):
Code:
' ######################################################################################## ' Library name: Galil ' Version: 0.1, Locale ID = 0 ' Description: Galil ' Path: C:\Program Files\Galil\GalilTools-x86\lib\Galil.tlb ' Library GUID: {30A08063-D424-4206-9631-AE91CF80C678} ' Code generated by the TypeLib Browser 4.0.11 (c) 2008 by José Roca ' Date: 27 Oct 2008 Time: 08:59:44 ' ######################################################################################## ' ======================================================================================== ' ClsIDs (Class identifiers) ' ======================================================================================== $CLSID_Galil = GUID$("{D70CFDB0-E481-480C-A29C-6F60FC044B38}") ' ======================================================================================== ' IIDs (Interface identifiers) ' ======================================================================================== $IID_Events = GUID$("{67E9C73D-896A-440C-88DD-D0AC82AB7569}") $IID_IGalil = GUID$("{F1F88B2C-881A-4D82-9F99-60A84691387D}") ' ######################################################################################## ' Interface name = IGalil ' IID = {F1F88B2C-881A-4D82-9F99-60A84691387D} ' Attributes = 4160 [&H1040] [Dual] [Dispatchable] ' Inherited interface = IDispatch ' ######################################################################################## #IF NOT %DEF(%IGalil_INTERFACE_DEFINED) %IGalil_INTERFACE_DEFINED = 1 INTERFACE IGalil $IID_IGalil INHERIT IDispatch ' ===================================================================================== METHOD libraryVersion <1610743808> ( _ ' VTable offset = 28 ) AS STRING ' [retval][out] *retval VT_BSTR ' ===================================================================================== PROPERTY SET address <1610743809> ( _ ' VTable offset = 32 BYVAL STRING _ ' [in] VT_BSTR ) ' void ' ===================================================================================== METHOD connection <1610743810> ( _ ' VTable offset = 36 ) AS STRING ' [retval][out] *retval VT_BSTR ' ===================================================================================== PROPERTY SET timeout_ms <1610743811> ( _ ' VTable offset = 40 BYVAL LONG _ ' [in] retval VT_INT <Long> ) ' void ' ===================================================================================== PROPERTY GET timeout_ms <1610743811> ( _ ' VTable offset = 44 ) AS LONG ' [retval][out] *retval VT_INT <Long> ' ===================================================================================== METHOD command <1610743813> ( _ ' VTable offset = 48 OPTIONAL BYVAL STRING _ ' [opt][in] command VT_BSTR [default value = "MG TIME"] , OPTIONAL BYVAL STRING _ ' [opt][in] terminator VT_BSTR [default value = "$CR"] , OPTIONAL BYVAL STRING _ ' [opt][in] ack VT_BSTR [default value = ":"] , OPTIONAL BYVAL INTEGER _ ' [opt][in] trim VT_BOOL <Integer> [default value = -1] ) AS STRING ' [retval][out] *retval VT_BSTR ' ===================================================================================== METHOD commandValue <1610743814> ( _ ' VTable offset = 52 OPTIONAL BYVAL STRING _ ' [opt][in] command VT_BSTR [default value = "MG TIME"] ) AS DOUBLE ' [retval][out] *retval VT_R8 <Double> ' ===================================================================================== METHOD programUpload <1610743815> ( _ ' VTable offset = 56 ) AS STRING ' [retval][out] *retval VT_BSTR ' ===================================================================================== METHOD programDownload <1610743816> ( _ ' VTable offset = 60 OPTIONAL BYVAL STRING _ ' [opt][in] program VT_BSTR [default value = "MG TIME[$CR]EN"] ) ' void ' ===================================================================================== METHOD programUploadFile <1610743817> ( _ ' VTable offset = 64 OPTIONAL BYVAL STRING _ ' [opt][in] file VT_BSTR [default value = "program.dmc"] ) ' void ' ===================================================================================== METHOD programDownloadFile <1610743818> ( _ ' VTable offset = 68 OPTIONAL BYVAL STRING _ ' [opt][in] file VT_BSTR [default value = "program.dmc"] ) ' void ' ===================================================================================== METHOD arrayUpload <1610743819> ( _ ' VTable offset = 72 OPTIONAL BYVAL STRING _ ' [opt][in] name VT_BSTR [default value = "array"] ) AS VARIANT ' [retval][out] *retval VT_VARIANT <Variant> ' ===================================================================================== METHOD arrayDownload <1610743820> ( _ ' VTable offset = 76 BYVAL VARIANT _ ' [in] array VT_VARIANT <Variant> , OPTIONAL BYVAL STRING _ ' [opt][in] name VT_BSTR [default value = "array"] ) ' void ' ===================================================================================== METHOD arrayUploadFile <1610743821> ( _ ' VTable offset = 80 OPTIONAL BYVAL STRING _ ' [opt][in] file VT_BSTR [default value = "arrays.csv"] , OPTIONAL BYVAL STRING _ ' [opt][in] names VT_BSTR [default value = ""] ) ' void ' ===================================================================================== METHOD arrayDownloadFile <1610743822> ( _ ' VTable offset = 84 OPTIONAL BYVAL STRING _ ' [opt][in] file VT_BSTR [default value = "arrays.csv"] ) ' void ' ===================================================================================== METHOD firmwareDownloadFile <1610743823> ( _ ' VTable offset = 88 OPTIONAL BYVAL STRING _ ' [opt][in] file VT_BSTR [default value = "firmware.hex"] ) ' void ' ===================================================================================== METHOD write <1610743824> ( _ ' VTable offset = 92 OPTIONAL BYVAL STRING _ ' [opt][in] bytes VT_BSTR [default value = "$CR"] ) AS LONG ' [retval][out] *retval VT_INT <Long> ' ===================================================================================== METHOD read <1610743825> ( _ ' VTable offset = 96 ) AS STRING ' [retval][out] *retval VT_BSTR ' ===================================================================================== METHOD sources <1610743826> ( _ ' VTable offset = 100 ) AS VARIANT ' [retval][out] *retval VT_VARIANT <Variant> ' ===================================================================================== METHOD recordsStart <1610743827> ( _ ' VTable offset = 104 OPTIONAL BYVAL DOUBLE _ ' [opt][in] period_ms VT_R8 <Double> [default value = -1] ) ' void ' ===================================================================================== METHOD record <1610743828> ( _ ' VTable offset = 108 OPTIONAL BYVAL STRING _ ' [opt][in] method VT_BSTR [default value = "QR"] ) AS VARIANT ' [retval][out] *retval VT_VARIANT <Variant> ' ===================================================================================== METHOD sourceValue <1610743829> ( _ ' VTable offset = 112 BYVAL VARIANT _ ' [in] record VT_VARIANT <Variant> , OPTIONAL BYVAL STRING _ ' [opt][in] source VT_BSTR [default value = "TIME"] ) AS DOUBLE ' [retval][out] *retval VT_R8 <Double> ' ===================================================================================== METHOD sourceUnits <1610743830> ( _ ' VTable offset = 116 OPTIONAL BYVAL STRING _ ' [opt][in] source VT_BSTR [default value = "TIME"] ) AS STRING ' [retval][out] *retval VT_BSTR ' ===================================================================================== METHOD sourceDescription <1610743831> ( _ ' VTable offset = 120 OPTIONAL BYVAL STRING _ ' [opt][in] source VT_BSTR [default value = "TIME"] ) AS STRING ' [retval][out] *retval VT_BSTR ' ===================================================================================== END INTERFACE #ENDIF ' /* __IGalil_INTERFACE_DEFINED__ */
Code:
'Galil COMM Test #INCLUDE "Galil.inc" function PBMAIN() static Galil as IGalil, GalilEvents as EventsImpl Galil = NEWCOM CLSID $CLSID_Galil IF isnothing(Galil) THEN MSGBOX "Unable to create an object refrence to the Galil Interface." exit function end if GalilEvents = CLASS "CEvents" EVENTS FROM Galil CALL GalilEvents Galil.address = "" Galil.connection() sleep 500 msgbox Galil.command("CONFIG=?") end function ' ######################################################################################## ' Class CEvents ' Interface name = Events ' IID = {67E9C73D-896A-440C-88DD-D0AC82AB7569} ' Attributes = 4096 [&H1000] [Dispatchable] ' Code generated by the TypeLib Browser 4.0.11 (c) 2008 by José Roca ' Date: 27 Oct 2008 Time: 09:03:04 ' ######################################################################################## CLASS CEvents GUID$("{3EC72A2F-5294-475D-B7CF-6590ACD7B250}") AS EVENT INTERFACE EventsImpl GUID$("{67E9C73D-896A-440C-88DD-D0AC82AB7569}") AS EVENT INHERIT IDispatch ' ===================================================================================== METHOD onInterrupt <0> ( _ BYVAL status AS LONG _ ' [in] status VT_INT <Long> ) ' VOID ' *** Insert your code here *** END METHOD ' ===================================================================================== ' ===================================================================================== METHOD onMessage <1> ( _ BYVAL message AS STRING _ ' [in] message VT_BSTR ) ' VOID ' *** Insert your code here *** END METHOD ' ===================================================================================== ' ===================================================================================== METHOD onRecord <2> ( _ BYVAL record AS VARIANT _ ' [in] record VT_VARIANT <Variant> ) ' VOID ' *** Insert your code here *** END METHOD ' ===================================================================================== END INTERFACE END CLASS
Comment