Galil gclib widget example

Introducing Galil’s New C Programming Library

gclib is a C-compatible application programming interface (API) for communicating with Galil motion controllers and PLCs.

This February Galil introduced a new C application program interface (API) library.  This library gives programmers access to powerful routines to interact with Galil motion controllers in a wide variety of application development environments.  The Galil C Library, or “gclib”, replaces the C++ GalilTools Communication Library, or GCL, released in 2007 and is recommended for all new software development.

Galil’s motion controllers and PLCs are designed to deploy conveniently into applications of all types. While every Galil controller features flash program memory which when loaded with a user created application program allows it to run completely standalone, in most applications communication with a general purpose computer is required. Examples include machine vision, human interface, data collection, coordination with other equipment, analysis and display.  The new gclib provides the software functions and API (application program interface) which enables a user’s program on the host computer to easily interact with the motion controller.

The gclib has a number of improvements, as outlined below.

1. Portable

The gclib improves the portability of previous solutions in two important ways. First, the library is C-based, which is naturally ideal for C/C++ users. Because C uses “Plain Old Data,” any C/C++ compiler can be used to develop Galil applications with gclib. C is the most universal programming language, allowing the gclib to be imported into languages and software environments of all kinds. A partial list of environments where gclib can be used includes C/C++, C#, VB .net, LabVIEW, and Python. In fact, virtually any language or software that has the capability to import a DLL can be used with gclib.

In addition to the unbeatable breadth of usage cases, gclib is also portable across operating systems. As of the publishing of this article, gclib is supported on x86 and x64 versions of Microsoft Windows 7 and newer, Linux Redhat 6 and 7, Linux Ubuntu 12.04 and 14.04, and Linux Fedora 21. Current Linux support is x64 only. Contact softwaresupport@galil.com for other operating systems and architectures.

2. Open Source

A large portion of the gclib is open source. This allows the user to modify many of the function calls to suit special requirements. It also allows for easy extension by adding further function calls.

3. Backwards Compatible

An included open source implementation of the C++ GalilTools Communications Library allows for users to upgrade to gclib while still maintaining the function calls of existing code.

For users with applications developed prior to 2007, Galil also offers the “DMC32 Operating System Upgrade” library, which is built on gclib. This allows older applications built on the DMC32.dll library to be upgraded past Windows XP. Contact softwaresupport@galil.com for DMC32OSU.

4. Improved Feature Set

The following outlines some of the improvements in the library over previous Galil APIs.

  1. Easily access a list of all available controllers connected to a system.
  2. Listen for controllers without IP addresses and assign IP addresses via BOOT-P and DHCP.
  3. Powerful connection options including protocol usage, handshaking, asynchronous data stream routing, etc.
  4. Improved control of array uploads and downloads including subsets.
  5. Convenience functions that return Integer, Double, or trimmed strings.
  6. A blocking “motion complete” call allowing the user’s procedural code to cleanly finish a move before profiling the next.
  7. Fine-grained control over program downloading including a tiered compression algorithm and code insertion.

The Galil C Library was created to streamline application development by leveraging the compatibility of the C language with Galil’s familiarity with our customers needs. Feature enhancements and additional sample code will be published as they become available.

Widgets and Microsoft .NET

Included in the Gclib download is a .NET wrapper that allows developers using .NET to easily access all the underlying features of the C library. C# and VB wrappers are provided for users of either language.

gclib also provides the communications foundation for the Galil Widgets project. Galil Widgets are a collection of .Net WinForms User Controls that provide quick development of custom graphical user interfaces (GUIs) that communicate with Galil Motion Controllers and PLCs. These graphical tools allow for very fast development of custom user front ends. The widget download currently includes a communication tool, terminal tool, backup and restore tool, and information polling and display tool.  Galil Widgets was used to create the program shown above.