Hello

This section details how to get started using the GalilTools Communication Library with step-by-step examples that show how to print a controller's connection information (e.g. "GALILPCI1, DMC1886 Rev 1.0b, 36") using popular programming languages. See the Hello Galil project on Galil's website for a complete list of examples.

Make sure GalilTools is installed and a connection to the controller can be established from that application. A try-catch error handler is required for most Galil functions, but is left out here for brevity. Please see the Library Reference.

Visual Basic

Visual Studio or the free-of-charge Express edition may be used (below configures Visual Studio 2008, but versions back to 6 may be used)

  1. Select Start | All Programs | Microsoft Visual Studio 2008 | Microsoft Visual Studio 2008

  2. Select File | New | Project... | Other Languages | Visual Basic | Windows Forms Application and click OK

  3. Select Project | Add Reference...

  4. Choose the COM tab, select Galil, and click OK

  5. Double click on Form1 and add the code below

  6. Hit F5 to run the program

C#

Visual Studio or the free-of-charge Express edition may be used (below configures Visual Studio 2008, but versions back to 2002 may be used)

  1. Select Start | All Programs | Microsoft Visual Studio 2008 | Microsoft Visual Studio 2008

  2. Select File | New | Project... | Other Languages | Visual C# | Windows Forms Application and click OK

  3. Select Project | Add Reference...

  4. Choose the COM tab, select Galil, and click OK

  5. Double click on Form1 and add the code below

  6. Hit F5 to run the program

C++/CLI

Visual Studio or the free-of-charge Express edition may be used (below configures Visual Studio 2008, but 2005 may also be used). This section covers C++/CLI (Common Language Infrastructure) targeting the CLR (Common Language Runtime). For native (unmanaged) C++, see Visual C++ 2008

  1. Select Start | All Programs | Microsoft Visual Studio 2008 | Microsoft Visual Studio 2008 | File | New | Project... | Visual C++ | CLR | Windows Forms Application and click OK

  2. Select Project | Properties... | Add New Reference...

  3. Choose the COM tab, select Galil, and click OK

  4. Double click on Form1 and add the code below

  5. Hit F5 to run the program

Visual C++ 2008

Visual Studio or the free-of-charge Express edition may be used (contact Galil if another C++ compiler is required). This section covers native C++. For managed C++, see C++/CLI

  1. Open a compiler command prompt

    Start | All Programs | Microsoft Visual Studio 2008 | Visual Studio Tools | Visual Studio 2008 Command Prompt

  2. Change to the directory containing the example C++ program (if you're not an Administrator, you'll need to copy the lib folder to %HOMEPATH% and work there)
    C:\Program Files\Microsoft Visual Studio 9.0\VC>cd %ProgramFiles%\Galil\GalilTools\lib
  3. Compile
    C:\Program Files\Galil\GalilTools\lib>cl hello.cpp Galil1.lib /EHsc /MD
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.21022.08 for 80x86
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
      hello.cpp
      Microsoft (R) Incremental Linker Version 9.00.21022.08
      Copyright (C) Microsoft Corporation.  All rights reserved.
    
      /out:hello.exe
      hello.obj
      Galil1.lib
  4. Tell Windows where to find Galil1.dll
    C:\Program Files\Galil\GalilTools\bin>set path=%path%;%ProgramFiles%\Galil\GalilTools\bin
  5. Run
    C:\Program Files\Galil\GalilTools\lib>hello
    1.1.0.4 Aug 29 2008 14:15:14 Galil1.dll
    GALILPCI2, DMC1886 Rev 1.0b, 988
    ...
  6. If you want to use the GUI debugger (devenv.exe or vcexpress.exe), you'll need to
    1. add %ProgramFiles%\Galil\GalilTools\bin to your PATH (Start | Control Panel | System | Advanced | Environment Variables)
    2. File | New | Project... | Visual C++ | General | Empty Project
    3. In the Solution Explorer, right click Source Files | Add | Existing Item... | C:\Program Files\Galil\GalilTools\lib\hello.cpp
    4. Set Project | Properties... | Configuration Properties | C/C++ | General | Additional Include Directories to "C:\Program Files\Galil\GalilTools\lib" (QUOTES IMPORTANT!)
    5. Set Project | Properties... | Configuration Properties | C/C++ | Code Generation | Runtime Library to Multi-threaded DLL (/MD)
    6. Set Project | Properties... | Configuration Properties | Linker | Input | Additional Dependencies to "C:\Program Files\Galil\GalilTools\lib\Galil1.lib" (QUOTES IMPORTANT!)

Note: GalilTools ships with release libraries (/MD switch above). In order to use debug (/MDd) the user MUST download the debug version of the Galil lib.

Debug libraries and libraries for other versions of Visual Studio are available in the GalilTools archive: http://www.galil.com/support/downloads/software/galiltools/windows/

g++ on Linux

  1. Change to the lib directory
    [dj@localhost Galil]$ cd lib
  2. Compile
    [dj@localhost lib]$ g++ hello.cpp -L. libGalil.so
  3. Run
    [dj@localhost lib]$ ./a.out
    1.1.0.4 Aug 29 2008 14:15:14 libGalil.so
    /dev/galilpci0, DMC1886 Rev 1.0b, 988
    ...

LabVIEW

  1. Open National Instruments LabVIEW and select Blank VI
  2. On the Front Panel, select View | Controls Palette | Search, type String Indicator, and drop it onto the Front Panel
  3. Choose Window | Show Block Diagram

  4. Choose View | Functions Palette | Seach, type Automation Open, and drop it onto the Block Diagram
  5. Right-click on the Automation Open block and choose Select ActiveX Class | Browse...
  6. Choose the Galil Version x.x Type Library, click the Galil Object, and click OK

  7. Right-click on the Automation Open block, choose ActiveX Palette | Property Node, and drop it onto the Block Diagram
  8. Connect the Automation Refnum terminal of the Automation Open block to the reference terminal on the Property Node
  9. Left-click on the Property element of the Property Node and choose address
  10. Choose View | Functions Palette, type String Constant, drop it onto the Block Diagram, and connect it to address

  11. Right-click on the Automation Open block, choose ActiveX Palette | Invoke Node, and drop it onto the Block Diagram
  12. Connect the Galil.IGalil (reference output) terminal of the Property Node to the reference terminal on the Invoke Node
  13. Left-click on the Method element of the Invoke Node and choose connection
  14. Connect connection to String

  15. Hit Ctrl+R to run the VI



Contents