gclib  2.0.8
Communications API for Galil controllers and PLCs
Commands Example

C++ C# Visual Basic
Example Example Example
Logic Logic Logic
Instructions Instructions Instructions

We are always interested in what our customers would like to see! To request any new examples or supported languages, please email suppo.nosp@m.rt@g.nosp@m.alil..nosp@m.com.

Concepts

This example demonstrates:

  • How to connect to a controller via IP Address.
  • How to issue basic commands.
  • How to read data back from the controller.
  • How to get context on errors that occur in the program.

Prerequisites

A Galil controller is required for this example.

Command Line Arguments

This example requires 1 argument:

  • The IP Address of a Galil controller.
commands_example.exe 192.168.42.200

Example Output

`*****************************************************************************`
`************************** GCmdT() example *****************************`
`*****************************************************************************`
GCmdT() will return a trimmed response of GCommand()
The command 'PR ?,?' will return the relative position of the A and B axes
<<PR ?,? with GCommand(): 0, 10000
:>>
<<PR ?,? with GCmdT(): 0, 10000>>
`*****************************************************************************`
`************************** GCmdI() example *****************************`
`*****************************************************************************`
GCmdI() will return the value of GCommand() parsed as an int
The command 'MG _LMS' will return the available space in the vector buffer of the S plane.
MG _LMS with GCmdT(): 511.0000
MG _LMS with GCmdI(): 511
`*****************************************************************************`
`************************** GCmd() example ******************************`
`*****************************************************************************`
GCmd() will execute the given command but does not return a value.
GCmd is useful for basic operations such as beginning motion or setting speed
GCmd(g, "BG A");
GCmd(g, "SP 5000");
`*****************************************************************************`
`************************** GCmdD() example *****************************`
`*****************************************************************************`
GCmdD() will return the value of GCommand parsed as a double
The command 'MG @AN[1]' will return the value of Analog Input 1
MG @AN[1] with GCmdD(): 9.7726
`*****************************************************************************`
`************************ Galil Double Format ***************************`
`*****************************************************************************`
Galil Controllers expect double values to be formatted to 4 decimal places
Unformatted double value: 0.00235
Formatted double value rounded to 4 decimal places: 0.0024
`*****************************************************************************`
`******************* G_UTIL_ERROR_CONTEXT example ***********************`
`*****************************************************************************`
GUtility() with G_UTIL_ERROR_CONTEXT: Broken Pipe