Description
GDK provides a macro feature to allow users to automate tasks. During the development and production of Galil applications, it is common to have multiple commands that are used frequently together. These commands can be assigned to a button or keyboard shortcut in GDK. Examples of such automated tasks follow.
- Loading a special firmware.
- Loading a production program, setting the program password, and locking the program memory.
- Configuring motor commutation when developing.
- Configuring and bringing up EtherCAT networks.
- Printing formatted debugging information with the MG command.
- Profiling moves for experimentation and development.
Macro Content
A macro is a simple text file containing DMC commands. It is very similar to an embedded dmc Galil program, but has the file extension sen (for send file). Any command that can be sent from the GDK Terminal can be used within a sen macro file. Commands that are only supported in an embedded program are not supported in macros (IF, JP, etc).
In addition to Galil commands, GDK Macros support a subset of the gclib communication library.
Adding Macros to GDK
There are four ways to add a macro to GDK.
- From within the Editor tool, author a macro and save the file with a .sen extension. The macro will automatically be added to the macro toolbar.
- Use the Add Macro button in the main GDK toolbar to add a pre-existing .sen file.
- Open a pre-existing sen file from the Windows shell. GDK will launch and the macro will be added.
- Drag-and-drop a pre-existing sen file into the GDK window.
Macros added to GDK appear in the macro toolbar. By default this toolbar is on the right side of the main GDK window. It can be moved to the top or the bottom of the main window, or floated on its own. If no macros are in GDK, the toolbar will not be displayed.
Macro Options
A macro is a pairing of up to four pieces of information.
- An existing sen macro file.
- An existing connection alias.
- An optional keyboard shortcut to trigger the macro.
- An icon to identify the macro visually.
To change these pairings, click the down arrow in the macro button to display the macro options pop-up menu.
Running Macros
To trigger a macro, click its button or type the keyboard shortcut. GDK will find an existing Terminal connected to the alias, or open a new Terminal to the alias and begin running the macro.
Any error returned from the controller will cause the macro to error and stop running.
Invoking gclib Functions
The following gclib functions are available to GDK Macros.
Function from gclib | Example Usage in Macro | Notes |
---|---|---|
GArrayDownloadFile() | ##gclib "GArrayDownloadFile(C:\dev\test\array\24000.csv)" | |
GArrayUploadFile() | ##gclib "GArrayUploadFile(C:\dev\test\array\uploaded.csv, A)" | Array name A specified |
GArrayUploadFile() | ##gclib "GArrayUploadFile(C:\dev\test\array\uploaded.csv") | Upload all arrays in controller's array table |
GFirmwareDownload() | ##gclib "GFirmwareDownload(C:\dev\test\fw\dmc-4000-r13b.hex)" | |
GMotionComplete() | ##gclib "GMotionComplete(A)" | |
GProgramDownloadFile() | ##gclib "GProgramDownloadFile(C:\dev\test\dmc\merge_test.dmc)" | Default preprocessor arguments |
GProgramDownloadFile() | ##gclib "GProgramDownloadFile(C:\dev\test\dmc\merge_test.dmc, --min 4)" | Specify preprocessor options |
GSetupDownloadFile() | ##gclib "GSetupDownloadFile(C:\dev\test\gcb\dmc4080_rev_1.3b.gcb)" | |
GSleep() | ##gclib "GSleep(100)" | |
GWaitForBool() | ##gclib "GWaitForBool(i=1)" |
When using the ##gclib preprocessor directive in a macro, don't forget to put a quad hash at the top of the file so the GDK Editor can recognize it. See the examples below.
Lines starting with ##gclib can also be used directly in the Terminal keyboard input to invoke the gclib call directly.
Notes
- Some Galil commands that are valid in macros are made up of non-printable control keys. To specify a control key, prepend a caret (^) before the desired control key. For example, to specify Ctrl+R Ctrl+V, use ^R^V in a macro.
- Macros are run from within GDK, sending commands to the Galil controller. The controller's program is not changed and no embedded program is executed. Embedded-only commands such as EN, IF, ELSE, ENDIF, JP, and JS are not supported in macros.
- A running macro blocks the Terminal it is running in. Most macros executing Galil commands will complete so quickly that this blocking is negligible. However, for long-running macros, it can be useful to open another Terminal tool to the same alias. This will allow the user to send commands while another Terminal is busy executing a macro.
- When a Tool window is popped out of the main GDK window, keyboard shortcuts in the tool will not trigger macros in the main GDK Window. Click the macro button or use the keyboard shortcut when focus is in the main window.
Examples
Example 1. Initializing a Controller
The following example will perform the following.
- Load a specified firmware.
- load a Setup file, which restores parameters, variables, arrays, and the user's program to a previously saved state.
- Set the user's password.
- Lock the user's program.
A macro such as this can be used to bootstrap a factory-reset controller to production state in one step.
## Use a 'quad hash' for GDK editing ## ^R^V //only valid in macro, not in DMC program //load firmware ##gclib "GFirmwareDownload(C:\dev\test\fw\dmc-4000-r13b-ser.hex)" ^R^V //load the controller's production memory ##gclib "GSetupDownloadFile(C:\dev\test\gcb\dmc4080_rev_1.3b-ser.gcb)" PW1234,1234//set password ^L^K1234,1//lock program BN;BV;BP //save everything //don't use EN to end a macro