| ||
Hardware Command Reference | ||
Edition 5/26/2011 9:30:24 AM (svn 400) | ||
| ||
This command reference is a supplement to the Galil User Manual.
| Resources on www.galilmc.com |
Printable version |
| Product Manuals |
| Application Notes |
| Newest Firmware |
| Sample DMC code |
| Learning Center |
| Support and Downloads |
DMC (Digital Motion Controller) code is the programming language used for all Galil hardware. It is a high-level, interpreted language which is simple to learn and use, yet is surprisingly powerful. Actively developed and refined since 1983, DMC code provides functionality that is particularly well suited to motion control and PLC applications.
DMC code can be used manually from a terminal, programmatically from an external device or customer application, and can be fully embedded into a Galil controller's memory to leverage powerful "embedded-only" features and for stand-alone applications.
DMC code of course provides symbolic variables, arrays, and math support. The elegance of DMC coding is particularly evident when writing code for embedded applications. When running on the controller, the DMC language supports if-then-else conditionals, code branching, subroutines, a call stack (with parameter passing and local variable scope on some models), multi-threading, and automatic subroutines (i.e. event-driven programming).
DMC code runs on the Galil Real Time Operating System (RTOS) which is specifically designed for Galil hardware and for motion control.
The learning curve on DMC code is quite fast, usually less than one hour to basic motion, so called, "spinning motors". It is the fastest to learn, the easiest, the simplest, and one of the most flexible and powerful languages in the industry. Don't forget, Galil's Applications Support Team is available to assist you; from the most basic question to the most complicated needs.
However you want, there are three general approaches to Galil programming.
In this approach, a host computer is only used during development to program the controller. The program is then downloaded and burned to non-volatile flash using the #AUTO automatic subroutine to indicate where code execution should start on boot-up. The Galil controller will now run "standalone," not requiring any intervention from the host. Note that for serial and Ethernet controllers, the standalone controller can still actively work with other controllers in a network, without host intervention.
PCI and other PC bus-based controllers support this approach, although still require the PCI bus for power.
GalilTools (GT) is provided as a programming environment for developing embedded applications.
If a GUI or other frontend is desired to be run on a host, all development can be conducted on the host PC, with the architecture, operating system, and programming language of choice. In this approach, the controller receives every command from the host PC, nothing is running embedded. Many Galil firmware features are available to facilitate host-centric programming including mode-of-motion buffers, data logging buffers, asynchronous data record updates from the controller, PCI and UDP interrupt events, and more.
GalilTools (GT) is bundled with a programming library (API) for programming applications from a host. Many popular operating systems and languages are supported.
Perhaps the most versatile approach to Galil system design, the Hybrid approach allows for both embedded code and host-side code to work in tandem. Typically an application is developed for embedded use in DMC code. The code incorporates all of the detail of an application but relies on the host to provide it data. Through variables, arrays, and other commands, the host is able to define the bounds of the embedded algorithms. The host plays a supervisory role, interrogating status, receiving asynchronous updates from the controller, starting and stopping threads, and so on. The controller takes care of the motion and I/O responsibilities based on its embedded program, and the controller's real time operating system (RTOS) ensures that the application won't suffer from indeterminacy which is common on general purpose PC operating systems (e.g. Microsoft Windows). Because the controller takes care of the details, the host is able to use its resources on other tasks, such as complicated number crunching or user interface.
It is noteworthy that Galil Standalone controllers (e.g. DMC-40x0, DMC-41x3, DMC-21x3, RIO-47xxx) can leverage the Ethernet to provide powerful modularity. Using any of the above three system approaches, multiple controllers can work in concert to achieve an application's requirements. Networked controllers also provide easy scalability. Need some more digital or analog I/O? Add an RIO. Need another axis of control? Add another DMC to the network. Both the Galil firmware and the Galil software libraries provide features which allow easy use of multiple controllers on an Ethernet network. RS232/422/485 networks are also possible.
DMC language can be broken up into the following general classifications
| Classification | Description | Examples | Example Comments |
|---|---|---|---|
| Explicit Notation Only | The command receives its arguments only by assignment with the "=" operator. | IHC=192,168,1,101<1070>2 | Create a TCP connection on Ethernet handle C to a device at IP address 192.168.1.101 on port 1070 |
| Implicit Notation Only | The command receives its arguments only by an implicit argument order. | IA 192,168,1,102 | Set the local IP address to 192.168.1.102 |
| Explicit & Implicit | The command receives its arguments either by an explicit assignment using the "=" symbol, or an implicit argument order. | KPA=64;KPB=32;KPH=128 KP 64,32,,,,,,128 | Assign the proportional constant (KP) of the PID filter to three different axes. |
| Accepts Axis Mask | The command receives its arguments as a string of valid axis names. | ST ADF | Stop (ST) axes A, D and F. Leave other axes running. |
| Two Letter Only | The command accepts no arguments | BN | Burn (BN) controller parameters to flash memory |
| Operator or Comparator | Operators take two arguments and produce a result. Comparators take two values and return a Boolean (1 or 0). | +,-,*,/ =,<,>,<=,>=,<> | Operators Comparators |
| @ Function | Starting with the @ character, these functions take one argument and perform a function, returning its result | @SIN,@ASIN @AN,@IN @RND,@FRAC,@COM | Trig functions Sine and ArcSine I/O functions Analog in and Digital in Numerical functions Round, Fractional Part, Bitwise compliment |
| Embedded Only | Not valid from the terminal, or from PC-side code, these commands are used in embedded DMC code only | IF,ELSE,ENDIF JS,JP EN, RE | IF Conditionals Jump commands End program, Return from Error |
| Operand | Operands hold values, and are not valid on their own. They can be used as arguments to commands, operators or comparators | _TPA _LFC _TC | Current position of axis A encoder Forward limit state on C axis Current Error code |
| Trippoint | Trippoints hold up a thread's execution (block) until a certain condition occurs. These are a special case of Embedded Only type commands. | WT 1000 AMA AI1 | Wait 1000 ms Wait until axis A completes profiled motion Wait for input one to go high |
| Comment | Comments are used to document code. | 'This is a comment | There are three types of comments: REM, ', and NO |
DMC code is case sensitive. All Galil commands are uppercase. User variables and arrays can be upper-case or lower case. Galil recommends that array and variable names contain at least one lower-case character to help distinguish them from commands.
These commands specify data using an axis designator followed by an equals sign. The * symbol can be used in place of the axis designator. The * defines data for all axes to be the same. For example:
| Syntax | Description |
|---|---|
| PRB=1000 | Sets B axis data at 1000 |
| PR*=1000 | Sets all axes to 1000 |
These commands require numerical arguments to be specified following the instruction. Values may be specified for any axis separately or any combination of axes. The comma delimiter indicates argument location. For commands that affect axes, the order of arguments is axis A first, followed by a comma, axis B next, followed by a comma, and so on. Omitting an argument will result in two consecutive commas and doesn't change that axis' current value. Examples of valid syntax are listed below.
| Valid Syntax | Description |
|---|---|
| AC n | Specify argument for A axis only |
| AC n,n | Specify argument for A and B only |
| AC n,,n | Specify argument for A and C only |
| AC n,n,n,n | Specify arguments for A,B,C,D axes |
| AC ,n,,,n | Specify arguments for B and E axis only |
| AC ,,,n,n | Specify arguments for E and F |
Where n is replaced by actual values.
These commands require the user to identify the specific axes to be affected. These commands are followed by uppercase X,Y,Z and W or A,B,C,D,E,F,G and H. In DMC code, X,Y,Z,W and A,B,C,D are synonyms, respectively.
No commas are used and the order of axes is not important. When an argument is not required and is not given, the command is executed for all axes.
| Valid Syntax | Description |
|---|---|
| SH A | Servo Here, A only |
| SH ABD | Servo Here, A,B and D axes |
| SH ACD | Servo Here, A,C and D axes |
| SH ABCD | Servo Here, A,B,C and D axes |
| SH XYZW | Identical to SH ABCD |
| SH BCAD | Servo Here, A,B,C and D axes |
| SH ADEG | Servo Here, A,D,E and G axes |
| SH H | Servo Here, H axis only |
| SH | Servo Here, all axes |
These commands have no options or arguments. Some examples follow.
| Valid Syntax | Description |
|---|---|
| BN | Burn parameters |
| BV | Burn Variables |
| BP | Burn Programs |
| ID | Identify hardware configuration |
| LA | List arrays |
Operators and Comparators take two arguments and return one value. All comparison and operations occur left to right. That is, multiplication and addition have the same order-of-operation priority, and operations and comparisons are performed as encountered on a left to right search. Parenthesis should be used to indicate order of operation precedence. Some examples follow.
| Valid Syntax | Description |
|---|---|
| var = 1 + 1 | Variable var is assigned value 2 |
| var = 2 + 1 * 3 | Variable var is assigned value 9 |
| var = 2 + (1 * 3) | Variable var is assigned value 5 |
| IF ((a=b) & (a=c)) | Checks if a=b=c |
| Invalid syntax to check if a=b=c | |
| var = (a=1) | var is assigned with Boolean value (true/false) based on comparison a=1 |
At functions take one value or evaluated expression and return a result. Some examples follow.
| Valid Syntax | Description |
|---|---|
| var = @SIN[90] | Variable var is assigned value 1. Sine of 90 degrees. |
| var = @ASIN[1] | Variable var is assigned value 90. Inverse Sine of 1 |
| var = @IN[1] | Variable var is assigned 1 or 0, based on current state of digital input 1 |
| var = @RND[1 + 0.6] | Variable var is assigned 2, 1.6 round to the nearest integer |
Embedded commands make sense only in the context of an embedded application. These commands include jumps, if-then-else syntax, subroutines, etc. Some examples follow.
| Valid Syntax | Description |
|---|---|
| #go | Labels can be called by name in order to jump code to specific lines |
| JP#go | Jump to line number indicated by #go label |
| #AUTO | Automatic subroutine. #AUTO is the entry point for execution on bootup. See entries starting with # for other automatic subroutines. |
| RI | Return from interrupt. This is the termination for certain automatic subroutines (event handlers) |
| IF (a=5);MG"Five";ELSE;MG"Not Five";ENDIF | If statement. ; can be replaced by carriage return for better readability |
Automatic subroutines operate very similarly to event handlers in event-driven languages. When an event occurs, execution of code jumps to the automatic subroutine. Once the end of the automatic subroutine is reached, code execution continues where it left off.
Many commands have corresponding operands that can be used for interrogation or for use within mathematical or other expressions. Operands are not valid alone, and must be used inside a valid DMC code expression. For example, to print the value of the TIME operand the following command is issued.
:MG TIME 13779546.0000 :
To assign TIME to a variable and then print it, the following is used.
:var=TIME :MG var 13909046.0000 :
All DMC codes starting with the underscore _ character are operands. The servo loop counter, TIME, is an operand without an underscore.
Variables and array elements act similarly to operands. Whereas operands are read-only, variables and array elements are read-write. Operands, variables, and array elements can be arguments to commands, are valid in mathematical expressions, and can be used in assignments to other variables and array elements.
The controller provides several commands that can be used to pause execution of code until certain conditions are met. Commands of this type are called "trippoints." Such trippoints may wait for an elapsed time, wait for a particular input, or in motion controllers wait for particular motion event to occur.
When a trippoint command is executed, the program halts execution of the next line of code until the status of the trippoint is cleared. Note that the trippoint only halts execution of the thread from which it is commanded while all other independent threads are unaffected. Additionally, if the trippoint is commanded from a subroutine, execution of the subroutine, as well as its calling thread, is halted.
Trippoints are intended for use only within embedded DMC code and should not be sent from a terminal or a host application program executing from a PC.
| Trippoint | Short Description | Supported On |
|---|---|---|
| WT | wait for a time period (sleep) | All Galil Hardware |
| AI | wait for a digital input | All Galil Hardware |
| AM | after move | Motion Controllers |
| MC | motion complete, in position | Motion Controllers |
| AT | At time, time from reference | All Galil Hardware |
| AD | after distance | Motion Controllers |
| AS | At speed | Motion Controllers |
| AV | After Vector Distance | Motion Controllers |
| AA | After Analog | RIO-47xxx only |
Comments are used to document code, and to disable lines of code while debugging. There are three ways to comment.
REM REM stands for "Remark." When a line begins with the REM command, the entire line is stripped by Galil software before downloading to the controller. REM is NOT a recognized Galil command; it is a keyword recognized by Galil software as data that is to be skipped during program download. When program speed and code length are at a premium, use REM comments.
NO NO stands for "No Operation." Lines beginning with NO are downloaded to the controller and incur a non-zero processing overhead as a result. If the developer desires the comments to stay in code so that uploaded code will still be notated, use NO or '. NO comments are not stripped when code is compressed by software.
' The single quote character is similar to NO. Lines beginning with ' are downloaded to the controller and incur a non-zero processing overhead as a result. If the developer desires the comments to stay in code so that uploaded code will still be notated, use NO or '. ' comments ARE stripped when code is compressed by software.
When commenting inline, NO and ' are valid when preceded by a ; character. REM is only valid as the start of a line. Some examples follow.
BG;' This is a comment. semicolon and ' precede, followed by spaces, and then the comment ST;NO Same as above, except on compression, this data will remain, less spaces REM This is a remark. It will not be downloaded to the controller by Galil software NO This is an NO comment starting a line NOTE This is also an NO comment ' This is a single quote comment starting a line 'PRX=1000;BGX;' This line of code has been disabled with a leading '
; The semicolon is used to separate individual commands on a single line of embedded code or in a single interrogation from the host. When running multi-threaded, embedded code, all commands on a single line will be executed before the program counter switches to the next thread*. Using multiple commands on a single line therefore allows for increased thread priority.
* Certain commands such as trippoints will cause the program counter to continue to the next thread before a line has completed.
' On the RIO series of PLCs, the backtick (ascii 96) is a line continuation character. If a line of code passes the RIO's 40 character length limit, the ` character can be used to continue the line of code on the next line.
Most commands accept a question mark (?) as an argument. This argument causes the controller to return parameter information. Type the command followed by a ? for each axis requested. The syntax format is the same as the parameter arguments described above except '?' replaces the values.
| Syntax | Description |
|---|---|
| PR ? | The controller will return the PR value for the A axis |
| PR ,,,? | The controller will return the PR value for the D axis |
| PR ?,?,?,? | The controller will return the PR value for the A,B,C and D axes |
| PR ,,,,,,,? | The controller will return the PR value for the H axis |
| PR*=? | The controller will return the PR value for all axes |
There is only one native data type in DMC language, the Galil4.2 format. Galil4.2 is a signed, fixed-point, decimal number with 4 bytes of integer and 2 bytes of fraction. Bit encoding of Galil4.2 is 2's compliment.
Integer values range from -2,147,483,648 to 2,147,483,647
Fractional values range from 0.999985 to .000015 in increments of .000015 (one part in 65535). When working with very small fractional values, use the $ formatter to display the number in hex.
:v=1-$0.0001;'subtract the smallest fractional value
:v=?
1.0000
:v=?{$1.4};'hex display has higher resolution
$0.FFFF
:v=v+$0.0001
:v=?
1.0000
:v=?{$1.4}
$1.0000
:
Galil "strings" are still variables in 4.2 format, with each byte printed as the ASCII representation of the number. Galil strings are max 6 characters. The left most character of a string is the most significant byte in the Galil4.2 number.
A Boolean is represented in the Galil language as a Galil4.2 value. 0.0 is false. All other values are true.
:a=1 :b=2 :c=(a=b);'(a=b) returns a Galil Boolean :LV a= 1.0000 b= 2.0000 c= 0.0000 :a=2 :c=(a=b) :LV a= 2.0000 b= 2.0000 c= 1.0000 :
The units of distance in a Galil controller are either in "counts" or "steps". A count is a single unit of feedback, such as a quadrature count, an SSI or BiSS bit, or an Analog to Digital converter bit. Counts are typical with servos. Steps are used for stepper-type motors. Steps are open-loop units and refer to a single level transition sent to a stepper amplifier. In general for a unit of real distance, 1 step is NOT equal in distance to 1 count. See the "Stepper Position Maintenance Mode" in the user manual for more information.
Each axis of a Galil motion controller can be configured to control either a servo or a stepper. In this documentation, servo motors are generally assumed. Differences between functionality in stepper and servo operation are noted in each command. Where not explicitly noted otherwise, when using stepper motors, the unit "count" can be exchanged with the unit "step" (e.g. steps per second instead of counts per second).
Each Galil controller has a flash memory provided for saving parameters and user data. The flash is divided into three sectors, Parameters, Variables and Arrays, and Program. Each sector has an associated burn command which burns the entire sector.
| Flash Sector | Data Storage | Burn Command |
|---|---|---|
| Parameters | Stores the controller parameters such as PID filter coefficients, IP address, motion kinematic values, I/O configurations | BN |
| Variables and Array | Stores the currently allocated variable table (LV) and each of the arrays in the array table (LA) | BV |
| Program | Stores program currently downloaded on the controller | BP |
When a master reset occurs, the controller will reset all setup parameters to their default values and the non-volatile memory is cleared to the factory state. A master reset is executed by the command, <ctrl R> <ctrl S> <Return> OR by powering up or resetting the controller with the MRST jumper on.